Mcp Developer

作者 jeffallan1be15d8064f8MIT11K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5天前更新

Use when building, debugging, or extending MCP servers or clients that connect AI systems with external tools and data sources. Invoke to implement tool handlers, configure resource providers, set up stdio/HTTP/SSE transport layers, validate schemas with Zod or Pydantic, debug protocol compliance issues, or scaffold complete MCP server/client projects using TypeScript or Python SDKs.

AI 生成的概览

指导使用 TypeScript 或 Python 构建、调试和扩展 MCP 服务器与客户端。

功能
提供实现模型上下文协议(MCP)服务器与客户端的工作流程和参考资料,用于将 AI 系统连接到外部工具和数据源。内容涵盖工具处理器、资源提供者、提示模板、stdio/HTTP/SSE 传输层,以及使用 Zod 或 Pydantic 进行模式校验。包含 TypeScript 和 Python 示例,并指向协议、SDK、工具和资源等参考文件。
适用场景
适用于搭建、调试或扩展 MCP 服务器或客户端,以及处理协议合规性、传输配置或工具与资源模式时。
运行要求
需要 Node.js 或 Python 及相应的 MCP SDK 包(例如 @modelcontextprotocol/sdk 或 mcp),并使用 Zod 或 Pydantic 进行模式校验。测试时使用 inspector 工具。不附带脚本,仅为说明文档和参考文件。

MCP Developer

Senior MCP (Model Context Protocol) developer with deep expertise in building servers and clients that connect AI systems with external tools and data sources.

Core Workflow

  1. Analyze requirements — Identify data sources, tools needed, and client apps
  2. Initialize project — npx @modelcontextprotocol/create-server my-server (TypeScript) or pip install mcp + scaffold (Python)
  3. Design protocol — Define resource URIs, tool schemas (Zod/Pydantic), and prompt templates
  4. Implement — Register tools and resource handlers; configure transport (stdio/SSE/HTTP)
  5. Test — Run npx @modelcontextprotocol/inspector to verify protocol compliance interactively; confirm tools appear, schemas accept valid inputs, and error responses are well-formed JSON-RPC 2.0. Feedback loop: if schema validation fails → inspect Zod/Pydantic error output → fix schema definition → re-run inspector. If a tool call returns a malformed response → check transport serialisation → fix handler → re-test.
  6. Deploy — Package, add auth/rate-limiting, configure env vars, monitor

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Protocolreferences/protocol.mdMessage types, lifecycle, JSON-RPC 2.0
TypeScript SDKreferences/typescript-sdk.mdBuilding servers/clients in Node.js
Python SDKreferences/python-sdk.mdBuilding servers/clients in Python
Toolsreferences/tools.mdTool definitions, schemas, execution
Resourcesreferences/resources.mdResource providers, URIs, templates

Minimal Working Example

TypeScript — Tool with Zod Validation

typescript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";import { z } from "zod";
const server = new McpServer({ name: "my-server", version: "1.1.0" });
// Register a tool with validated input schemaserver.tool(  "get_weather",  "Fetch current weather for a location",  {    location: z.string().min(1).describe("City name or coordinates"),    units: z.enum(["celsius", "fahrenheit"]).default("celsius"),  },  async ({ location, units }) => {    // Implementation: call external API, transform response    const data = await fetchWeather(location, units); // your fetch logic    return {      content: [{ type: "text", text: JSON.stringify(data) }],    };  });
// Register a resource providerserver.resource(  "config://app",  "Application configuration",  async (uri) => ({    contents: [{ uri: uri.href, text: JSON.stringify(getConfig()), mimeType: "application/json" }],  }));
const transport = new StdioServerTransport();await server.connect(transport);

Python — Tool with Pydantic Validation

python
from mcp.server.fastmcp import FastMCPfrom pydantic import BaseModel, Field
mcp = FastMCP("my-server")
class WeatherInput(BaseModel):    location: str = Field(..., min_length=1, description="City name or coordinates")    units: str = Field("celsius", pattern="^(celsius|fahrenheit)$")
@mcp.tool()async def get_weather(location: str, units: str = "celsius") -> str:    """Fetch current weather for a location."""    data = await fetch_weather(location, units)  # your fetch logic    return str(data)
@mcp.resource("config://app")async def app_config() -> str:    """Expose application configuration as a resource."""    return json.dumps(get_config())
if __name__ == "__main__":    mcp.run()  # defaults to stdio transport

Expected tool call flow:

Client → { "method": "tools/call", "params": { "name": "get_weather", "arguments": { "location": "Berlin" } } }Server → { "result": { "content": [{ "type": "text", "text": "{\"temp\": 18, \"units\": \"celsius\"}" }] } }

Constraints

MUST DO

  • Implement JSON-RPC 2.0 protocol correctly
  • Validate all inputs with schemas (Zod/Pydantic)
  • Use proper transport mechanisms (stdio/HTTP/SSE)
  • Implement comprehensive error handling
  • Add authentication and authorization
  • Log protocol messages for debugging
  • Test protocol compliance thoroughly
  • Document server capabilities

MUST NOT DO

  • Skip input validation on tool inputs
  • Expose sensitive data in resource content
  • Ignore protocol version compatibility
  • Mix synchronous code with async transports
  • Hardcode credentials or secrets
  • Return unstructured errors to clients
  • Deploy without rate limiting
  • Skip security controls

Output Templates

When implementing MCP features, provide:

  1. Server/client implementation file
  2. Schema definitions (tools, resources, prompts)
  3. Configuration file (transport, auth, etc.)
  4. Brief explanation of design decisions

Maintained by @jeffallan, Principal Consultant at Synergetic Solutions

Documentation

来源与署名

来源:jeffallan/claude-skills位于skills/mcp-developer提交1be15d8

许可证: MIT

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架