mcp-server-patterns by affaan-m/everything-claude-code
npx skills add https://github.com/affaan-m/everything-claude-code --skill mcp-server-patterns模型上下文协议(MCP)允许 AI 助手调用工具、读取资源并使用来自您服务器的提示。在构建或维护 MCP 服务器时使用此技能。SDK API 会不断演进;请查阅 Context7(查询文档关键词 "MCP")或官方 MCP 文档以获取当前的方法名称和签名。
在以下情况下使用:实现新的 MCP 服务器、添加工具或资源、选择 stdio 与 HTTP、升级 SDK,或调试 MCP 注册和传输问题。
registerTool() 或 tool() 进行注册。registerResource() 或 resource() 进行注册。处理程序通常接收一个 uri 参数。registerPrompt() 或等效方法注册。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Node/TypeScript SDK 可能暴露 tool() / resource() 或 registerTool() / registerResource();官方 SDK 已随时间变化。请务必根据当前的 MCP 文档 或 Context7 进行验证。
对于本地客户端,创建一个 stdio 传输并将其传递给服务器的 connect 方法。确切的 API 因 SDK 版本而异(例如构造函数与工厂函数)。请参阅官方 MCP 文档或在 Context7 中查询 "MCP stdio server" 以获取当前模式。
保持服务器逻辑(工具 + 资源)独立于传输层,以便您可以在入口点中接入 stdio 或 HTTP。
对于 Cursor、云端或其他远程客户端,使用 Streamable HTTP(根据当前规范,每个 MCP HTTP 端点)。仅在需要向后兼容性时支持旧版 HTTP/SSE。
npm install @modelcontextprotocol/sdk zod
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
const server = new McpServer({ name: "my-server", version: "1.0.0" });
使用您的 SDK 版本提供的 API 注册工具和资源:某些版本使用 server.tool(name, description, schema, handler)(位置参数),其他版本使用 server.tool({ name, description, inputSchema }, handler) 或 registerTool()。资源同理——当 API 提供时,在处理程序中包含一个 uri。请查阅官方 MCP 文档或 Context7 以获取当前 @modelcontextprotocol/sdk 的签名,避免复制粘贴错误。
使用 Zod(或 SDK 首选的模式格式)进行输入验证。
@modelcontextprotocol/sdk(npm)。使用 Context7 并指定库名 "MCP" 以获取当前的注册和传输模式。modelcontextprotocol/go-sdk)。每周安装次数
359
代码仓库
GitHub 星标数
105.0K
首次出现
9 天前
安全审计
安装于
codex343
cursor306
gemini-cli303
github-copilot303
amp303
cline303
The Model Context Protocol (MCP) lets AI assistants call tools, read resources, and use prompts from your server. Use this skill when building or maintaining MCP servers. The SDK API evolves; check Context7 (query-docs for "MCP") or the official MCP documentation for current method names and signatures.
Use when: implementing a new MCP server, adding tools or resources, choosing stdio vs HTTP, upgrading the SDK, or debugging MCP registration and transport issues.
registerTool() or tool() depending on SDK version.registerResource() or resource(). Handlers typically receive a uri argument.registerPrompt() or equivalent.The Node/TypeScript SDK may expose tool() / resource() or registerTool() / registerResource(); the official SDK has changed over time. Always verify against the current MCP docs or Context7.
For local clients, create a stdio transport and pass it to your server’s connect method. The exact API varies by SDK version (e.g. constructor vs factory). See the official MCP documentation or query Context7 for "MCP stdio server" for the current pattern.
Keep server logic (tools + resources) independent of transport so you can plug in stdio or HTTP in the entrypoint.
For Cursor, cloud, or other remote clients, use Streamable HTTP (single MCP HTTP endpoint per current spec). Support legacy HTTP/SSE only when backward compatibility is required.
npm install @modelcontextprotocol/sdk zod
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
const server = new McpServer({ name: "my-server", version: "1.0.0" });
Register tools and resources using the API your SDK version provides: some versions use server.tool(name, description, schema, handler) (positional args), others use server.tool({ name, description, inputSchema }, handler) or registerTool(). Same for resources — include a uri in the handler when the API provides it. Check the official MCP docs or Context7 for the current @modelcontextprotocol/sdk signatures to avoid copy-paste errors.
Use Zod (or the SDK’s preferred schema format) for input validation.
@modelcontextprotocol/sdk (npm). Use Context7 with library name "MCP" for current registration and transport patterns.modelcontextprotocol/go-sdk).Weekly Installs
359
Repository
GitHub Stars
105.0K
First Seen
9 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex343
cursor306
gemini-cli303
github-copilot303
amp303
cline303
AI 代码实施计划编写技能 | 自动化开发任务分解与 TDD 流程规划工具
42,300 周安装
Rust调用关系图生成器 - 可视化函数调用层次结构,提升代码分析效率
539 周安装
parallel-web-extract:并行网页内容提取工具,高效抓取网页数据
595 周安装
腾讯云CloudBase AI模型Web技能:前端调用混元/DeepSeek模型,实现流式文本生成
560 周安装
Apollo Connectors 模式助手:GraphQL API 连接器开发与集成指南
565 周安装
GitHub Trending 趋势分析工具:实时发现热门项目、技术洞察与开源机会
556 周安装
GSAP React 集成教程:useGSAP Hook 动画库与 React 组件开发指南
546 周安装