LLM
  • Overview
    • LLM
  • Key Concepts
    • Models
    • Key Concepts
  • Quckstart
    • Jan.ai
    • đŸ¦™Ollama & Chatbox
  • Playground
  • Workflows
    • n8n
    • Flowise
      • Basic Chatbot
      • Research Agent
      • Company Information Agent
      • PDF Parser
      • Knowledge Base
      • Lead Gen
    • Agno
  • LLM Projects
    • RAG + ChainLit
  • Model Context Protocol
    • Claude + MCPs
    • Flowise + MCPs
  • Knowledge Graphs
    • neo4j
    • WhyHow.ai
  • Setup
    • WSL & Docker
    • đŸ¦™Quickstart
    • Key Concepts
    • Workflows
    • Model Context Protocol
Powered by GitBook
On this page

Model Context Protocol

Extend the functionality of your Tool with MCP ( Model Context Protocol) ..

PreviousRAG + ChainLitNextClaude + MCPs

Last updated 22 days ago

Model Context Protocol (MCP)

The Model Context Protocol (MCP) is a framework that governs how AI language models manage information during conversations. It defines rules for handling context windows—the amount of text a model can process at once.

MCP categorizes information into different priority levels, including system instructions, conversation history, and current user inputs. This prioritization ensures the most relevant information remains accessible when context space is limited.

Context management mechanisms like windowing (removing older information), compression (summarizing previous exchanges), and retrieval (accessing external information) help models maintain conversational coherence while working within technical constraints.

The practical impact of MCP is seen in a model's ability to maintain consistent behavior, remember details from earlier exchanges, and balance between past context and new inputs. This affects everything from casual chatting to complex reasoning tasks.

MCP continues to evolve as AI systems advance, with early models having very limited context abilities compared to current systems that can maintain coherence across much longer conversations.

MCP Components

  1. Host application: LLMs that interact with users and initiate connections. This includes Claude Desktop, AI-enhanced IDEs like Cursor, and standard web-based LLM chat interfaces.

  2. MCP client: Integrated within the host application to handle connections with MCP servers, translating between the host’s requirements and the Model Context Protocol. Clients are built into host applications, like the MCP client inside Claude Desktop.

  3. MCP server: Adds context and capabilities, exposing specific functions to AI apps through MCP. Each standalone server typically focuses on a specific integration point, like GitHub for repository access or a PostgreSQL for database operations.

  4. Transport layer: The communication mechanism between clients and servers. MCP supports two primary transport methods:

    • STDIO (Standard Input/Output): Mainly local integrations where the server runs in the same environment as the client.

    • HTTP+SSE (Server-Sent Events): Remote connections, with HTTP for client requests and SS for server responses and streaming.

When a user interacts with a host application (an AI app) that supports MCP, several processes occur behind the scenes to enable quick and seamless communication between the AI and external systems. Let’s take a closer look at what happens when a user asks Claude Desktop to perform a task that invokes tools outside the chat window.

Protocol handshake

  1. Initial connection: When an MCP client (like Claude Desktop) starts up, it connects to the configured MCP servers on your device.

  2. Capability discovery: The client asks each server "What capabilities do you offer?" Each server responds with its available tools, resources, and prompts.

  3. Registration: The client registers these capabilities, making them available for the AI to use during your conversation.

From user request to external data

Let's say you ask Claude, "What's the weather like in San Francisco today?" Here's what happens:

  1. Need recognition: Claude analyzes your question and recognizes it needs external, real-time information that wasn't in its training data.

  2. Tool or resource selection: Claude identifies that it needs to use an MCP capability to fulfill your request.

  3. Permission request: The client displays a permission prompt asking if you want to allow access to the external tool or resource.

  4. Information exchange: Once approved, the client sends a request to the appropriate MCP server using the standardized protocol format.

  5. External processing: The MCP server processes the request, performing whatever action is needed—querying a weather service, reading a file, or accessing a database.

  6. Result return: The server returns the requested information to the client in a standardized format.

  7. Context integration: Claude receives this information and incorporates it into its understanding of the conversation.

  8. Response generation: Claude generates a response that includes the external information, providing you with an answer based on current data.

Ideally, this entire process happens in seconds, creating an unobtrusive experience where Claude appears to "know" information it couldn't possibly have from its training data alone.

MCP Clients

MCP clients span a wide spectrum of applications, from desktop interfaces to specialized development environments. At its core, MCP follows a client-server architecture where host applications (MCP clients) maintain one-to-one connections with MCP servers that expose specific capabilities through the standardized protocol.

MCP Servers

All communication in MCP uses as the underlying message standard, providing a standardized structure for requests, responses, and notifications.

JSON-RPC 2.0
https://github.com/punkpeye/awesome-mcp-clients
https://github.com/modelcontextprotocol/servers
Introduction - Model Context ProtocolModel Context Protocol
Link to MCP
Logo
MCP Core Components
Protocol Handshake