Building Mcp Servers 标志

Building Mcp Servers

社区
andreaswasita
building-mcp-servers

使用官方 SDK 编写 MCP 服务器,并设置门控。

Add to TypingMind

概览

发布者andreaswasita
代码仓库copilot-agents-dojo
技能名称building-mcp-servers
星标数
54
复刻数
15
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 andreaswasita 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Building Mcp Servers AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/andreaswasita/copilot-agents-dojo/tree/main/optional-skills/building-mcp-servers
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/andreaswasita/copilot-agents-dojo.git /tmp/copilot-agents-dojo
mkdir -p .claude/skills
cp -r /tmp/copilot-agents-dojo/optional-skills/building-mcp-servers .claude/skills/building-mcp-servers
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Building Mcp Servers,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Building Mcp Servers。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Building Mcp Servers 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Building MCP Servers Skill

Authors a Model Context Protocol server in TypeScript or Python using the official SDKs (@modelcontextprotocol/sdk, mcp), with deliberate tool/resource/prompt design, both stdio and Streamable HTTP transports, OAuth 2.1 auth, and a test fixture. Does NOT roll its own JSON-RPC framing and does NOT ship without registry + config snippet.

When to Use

  • A required system is not in mcp/registry.yaml.
  • An existing MCP server is too broad; you need a domain-specific facade.
  • User says "build", "write", "author", "create" + "MCP server".
  • Wrapping internal APIs so an agent can call them without bespoke skills.

Prerequisites

  • Node 20+ (TypeScript) or Python 3.11+.
  • The official SDK installed (@modelcontextprotocol/sdk or mcp).
  • An auth strategy decided upfront (CLI inheritance for local, OAuth 2.1 + PKCE for hosted).
  • mcp/registry.yaml and mcp/configs/ writable.
  • @modelcontextprotocol/inspector for handshake debugging.

How to Run

text
1. Pick primitives: tools / resources / prompts. Default to tools.
2. Design tool names (verb_object) and JSON Schema inputs.
3. Scaffold the server with the official SDK + stdio transport.
4. Add Streamable HTTP transport if the server is hosted.
5. Implement auth — CLI inheritance (local) or OAuth 2.1 + PKCE (hosted).
6. Add tests: in-memory transport unit tests + a real stdio smoke test.
7. Register in `mcp/registry.yaml` and add a `mcp/configs/` snippet.

Quick Reference

PrimitiveUse forMental model
toolsSide-effectful or arg'd queriesRPC the agent decides to invoke
resourcesRead-only documents addressable by URIThings the agent or user attaches
promptsPre-baked agent instructionsSlash commands the user invokes
ConcernRule
Tool namingverb_object snake_case (get_my_deals)
Input schemaJSON Schema, required fields marked, description on every property
OutputText content first; structured JSON in a second content block
Loggingstderr only — stdout is reserved for JSON-RPC framing
AuthCLI inheritance (local) or OAuth 2.1 + PKCE (hosted), never tokens in tool args
PaginationEvery list tool has limit (default ≤50) and cursor
IdempotencyMutations accept a client-provided idempotency key
VersioningBump serverInfo.version on schema changes

Procedure

Step 1: Choose Primitives

Default to tools. Use resources only when the data is naturally addressable by URI. Use prompts only when the user invokes them explicitly (slash commands).

Step 2: Design Tool Surface

For each tool:

  • Name: verb_object snake_case.
  • Description: answer "when do I call this?", not "what does it do internally". Lead with the trigger context.
  • Input: JSON Schema with required, every property has a human-readable description.
  • Output: text summary first; machine-readable JSON in a second content block if the agent will chain calls.

Step 3: Stdio Scaffold (TypeScript)

ts
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

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

server.setRequestHandler(/* tools/list */, async () => ({ tools: [...] }));
server.setRequestHandler(/* tools/call */, async (req) => { /* ... */ });

await server.connect(new StdioServerTransport());

Step 4: Streamable HTTP (Hosted)

  • Use StreamableHTTPServerTransport.
  • Mount behind a real auth provider (Entra ID, Auth0, custom OAuth 2.1).
  • Implement /mcp POST + GET (SSE streaming). Do not invent endpoints.
  • Add protected resource metadata so clients can discover the auth server.

Step 5: Stdout Discipline

The single most common failure: a console.log or stray print before the JSON-RPC handshake corrupts the stream. The client silently dies.

  • TypeScript: route logs to console.error.
  • Python: configure logging to sys.stderr, never print.

Step 6: Auth Without Inline Secrets

  • Local dev: inherit from az, gh, kubectl, gcloud.
  • Hosted: OAuth 2.1 + PKCE. Map Authorization: Bearer … to your resource server.
  • Never accept tokens via tool arguments — that places them in the agent's context window and chat history.

Step 7: Tests

  • Unit-test handlers with the SDK's in-memory transport.
  • Smoke test: spawn the server, call tools/list then one representative tools/call.
  • Ship an auth_status tool for diagnostics.
  • Provide a --inspect mode wired to @modelcontextprotocol/inspector.

Step 8: Register and Document

After the server works:

  1. Add an entry to mcp/registry.yaml (transport, scopes, auth model).
  2. Add a config snippet under mcp/configs/.
  3. Cross-link from the relevant consumer skill.

Pitfalls

  • DO NOT log to stdout in a stdio server.
  • DO NOT build a mega-tool with a mode enum that switches behavior. One job per tool.
  • DO NOT write tool descriptions that explain implementation. Lead with the trigger context.
  • DO NOT return unbounded result sets. Every list tool has limit and cursor.
  • DO NOT accept credentials as tool arguments. They will end up in chat history.
  • DO NOT re-implement JSON-RPC framing. Use the SDK.
  • DO NOT ship a server without an auth_status / health tool.

Verification

  • Built with @modelcontextprotocol/sdk (TS) or mcp (Python) — no custom framing.
  • All tools have JSON Schema input with required set and per-property description.
  • Stdout is reserved for JSON-RPC; all logs go to stderr.
  • Auth uses CLI inheritance (local) or OAuth 2.1 + PKCE (hosted).
  • auth_status tool exists.
  • Smoke test covers tools/list and one tools/call over real stdio.
  • Registry entry and mcp/configs/ snippet exist.
  • serverInfo.version set and bumped on every schema change.

常见问题

Building Mcp Servers AI 技能有什么作用?

使用官方 SDK 编写 MCP 服务器,并设置门控。

为什么在 TypingMind 中使用 Building Mcp Servers?

因为您只需安装一次,就能搭配任何模型使用。Building Mcp Servers 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Building Mcp Servers?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/andreaswasita/copilot-agents-dojo/tree/main/optional-skills/building-mcp-servers。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Building Mcp Servers?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Building Mcp Servers 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Building Mcp Servers 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Building Mcp Servers AI 技能免费吗?

是的。andreaswasita 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇