Claude Seekho

MCP: Model Context Protocol

MCP is an open standard (launched by Anthropic in Nov 2024) that gives AI apps a common way to connect to external tools and data. It is called "USB-C for AI": build an MCP server once and it works in Claude, Claude Code, IDEs and other AI clients.

13.1 Architecture

Host → Client → Server
  1. 1.MCP Host: Claude Desktop, Claude Code, IDE
  2. 2.MCP Client: inside the host, one connection per server
  3. 3.MCP Server: GitHub, DB, Slack, filesystem...
  4. 4.Data source / API: the real system where the data lives

Messages travel in JSON-RPC 2.0 format

13.2 MCP primitives

PrimitiveWho controls itWhat it isExample
ToolsModelFunctions the model callscreate_issue, run_query
ResourcesApplicationRead-only data/context (by URI)File content, DB schema
PromptsUserReusable prompt templates (like slash commands)/review-pr
Sampling (client feature)Server makes the requestServer asks the client's LLM for a completionServer needs an AI summary
Roots (client feature)ClientWhich folders/URIs the server may work inProject directory
Elicitation (client feature)ServerAsking the user for extra input midway"Which branch?"

13.3 Transports

TransportWhenDetail
stdioLocal serverThe host runs it as a child process; they talk over stdin/stdout
Streamable HTTPRemote serverHTTP POST + optional SSE streaming; auth via OAuth
SSE (old)LegacyDeprecated; use Streamable HTTP

13.4 Your own MCP server (Python)

# pip install "mcp[cli]"
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("employee-db")

@mcp.tool()
def get_salary(emp_id: int) -> str:
    """Get the salary by employee ID."""
    return db_lookup(emp_id)

@mcp.resource("schema://employees")
def schema() -> str:
    """Schema of the employees table."""
    return "Id INT, Name NVARCHAR(100), Salary DECIMAL(18,2)"

if __name__ == "__main__":
    mcp.run()            # default transport: stdio

13.5 Connecting MCP

# Local (stdio) server in Claude Code
claude mcp add employee-db -- python server.py

# Remote HTTP server
claude mcp add --transport http github https://api.githubcopilot.com/mcp/

claude mcp list          # connected servers
# Project scope: commit the .mcp.json file to the repo and the whole team gets it
# Remote MCP server straight from the Messages API (MCP connector, beta)
r = client.beta.messages.create(
    model="claude-opus-5-5", max_tokens=4000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[{"type": "url", "url": "https://example.com/mcp", "name": "crm"}],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "crm"}],   # both halves are required
    messages=[{"role": "user", "content": "Show the top 5 open deals"}],
)