Model Context Protocol (MCP) (original) (raw)

Last Updated : 1 May, 2026

Model Context Protocol (MCP) is a standardized framework by Anthropic that enables AI models to connect with external tools and data sources, providing secure, scalable and real time access without custom integrations.

MCP Architecture

model_context_protocol_architecture

MCP Architecture

MCP is designed as a flexible system that connects AI models with external tools and data sources through three main components: servers, clients and hosts, enabling smooth and efficient interaction.

1. MCP Servers

2. MCP Clients

3. MCP Hosts

Use of MCP in Agent Workflow

MCP helps AI agents manage different types of context efficiently, enabling better coordination, memory handling and secure interactions across tasks. Agents typically handle three types of context:

Implementation

This example shows how to set up a Hugging Face MCP server in VS Code to interact with models and datasets using a standardized API connection.

Step 1: Create a .vscode Folder

We stores your VS Code configuration files like settings.json, launch.json and mcp.json.

imagemcp1

.vscode folder

Step 2: Configure the MCP Server

Create and set up the mcp.json file with details like server type, URL and API token to connect with the Hugging Face MCP server.

{ "servers": [ { "Hf-mcp-server": { "type": "sse", "url": "https://huggingface.co/mcplogin", "headers": { "Authorization": "Bearer YOUR_HUGGINGFACE_API_KEY" } } } ] }

`

Step 3: Choose Command Mode

Selecting Command (stdio) lets you run a local MCP server script directly from your system.

imagemcp3

Local Command

Step 4: Select MCP Server in Copilot

Before moving to the next step, install Copilot in VS Code.

Refer to: How to Install GitHub Copilot on VSCode

imagemcp5

MCP Server Tool

**Step 5: Verify MCP Server Connection

import requests import json

def load_mcp_config(config_file_path): print(f"Loading configuration from {config_file_path}...") with open(config_file_path, "r") as f: config = json.load(f) server_config = config["servers"]["hf-mcp-server"] return { "url": server_config["url"], "headers": server_config.get("headers", {}) }

def check_mcp_server(mcp_server): response = requests.get(mcp_server["url"], headers=mcp_server.get("headers", {}), timeout=10) if response.status_code == 200: print("MCP server is reachable and working!") else: print(f"MCP server responded with status code: {response.status_code}") print(f"Response text: {response.text[:100]}...")

if name == "main": CONFIG_FILE = "mcp.json" mcp_server_config = load_mcp_config(CONFIG_FILE) check_mcp_server(mcp_server_config)

`

**Output:

imagemcp6

Configuration

Step 6: Verify Configuration via Copilot

imagemcp7

MCP Servers

imagemcp8

Text Generation Using MCP Server

Step 8: Generate Image

Applications

Advantages

Limitations