Explanation on MCP
Explanation on MCP
Let’s Explain MCP Servers!
Hey devs, curious about how MCP (Model Context Protocol) servers’ power up your AI assistants in VS Code? Buckle up! I’ll break down what MCP servers are, why they matter, show you practical real-world uses, and walk you step-by-step on plugging them into your VS Code workflow with friendly, non-nonsense guidance all the way!
What’s an MCP Server In Human Speak?
Picture MCP as the USB-C for AI: it’s an open, universal connector that lets Large Language Models (LLMs) reach out to external tools, APIs, and data sources. Instead of hacking together custom integrations for every new AI thing, MCP gives you one standardized “socket” where all your AI, tools, and data can plug in and immediately play nice.
Just like how you expect every USB-C device to work with every laptop or charger, an AI hooked into MCP can fetch files, run workflows, poke APIs, and more even across platforms or vendors with zero glue code. That’s the promise!
How MCP Servers Work (And Why You Should Care)
Here’s the vibe:
- MCP Hosts: These are user-facing AI apps (Claude Desktop, VS Code, Cursor, etc.).
- MCP Clients: Connectors inside the host. Each manages a dedicated connection to one MCP server.
- MCP Servers: Standalone processes/services (local or cloud) that expose tools, data, or prompts (think: “list files”, “run tests”, “query DB”, etc.).
When you ask your AI assistant to “create a GitHub issue” or “find all files mentioning ‘auth’ in my repo”, that LLM routes your request, via the MCP client, to the appropriate MCP server. The server executes your command (using its own logic or calling outside APIs) and hands the result back for display in your chat or IDE.
The Anatomy: Tools, Resources & Prompts
Every MCP server fundamentally speaks in three “primitives”:
- Tools – Functions the AI can call to do stuff (i.e., create a file, send a message, trigger a Jenkins build).
- Resources – Data the AI can fetch and use as context but not change (i.e., the content of a file, a database row, API docs).
- Prompts – Preset templates for the AI to follow (i.e., “draft an email”, “plan a vacation”, “code review checklist”).
Each tool and resource is schema-defined, making things discoverable and automatable for both humans and AI.
Real-World Examples
Let’s get practical with some repeatable, modern MCP server use cases:
Developer Productivity
- VS Code + Microsoft Learn Docs MCP Server: Lets Copilot (or any LLM-powered IDE agent) directly search and quote the newest docs from Microsoft Learn, Azure, or Microsoft 365, instead of hallucinating API details
- Azure MCP Server: Allows you to provide cloud resources, fetch logs, query DBs, or trigger builds/monitoring via natural language in your coding environment
Security & DevOps
- SecOps MCP Server: Automatically scans logs, blocks IPs based on threat feeds, or runs playbooks (like quarantining hosts or notifying your SOC team)
- CI/CD Automation: Bridge Jenkins, GitHub, Docker, and Webex via a single agent that builds, deploys, notifies using just one query!
Communication & Data Access
- Slack MCP Server: Lets your AI assistant post updates in team channels or pull in channel links
- Google Calendar / Notion / Linear / Stripe Servers: Hook up directly for AI-supervised scheduling, bug tracking, or transaction processing
Data Science & Knowledge
- Custom Database MCP Server: Build an agent that answers natural-language queries from your very own Postgres or MongoDB
Why Use MCP in Your AI Workflow?
Three big wins:
- Plug-and-play integrations: Ditch the brittle, per-tool spaghetti code. Flip a config, and your agents gain new powers instantly.
- Security & consent: Every tool/resource asks for explicit privileges. Approve once, and the agent works with user supervision with no silent action at a distance.
- Unified extensibility: When Microsoft/Notion/Zapier ships new MCP servers, VS Code, Claude, and any compliant host can use them cross-vendor!
Key Technical Details (Code!)
Here’s an custom code snippet for a custom calculator server in Python, using the fastmcp Python SDK:
from fastmcp import FastMCP mcp = FastMCP("Hello World") @mcp.tool() def add(a: int, b: int) -> int: return int(a + b) @mcp.resource("greeting://{name}") def get_greeting(name: str) -> str: return f"Hello, {name}!" if __name__ == '__main__': mcp.run(transport='stdio')
This MCP server exposes “add” as a tool and “greeting” as a resource. You can plug this into VS Code, Cursor, Claude Desktop, and elsewhere.
How Does VS Code Fit Into the Story?
VS Code is now a first-class MCP host: it can speak MCP natively, both for local (stdio) and remote (HTTP/SSE) servers.
This means in VS Code, you can:
- Add new MCP server backends (local or remote) directly from the UI or mcp.json config
- Browse a registry/marketplace of popular MCP servers
- Use MCP tools as part of Copilot’s “Agent Mode”
- Setup workspace-only or per-user configurations
Setting Up MCP Servers in VS Code: Prerequisites
To get going, make sure you have:
- The latest Visual Studio Code
- GitHub Copilot extension (for Agent Mode/tool use)
- Access to MCP servers you want to add (or local server scripts)
- Any required API keys/tokens for external services (GitHub, Azure, etc.)
No need to install MCP manually for built-in experiences (e.g., Microsoft Learn Docs), but MCP SDKs are available for building your own.
Adding Local MCP Servers (STDIO Transport)
Want to wire up your own local tool? Here’s the standard workflow:
- Create your MCP server locally (Python, Node, etc.). For example, with FastMCP:
python calculator_mcp_server.py
- In VS Code, open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and choose MCP: Add Server.
- Pick “Command (stdio)” as the connection method.
- Enter the absolute path to your interpreter and script, e.g.:
/home/user/venv/bin/python ~/dev/mcp/calculator_mcp_server.py
- Give it a descriptive name (e.g. “calc_serve”) and pick “Workspace Settings” or “User Settings”. Workspace is safest for most workflows!
VS Code will generate a .vscode/mcp.json file in your workspace:
{ "servers": { "calc_serve": { "type": "stdio", "command": "/home/user/venv/bin/python", "args": [ "/home/user/dev/mcp/calculator_mcp_server.py" ] } } }
You’ll now see your server listed in the MCP Servers UI. Start it when prompted!
Using Remote (HTTP/SSE) MCP Servers
For hosted third party or distributed servers:
- In MCP’s “Add Server” dialog, pick the HTTP (or SSE) method.
- Enter/paste the server’s URL (e.g., https://mcp.composio.dev/your/path)
- Provide any needed API credentials (usually via input variables, not hardcoded in config for security reasons)
- Choose workspace or user-level scope
- Restart the server if prompted.
Now, VS Code will discover tools, resources, and prompts from the remote server no manual tool setup needed!1819
Using MCP Tools in Agent Mode
Once you’ve added MCP servers:
- Open the Copilot Chat panel (Ctrl+Alt+I).
- Switch to “Agent Mode” in the drop-down menu.
- Click the 🛠️ Tools icon. You’ll see a big list: MCP tools from all enabled servers, built-in tool agents, and so on.
- (Tip) Type # plus a tool name in your prompt “#add” to call a tool directly.
- Compose your request like “Sum 56 and 29” and let Copilot route it to your server.
- Approve the tool use (if requested) in the dialog: Per session, workspace, or global approval settings available.
Inspecting Available Tools and Resources
Want to check what tools an MCP server exposes?
- Run MCP: Show Installed Servers or MCP: List Servers via the Command Palette.
- Open the “MCP Servers” section in the Extensions sidebar for quick visual browsing.
- Click on any listed tool/resource to see its input schema, docs, and last-used status.
- Use the chat “Add Context > MCP Resources” menu to inject server-provided resources into a prompt.
This structured discovery makes it super easy to onboard new agents and keep everything transparent.
Building Your Own MCP Server (SDKs & Guide)
Want to roll your own? Here’s the starter stack:
- Python: Use fastmcp or the Model Context Protocol python SDK. Wrap your code with @mcp.tool(), @mcp.resource(), @mcp.prompt() decorators.
pip install "mcp[cli]"
- Node.js: Use the Official TypeScript SDK. Implement your server logic and export tools/resources, or use the ready-to-go examples from @anthropic-ai, @composio, etc.
- Others: Java, Go, C#, Kotlin have official SDKs for modern, type-safe integration.
Test locally with the MCP Inspector before deploying more widely.
Strongly recommended for workshops or teams: use a version control system and static code scanning for published servers!
For detailed step-by-step guides, see:
- Composio’s “Build Your Own MCP Server” blog
- Real Python’s hands-on MCP tutorial
- Microsoft’s official Python MCP SDK docs
Your guide on MCP servers is a very thorough and well-organized one, thank you. The concept of the Model Context Protocol as you explain it so brilliantly, making it look like an analogy with USB C and AI, and then the practical steps of integrating the VS Code with functioning code samples, makes what might seem a rather sophisticated subject matter easily digestible. This difference between Tools, Resources and Prompts as the fundamental primitives and practical application to Devops, security and developer productivity gives immeasurable value to any individual looking to improve their AI supported workflows. This is a precious resource and will surely speed up the adoption of MCP amongst development teams and I appreciate the time and effort you have put in to producing such a comprehensive reference, that can be put into action by the community.