MCP (Model Context Protocol) is an open protocol standard introduced by Anthropic that defines standardized communication between AI models and external tools and data sources. MCP is becoming the "USB interface" connecting AI to the real world, enabling large language models to safely and efficiently access various resources and perform operations.

📋 Table of Contents

Key Takeaways

  • Standardized Protocol: MCP defines a unified JSON-RPC 2.0 communication standard, allowing different AI applications to reuse the same toolset
  • Three Primitives: Tools, Resources, and Prompts form the core capabilities of MCP
  • Bidirectional Communication: Supports requests from Client to Server, as well as Server-initiated notifications
  • Security Isolation: Servers run in separate processes with clear permission boundaries to protect system security
  • Thriving Ecosystem: Hundreds of MCP Servers already cover databases, APIs, file systems, and more

Want to quickly discover and use various MCP Servers? Visit our MCP navigation page:

👉 MCP Server Directory

What is MCP Protocol

MCP (Model Context Protocol) is an open communication protocol designed to standardize how AI models interact with the external world. Before MCP, each AI application had to implement its own tool-calling logic, resulting in duplicated effort and compatibility issues.

Why Do We Need MCP?

graph LR subgraph "Before MCP" A1[Claude] -->|Custom| T1[Tool A] A2[GPT] -->|Custom| T2[Tool A'] A3[Gemini] -->|Custom| T3[Tool A''] end subgraph "After MCP" B1[Claude] -->|MCP| T4[MCP Server] B2[GPT] -->|MCP| T4 B3[Gemini] -->|MCP| T4 end
Comparison Traditional Approach MCP Protocol
Tool Reuse Separate implementation for each AI Build once, use everywhere
Protocol Standard Custom definitions Unified JSON-RPC 2.0
Security Model Inconsistent Clear permission boundaries
Ecosystem Fragmented Unified Server ecosystem
Development Cost High Low

Core Value of MCP

  1. Interoperability: The same MCP Server can be used by Claude, Cursor, Windsurf, and other clients
  2. Security: Process isolation and permission control protect user data and system security
  3. Extensibility: Simple protocol design allows developers to quickly build new Servers
  4. Ecosystem Effect: Shared Server ecosystem reduces development costs across the industry

MCP Architecture Explained

MCP uses a client-server architecture with standardized message formats for communication.

Overall Architecture

graph TB subgraph "MCP Host Application" H["Claude Desktop / Cursor / IDE"] C1[MCP Client 1] C2[MCP Client 2] H --> C1 H --> C2 end subgraph "MCP Servers" S1[Filesystem Server] S2[Database Server] S3[API Server] end subgraph "External Resources" R1["(Local Files)"] R2["(PostgreSQL)"] R3[GitHub API] end C1 <-->|stdio/SSE| S1 C2 <-->|stdio/SSE| S2 C2 <-->|stdio/SSE| S3 S1 --> R1 S2 --> R2 S3 --> R3

Communication Flow

sequenceDiagram participant User as User participant Host as MCP Host participant Client as MCP Client participant Server as MCP Server participant Resource as External Resource User->>Host: Send request Host->>Client: Parse intent Client->>Server: initialize Server-->>Client: capabilities Client->>Server: tools/list Server-->>Client: Available tools Client->>Server: tools/call Server->>Resource: Execute operation Resource-->>Server: Return result Server-->>Client: Tool execution result Client-->>Host: Format response Host-->>User: Display result

Core Components Deep Dive

MCP protocol defines three core primitives that form the foundation for AI interaction with the external world.

1. Tools

Tools are the most essential capability of MCP, allowing AI models to perform specific operations.

typescript
interface Tool {
  name: string;
  description: string;
  inputSchema: {
    type: "object";
    properties: Record<string, JSONSchema>;
    required?: string[];
  };
}

interface CallToolResult {
  content: Array<TextContent | ImageContent | EmbeddedResource>;
  isError?: boolean;
}

Tool Examples:

Tool Type Examples Purpose
File Operations read_file, write_file Read/write local files
Database query, execute SQL queries and execution
API Calls http_request Call external APIs
System Commands run_command Execute shell commands
Search web_search Web search

2. Resources

Resources provide structured access to data, similar to GET endpoints in REST APIs.

typescript
interface Resource {
  uri: string;
  name: string;
  description?: string;
  mimeType?: string;
}

interface ReadResourceResult {
  contents: Array<TextResourceContents | BlobResourceContents>;
}

Resource URI Examples:

  • file:///path/to/document.txt - Local file
  • postgres://localhost/mydb/users - Database table
  • github://repo/owner/name/issues - GitHub Issues

3. Prompts

Prompts allow Servers to predefine reusable prompt templates, simplifying common operations.

typescript
interface Prompt {
  name: string;
  description?: string;
  arguments?: Array<{
    name: string;
    description?: string;
    required?: boolean;
  }>;
}

interface GetPromptResult {
  description?: string;
  messages: Array<PromptMessage>;
}

Building MCP Servers

Let's walk through a complete example of developing an MCP Server using TypeScript.

Environment Setup

bash
# Create project
mkdir my-mcp-server && cd my-mcp-server
npm init -y

# Install dependencies
npm install @modelcontextprotocol/sdk zod
npm install -D typescript @types/node

Basic Server Structure

typescript
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";

const server = new Server(
  {
    name: "my-mcp-server",
    version: "1.0.0",
  },
  {
    capabilities: {
      tools: {},
    },
  }
);

server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools: [
      {
        name: "get_weather",
        description: "Get weather information for a specified city",
        inputSchema: {
          type: "object",
          properties: {
            city: {
              type: "string",
              description: "City name",
            },
          },
          required: ["city"],
        },
      },
    ],
  };
});

server.setRequestHandler(CallToolRequestSchema, async (request) => {
  const { name, arguments: args } = request.params;

  if (name === "get_weather") {
    const city = args?.city as string;
    const weather = await fetchWeather(city);
    return {
      content: [
        {
          type: "text",
          text: JSON.stringify(weather, null, 2),
        },
      ],
    };
  }

  throw new Error(`Unknown tool: ${name}`);
});

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
}

main().catch(console.error);

Python Implementation

python
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent

server = Server("my-mcp-server")

@server.list_tools()
async def list_tools() -> list[Tool]:
    return [
        Tool(
            name="get_weather",
            description="Get weather information for a specified city",
            inputSchema={
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string",
                        "description": "City name"
                    }
                },
                "required": ["city"]
            }
        )
    ]

@server.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
    if name == "get_weather":
        city = arguments["city"]
        weather = await fetch_weather(city)
        return [TextContent(type="text", text=str(weather))]
    raise ValueError(f"Unknown tool: {name}")

async def main():
    async with stdio_server() as (read_stream, write_stream):
        await server.run(read_stream, write_stream)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Configuring MCP Server

Configure Server in Claude Desktop (claude_desktop_config.json):

json
{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["/path/to/my-mcp-server/dist/index.js"],
      "env": {
        "API_KEY": "your-api-key"
      }
    }
  }
}
Client Type MCP Support Features
Claude Desktop Desktop App Native Anthropic official, most complete MCP support
Cursor IDE Native AI coding IDE with deep MCP integration
Windsurf IDE Native By Codeium, rich MCP tools
Cline VS Code Extension Native Open source, supports multiple LLMs
Continue IDE Plugin Native Open source, supports VS Code and JetBrains
Zed Editor Native High-performance editor with native MCP

Claude Desktop Configuration Example

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Documents"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxx"
      }
    }
  }
}

Cursor Configuration Example

Add MCP Server in Cursor settings:

json
{
  "mcp.servers": {
    "database": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": {
        "DATABASE_URL": "postgresql://localhost/mydb"
      }
    }
  }
}

MCP Ecosystem and Resources

The MCP ecosystem is rapidly growing, with hundreds of Servers covering various use cases.

Official Servers

Server Function Installation
filesystem File system operations npx @modelcontextprotocol/server-filesystem
github GitHub API npx @modelcontextprotocol/server-github
postgres PostgreSQL npx @modelcontextprotocol/server-postgres
sqlite SQLite database npx @modelcontextprotocol/server-sqlite
puppeteer Browser automation npx @modelcontextprotocol/server-puppeteer
  • Brave Search: Web search capabilities
  • Slack: Slack messages and channel management
  • Google Drive: Google Drive operations
  • Notion: Notion pages and databases
  • Linear: Project management and issue tracking

💡 Discover More MCP Servers: Visit QubitTool MCP Server Directory to browse and search the complete MCP Server list and quickly find tools that meet your needs.

Best Practices and Security

Development Best Practices

  1. Clear Tool Descriptions: Provide clear, detailed descriptions for each tool to help AI select and use them correctly
  2. Input Validation: Use JSON Schema to strictly validate input parameters
  3. Error Handling: Return meaningful error messages to aid debugging
  4. Logging: Record key operations for troubleshooting
typescript
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  try {
    const result = await executeTool(request.params);
    return { content: [{ type: "text", text: JSON.stringify(result) }] };
  } catch (error) {
    console.error(`Tool execution failed: ${error}`);
    return {
      content: [{ type: "text", text: `Error: ${error.message}` }],
      isError: true,
    };
  }
});

Security Considerations

Security Measure Description
Least Privilege Server only requests necessary permissions
Input Filtering Validate and sanitize all user input
Sensitive Data Don't log keys and sensitive information
Process Isolation Server runs in a separate process
Environment Variables Use env vars for keys, never hardcode

FAQ

What's the difference between MCP and Function Calling?

Function Calling is each AI vendor's own implementation of tool calling, with different formats and capabilities. MCP is an open protocol standard that defines a unified communication format, allowing the same Server to be used by multiple AI clients, achieving true interoperability.

How do I debug MCP Servers?

  1. Use the MCP Inspector tool: npx @modelcontextprotocol/inspector
  2. Check the Server's stderr output
  3. Add detailed logging in your code
  4. Use Claude Desktop's developer tools to view communication logs

What transport methods does MCP Server support?

  • stdio: Standard input/output, most common, suitable for local Servers
  • SSE (Server-Sent Events): HTTP long-polling, suitable for remote Servers
  • WebSocket: Bidirectional communication, suitable for real-time push scenarios

How do I publish my MCP Server?

  1. Publish code to npm or PyPI
  2. Submit to the official MCP Server list
  3. Share in communities (GitHub, Discord, etc.)
  4. Submit to QubitTool MCP Directory for more exposure

Conclusion

MCP protocol is becoming essential infrastructure for AI application development. Through standardized communication protocols, MCP enables AI models to interact safely and efficiently with the external world, significantly reducing development costs and promoting ecosystem growth.

Key Takeaways Recap

✅ MCP is a standardized protocol for AI-tool interaction
✅ Three primitives: Tools, Resources, Prompts
✅ TypeScript and Python SDKs for Server development
✅ Major AI clients widely support MCP
✅ Open ecosystem, build once use everywhere

Further Reading


💡 Start Exploring: Visit QubitTool MCP Server Directory to discover MCP tools that meet your needs and accelerate AI application development!