# Model Context Protocol (MCP) An Open Standard introduced by Anthropic ([[Claude]]) end November 2024. The goal of MCP is to define a standard for connecting [[Large Language Models (LLMs)]] to data sources and tools. It extends the knowledge LLMs have access to, and introduces the capability of interacting (read and write) with tools and platforms. Of course, the idea, similar to [[Retrieval Augmented Generation (RAG)]] and [[Vector Databases]] is to give LLMs access to data that they don't have (i.e., not part of their training data set). That includes data that was created after the LLM was trained, but also data that it couldn't have access to (e.g., private data of a company or individual). MCP provides an open protocol to connect AI systems with data sources. The MCP protocol supports two-way connections. From AI systems to tools and from tools to AI systems. ## Initial release Upon initial release, Anthropic published: - The MCP specification and SDKs - Local MCP support in the [[Claude]] Desktop applications - An open-source repository of MCP servers ## Architecture and Components - MCP Hosts: Programs like [[Claude]] Desktop, IDEs, and tools that want to access resources through the MCP protocol - MCP Clients: Clients that maintain 1:1 connections with servers - MCP Servers: Programs that expose specific capabilities through the MCP protocol - Local Resources: Your machine's resources (databases, files, services) that MCP servers can access - Remote Resources: Resources available over the network/the Internet (e.g., through APIs) that MCP servers can connect to MCP uses a client-server architecture, where a host application can connect to multiple servers: ![[MCP high level architecture.png]] Caption: MCP architecture overview As shown above, a single MCP host (e.g., Claude Desktop, IDEs, etc) can interact with many MCP servers (e.g., filesystem access, search support, sqlite access, etc) through the MCP protocol. Example with SQLite: ![[MCP SQLite example.png]] Notes: - MCP servers only expose specific/controlled capabilities - MCP servers run locally on your machine, and the resources they access are not exposed to the Internet - Claude Desktop requires user confirmation for sensitive operations (e.g., reading/writing files on your behalf) ## MCP Clients There's a list of applications that support MCP integrations here: https://modelcontextprotocol.io/clients ## Protocol details The MCP protocol uses JSON-RPC 2.0 messages to enable communication between hosts, clients and servers: - Hosts: LLM "applications" that initiate connections - Clients: Connectors within the host application - Servers: Services that provide context and capabilities The MCP protocol is inspired by Microsoft's [Language Server Protocol](https://microsoft.github.io/language-server-protocol/). The protocol uses stateful connections, and handles client/server capability negotiation. Servers may offer any of the following features to clients: - Resources: Context and data, for the user or the AI model to use - Prompts: Templated messages and workflows for users - Tools: Functions for the AI model to execute Clients may offer the following features to servers: - Sampling: Server-initiated agentic behaviors and recursive LLM interactions In addition, the protocol includes additional utilities: - Configuration - Progress tracking - Cancellation - Error reporting - Logging ## Prompts MCP Prompts enable MCP servers to define reusable prompt templates and workflows that MCP clients can surface to users in their user interfaces and LLMs. They provide a way to standardize and share common LLM interactions. Details: https://modelcontextprotocol.io/docs/concepts/prompts ## Tools MCP Tools enable LLMs to perform actions through MCP servers. They enable MCP servers to expose executable functionality to MCP clients, enabling LLMs to interact with external systems/services, perform computations, and perform real-world actions. Details: https://modelcontextprotocol.io/docs/concepts/tools ## Sampling Sampling is an MCP feature that allows MCP servers to request LLM completions through the MCP client connected to it, enabling agentic behaviors. As of November 2024, this feature is not yet supported by Claude Desktop, but it's certainly worth keeping an eye on. Details: https://modelcontextprotocol.io/docs/concepts/sampling ## MCP Protocol Security Considerations Given that MCP enables arbitrary data access and code execution, implementors need to pay attention and address important security and trust considerations See here for details: https://spec.modelcontextprotocol.io/specification/#key-principles See here for guidelines: https://spec.modelcontextprotocol.io/specification/#implementation-guidelines The full specification is documented here: https://spec.modelcontextprotocol.io/specification/ ## SDKs MCP currently (November 2024) includes two SDKs: - Python: https://github.com/modelcontextprotocol/python-sdk - TypeScript: https://github.com/modelcontextprotocol/typescript-sdk There are introduction guides available: - https://modelcontextprotocol.io/docs/first-server/python - https://modelcontextprotocol.io/docs/first-server/typescript ## Debugging There's a guide for troubleshooting MCP issues: - https://modelcontextprotocol.io/docs/tools/debugging - https://modelcontextprotocol.io/docs/tools/inspector ## Claude Desktop ### Debugging To debug MCP servers, see https://modelcontextprotocol.io/docs/tools/debugging ### Windows First, make sure you are using Claude Desktop >= 0.7.5. See [[Claude]] to know where the [[Claude]] configuration is located. Some notes: - Make sure your filepaths have `\\` escaped backslashes - The command should be the same for all node tools: `"command": "path\to\your\node_install\node.exe",` unless if node is on your PATH - The first arg should always be `"args":["path\to\node_modules\@servername\dist\index.js",...]` - Non-node-based tools should just work, ie sqlite works just fine - If the `claude_desktop_config.json` file does not exist, then create it manually Example `claude_desktop_config.json` file configuration for the filesystem MCP server: ``` "mcpServers": { "filesystem": { "command": "C:\\Program Files\\nodejs\\node.exe", "args": [ "C:\\Users\\myname\\AppData\\Roaming\\npm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", "C:\\Users\\myname\\myfiles ] }, ``` Assuming you have put `node` on your path, you can juste use "node.exe" as command. You can also install MCP servers globally to ease their use: ``` npm install -g @modelcontextprotocol/server-memory npm install -g @modelcontextprotocol/server-puppeteer npm install -g @modelcontextprotocol/server-brave-search npm install -g @modelcontextprotocol/server-google-maps npm install -g @modelcontextprotocol/server-postgres ``` Once correctly configured, you should be able to access your files and do tons of cool stuff. Here's an example where Claude has read-access to my Obsidian notes: ``` { "mcpServers": { "filesystem": { "command": "node.exe", "args": [ "C:\\npm\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", "C:\\Users\\trankill\\My Drive\\Notes\\Seb" ] } } } ``` ![[Model Context Protocol (MCP) - access obsidian notes.png]] ## References - Anthropic's Announcement: https://www.anthropic.com/news/model-context-protocol - Official Website: https://modelcontextprotocol.io/introduction - Source code, specification and SDKs: https://github.com/modelcontextprotocol - TypeScript: https://github.com/modelcontextprotocol/typescript-sdk - Python: https://github.com/modelcontextprotocol/python-sdk - Announcement: https://www.anthropic.com/news/model-context-protocol - Protocol specification: https://spec.modelcontextprotocol.io/specification/ - Protocol TypeScript schema: https://github.com/modelcontextprotocol/specification/blob/main/schema/schema.ts - MCP Servers - Official and a part of the community ones: https://github.com/modelcontextprotocol/servers - Others - https://smithery.ai/ - https://www.pulsemcp.com/ - https://github.com/punkpeye/awesome-mcp-servers - https://github.com/wong2/awesome-mcp-servers - https://github.com/appcypher/awesome-mcp-servers - Interesting - Bluesky: https://github.com/keturiosakys/bluesky-context-server - Brave Search: https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search - Chat summary: https://github.com/chatmcp/mcp-server-chatsum - Fetch: https://github.com/modelcontextprotocol/servers/tree/main/src/fetch - Google Maps: https://github.com/modelcontextprotocol/servers/tree/main/src/google-maps - Markdownify: https://github.com/zcaceres/markdownify-mcp - Memory: https://github.com/modelcontextprotocol/servers/tree/main/src/memory - Memory Mesh: [https://github.com/CheMiguel23/MemoryMesh](https://github.com/CheMiguel23/MemoryMesh) - Notion: https://github.com/danhilse/notion_mcp - Puppeteer: https://github.com/modelcontextprotocol/servers/tree/main/src/puppeteer - Obsidian: https://github.com/calclavia/mcp-obsidian - OpenAI: https://github.com/snaggle-ai/openapi-mcp-server - OpenRouter: https://glama.ai/mcp/servers/xdnmf8yei0 - Sequential Thinking: https://github.com/modelcontextprotocol/servers/tree/main/src%2Fsequentialthinking - Explanations: https://x.com/combdn/status/1865031688629187030 - Spotify: https://github.com/varunneal/spotify-mcp - Spring (Java) SDK: https://spring.io/blog/2024/12/11/spring-ai-mcp-announcement - Source code: https://github.com/spring-projects-experimental/spring-ai-mcp - Kotlin SDK: https://github.com/modelcontextprotocol/kotlin-sdk - Tools - MCP installer: https://github.com/anaisbetts/mcp-installer - MCP CLI: https://github.com/wong2/mcp-cli - Tutorials - https://www.youtube.com/watch?v=5CmAKm1wWW0 - https://www.youtube.com/watch?v=8mU2OeOCIrE - https://www.youtube.com/watch?v=VNb4tGAHgos - https://johnmaeda.medium.com/claude-mcp-first-run-be-sure-to-choose-settings-from-the-menubar-to-save-yourself-time-fa457ad37582 - https://medium.com/@LakshmiNarayana_U/exploring-model-context-protocol-mcp-with-claude-desktop-simplifying-ai-integration-e447087f95a1 - https://www.tomsguide.com/ai/claude-desktop-can-now-browse-the-internet-and-manage-files-on-your-computer-heres-whats-new - https://www.reddit.com/r/ClaudeAI/comments/1h06uec/with_mcp_claude_can_now_work_directly_with_local/ - Usage on Windows - https://github.com/modelcontextprotocol/servers/issues/75 - https://gist.github.com/feveromo/7a340d7795fca1ccd535a5802b976e1f - Communities - Reddit: https://www.reddit.com/r/mcp/?rdt=48491 - Discord: https://discord.com/invite/TFE8FmjCdS