بنقرة واحدة
building-mcp-servers
Authors an MCP server with the official SDK and gates.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Authors an MCP server with the official SDK and gates.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Flags risky shell commands and unsafe tree ops.
Detects high-confidence security risks in code.
Surfaces the dojo's non-negotiable prime directives.
Activates the dojo framework at the start of a session.
Plans multi-step work before writing code.
Captures lessons and promotes recurring patterns.
| name | building-mcp-servers |
| description | Authors an MCP server with the official SDK and gates. |
| tier | optional |
| category | integration |
| created_by | human |
| platforms | ["windows","macos","linux"] |
| tags | ["mcp","sdk","server-authoring"] |
| author | Andreas Wasita (@andreaswasita) |
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.
mcp/registry.yaml.@modelcontextprotocol/sdk or mcp).mcp/registry.yaml and mcp/configs/ writable.@modelcontextprotocol/inspector for handshake debugging.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.
| Primitive | Use for | Mental model |
|---|---|---|
| tools | Side-effectful or arg'd queries | RPC the agent decides to invoke |
| resources | Read-only documents addressable by URI | Things the agent or user attaches |
| prompts | Pre-baked agent instructions | Slash commands the user invokes |
| Concern | Rule |
|---|---|
| Tool naming | verb_object snake_case (get_my_deals) |
| Input schema | JSON Schema, required fields marked, description on every property |
| Output | Text content first; structured JSON in a second content block |
| Logging | stderr only — stdout is reserved for JSON-RPC framing |
| Auth | CLI inheritance (local) or OAuth 2.1 + PKCE (hosted), never tokens in tool args |
| Pagination | Every list tool has limit (default ≤50) and cursor |
| Idempotency | Mutations accept a client-provided idempotency key |
| Versioning | Bump serverInfo.version on schema changes |
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).
For each tool:
verb_object snake_case.required, every property has a human-readable description.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());
StreamableHTTPServerTransport./mcp POST + GET (SSE streaming). Do not invent endpoints.The single most common failure: a console.log or stray print before the JSON-RPC handshake corrupts the stream. The client silently dies.
console.error.logging to sys.stderr, never print.az, gh, kubectl, gcloud.Authorization: Bearer … to your resource server.tools/list then one representative tools/call.auth_status tool for diagnostics.--inspect mode wired to @modelcontextprotocol/inspector.After the server works:
mcp/registry.yaml (transport, scopes, auth model).mcp/configs/.mode enum that switches behavior. One job per tool.limit and cursor.auth_status / health tool.@modelcontextprotocol/sdk (TS) or mcp (Python) — no custom framing.required set and per-property description.auth_status tool exists.tools/list and one tools/call over real stdio.mcp/configs/ snippet exist.serverInfo.version set and bumped on every schema change.