{"id":"5650a825-376b-4ce1-a114-b47e158d0aa5","shortId":"uCfF27","kind":"skill","title":"mcp-best-practices","tagline":"Build production MCP servers with the TypeScript SDK. Covers spec 2025-11-25, SDK v1.28+/v2, transport selection, tool design, error handling, security, performance, known bugs with workarounds, MCP extensions, MCP Apps (interactive UIs), authorization extensions, and the MCP Reg","description":"# MCP Best Practices\n\nDecision reference for building production MCP servers with the TypeScript SDK. Not a tutorial - assumes you already have a working server and need to make it correct, fast, and secure.\n\n## Quick Reference\n\n| Component | Current | Next |\n|-----------|---------|------|\n| Spec | **2025-11-25** ([spec.modelcontextprotocol.io](https://spec.modelcontextprotocol.io)) | - |\n| TS SDK (stable) | **v1.28.0** (`@modelcontextprotocol/sdk`) | v2 pre-alpha on `main` |\n| TS SDK (v2) | Pre-alpha (`@modelcontextprotocol/server`, `/client`, `/core`) | Q1 2026 stable |\n| JSON Schema | **2020-12** default (explicit `$schema` supported) | - |\n| Transport | **Streamable HTTP** (remote), **stdio** (local) | SSE removed in v2 |\n| Extensions | **MCP Apps** (GA), **Auth Extensions** (official) | Domain-specific WGs |\n| Registry | **Preview** ([registry](https://modelcontextprotocol.io/registry/about)) | GA pending |\n\n**v1 imports** (production today):\n```typescript\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { WebStandardStreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n```\n\n**v2 imports** (when stable):\n```typescript\nimport { McpServer } from \"@modelcontextprotocol/server\";\nimport { WebStandardStreamableHTTPServerTransport } from \"@modelcontextprotocol/server\";\n```\n\n## Server Setup\n\n### Transport Decision\n\n| Scenario | Transport | Key Config |\n|----------|-----------|------------|\n| Remote, stateless (K8s, CF Workers) | `WebStandardStreamableHTTPServerTransport` | `sessionIdGenerator: undefined`, `enableJsonResponse: true` |\n| Remote, stateful (long tasks, SSE) | `WebStandardStreamableHTTPServerTransport` | `sessionIdGenerator: () => randomUUID()` |\n| Local CLI / Claude Desktop | `StdioServerTransport` | Default |\n| Legacy SSE clients | SSE removed in v2 - migrate to Streamable HTTP | - |\n\n### Stateless Pattern (recommended for remote deployment)\n\nPer-request server+transport creation is the canonical pattern. Maintainer @ihrpr confirms: \"each transport should have an instance of MCPServer\" ([#343](https://github.com/modelcontextprotocol/typescript-sdk/issues/343)). Sharing instances leaks cross-client data (GHSA-345p-7cg4-v4c7).\n\n```typescript\napp.post(\"/mcp\", async (c) => {\n  const server = new McpServer({ name: \"my-server\", version: \"1.0.0\" });\n  // Register tools, resources, prompts...\n  registerTools(server);\n\n  const transport = new WebStandardStreamableHTTPServerTransport({\n    sessionIdGenerator: undefined,   // stateless - no session tracking\n    enableJsonResponse: true,        // JSON responses, no SSE streaming\n  });\n\n  // All tools/resources must be registered before connect() (#893)\n  try {\n    await server.connect(transport);\n    return transport.handleRequest(c.req.raw);\n  } finally {\n    await transport.close();\n    await server.close();\n  }\n});\n```\n\n**What to hoist to module level** (don't recreate per request):\n- Zod schemas (they never change)\n- Annotation objects (`{ readOnlyHint: true, ... }`)\n- Tool description strings\n- Payment configs, upstream API clients\n\nThe McpServer itself must be per-request, but its constant inputs should not be.\n\n> For deep dive on transports, sessions, HTTP/2 gotchas, and K8s deployment: see `references/transport-patterns.md`\n\n### Framework Integration\n\n**Hono** (web-standard):\n```typescript\nimport { Hono } from \"hono\";\nconst app = new Hono();\napp.post(\"/mcp\", handleMcpRequest);  // WebStandardStreamableHTTPServerTransport\napp.get(\"/mcp\", handleMcpSse);       // Optional: SSE for server notifications\napp.delete(\"/mcp\", handleMcpDelete); // Optional: session termination\n```\n\n**Cloudflare Workers**: Same pattern - `WebStandardStreamableHTTPServerTransport` works natively in Workers runtime.\n\n**Express/Node** (v2): Use `@modelcontextprotocol/express` middleware with `NodeStreamableHTTPServerTransport` (wraps the Web Standard transport for `IncomingMessage`/`ServerResponse`).\n\n## Tool Design\n\n### Registration API\n\n**v1 (current stable)** - `server.tool()` works but has ambiguous overloads. Prefer the config-object form when possible:\n```typescript\nserver.tool(\"search_docs\", \"Search documents\", {\n  query: z.string().describe(\"Search query\"),\n  max_results: z.number().optional().describe(\"Max results (default 20)\"),\n}, { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },\n  async ({ query, max_results }) => { /* handler */ }\n);\n```\n\n**v2 (migration target)** - `registerTool()` with config object:\n```typescript\nserver.registerTool(\"search_docs\", {\n  title: \"Document Search\",\n  description: \"Search documents by keyword or phrase\",\n  inputSchema: z.object({\n    query: z.string().describe(\"Search query\"),\n    max_results: z.number().optional().describe(\"Max results (default 20)\"),\n  }),\n  outputSchema: z.object({\n    results: z.array(z.object({ id: z.string(), text: z.string() })),\n    has_more: z.boolean(),\n  }),\n  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },\n}, async ({ query, max_results }) => {\n  const result = await fetchDocs(query, max_results);\n  return {\n    structuredContent: result,\n    content: [{ type: \"text\", text: JSON.stringify(result) }],\n  };\n});\n```\n\n### Naming\n\nSpec (2025-11-25): 1-128 chars, case-sensitive. Allowed: `A-Za-z0-9_-.`\n\n**DO**: `search_docs`, `get_user_profile`, `admin.tools.list`\n**DON'T**: `search` (too generic, collides across servers), `Search Docs` (spaces not allowed)\n\nService-prefix your tools (`github_*`, `jira_*`) when multiple servers are active - LLMs confuse generic names across servers.\n\n### Schema Rules\n\n`.describe()` on every field - this is what LLMs use for argument generation.\n\n> For complete Zod-to-JSON-Schema conversion rules, what breaks silently, outputSchema/structuredContent patterns: see `references/tool-schema-guide.md`\n\n**Critical bugs**:\n- `z.union()` / `z.discriminatedUnion()` silently produce empty schemas ([#1643](https://github.com/modelcontextprotocol/typescript-sdk/issues/1643)). Use flat `z.object()` with `z.enum()` discriminator field instead.\n- Plain JSON Schema objects silently dropped before v1.28.0. Fixed in v1.28 - now throws at registration ([#1596](https://github.com/modelcontextprotocol/typescript-sdk/issues/1596)).\n- `z.transform()` stripped during conversion - JSON Schema can't represent transforms ([#702](https://github.com/modelcontextprotocol/typescript-sdk/issues/702)).\n\n### Annotations\n\nAll are optional hints (untrusted from untrusted servers per spec):\n\n| Annotation | Default | Meaning |\n|------------|---------|---------|\n| `readOnlyHint` | `false` | Tool doesn't modify its environment |\n| `destructiveHint` | `true` | May perform destructive updates (only when readOnly=false) |\n| `idempotentHint` | `false` | Repeated calls with same args have no additional effect |\n| `openWorldHint` | `true` | Interacts with external entities (APIs, web) |\n\nSet them accurately - clients use them for consent prompts and auto-approval decisions.\n\n**Open SEPs expanding annotations**:\n- `#1913` Trust and Sensitivity - data classification hints\n- `#1984` Comprehensive annotations for governance/UX\n- `#1561` `unsafeOutputHint` - output may contain untrusted content\n- `#1560` `secretHint` - tool handles secrets/credentials\n- `#1487` `trustedHint` - server attestation of tool trustworthiness\n\n**The \"Lethal Trifecta\"**: Combining (1) access to private data + (2) exposure to untrusted content + (3) external communication ability creates data theft conditions. Researchers demonstrated this with a malicious calendar event, an MCP calendar server, and a code execution tool. Design tool sets to avoid granting all three simultaneously.\n\n**Evaluation framework for new annotation proposals**:\n1. What client behavior changes? (No concrete action = don't add it)\n2. Does it require trust to be useful? (If yes, doesn't help against untrusted servers)\n3. Could `_meta` handle it? (Namespaced metadata better for single-deployment needs)\n4. Does it help reason about tool combinations?\n5. Is it a hint or contract? (Contracts belong in auth/transport/runtime layer)\n\n## Error Handling\n\nTwo distinct mechanisms with different LLM visibility:\n\n| Type | LLM Sees It? | Use For |\n|------|--------------|---------|\n| **Tool error** (`isError: true` in CallToolResult) | Yes - enables self-correction | Input validation, API failures, business logic errors |\n| **Protocol error** (JSON-RPC error response) | Maybe - clients MAY expose | Unknown tool, malformed request, server crash |\n\nPer SEP-1303 (merged into spec 2025-11-25): input validation errors MUST be tool execution errors, not protocol errors. The LLM needs to see \"date must be in the future\" to self-correct.\n\n```typescript\n// DO: Tool execution error - LLM can self-correct\nreturn {\n  isError: true,\n  content: [{ type: \"text\", text: \"Date must be in the future. Current date: 2026-03-25\" }],\n};\n\n// DON'T: Protocol error for validation - LLM can't see this\nthrow new McpError(ErrorCode.InvalidParams, \"Invalid date\");\n```\n\n**Known bug**: The SDK loses `error.data` when converting `McpError` to tool results ([PR #1075](https://github.com/modelcontextprotocol/typescript-sdk/pull/1075)). If you embed structured data in McpError's data field, it may not reach the client. Use `isError: true` tool results with structured content instead.\n\n> For full error taxonomy, code examples, and payment error patterns: see `references/error-handling.md`\n\n## Resources and Instructions\n\n### Server Instructions\n\nSet in the initialization response - acts as a system-level hint to the LLM about how to use your server:\n\n```typescript\nconst server = new McpServer({\n  name: \"docs-api\",\n  version: \"1.0.0\",\n  instructions: \"Knowledge base API. Use search_docs for full-text search, get_doc for retrieval by ID. All tools are read-only.\",\n});\n```\n\n### Resource Registration\n\nExpose documentation or structured data via `docs://` URI scheme:\n\n```typescript\nserver.resource(\"search-operators\", \"docs://search-operators\", {\n  title: \"Search Operators Guide\",\n  description: \"Supported search operators and syntax\",\n  mimeType: \"text/markdown\",\n}, async () => ({\n  contents: [{ uri: \"docs://search-operators\", text: operatorsMarkdown }],\n}));\n```\n\n## Performance\n\n### Module-Level Caching\n\nThe McpServer must be per-request, but everything else can be shared:\n\n```typescript\n// Module-level (created once)\nconst SCHEMAS = {\n  search: z.object({ query: z.string().describe(\"Search query\") }),\n  fetch: z.object({ id: z.string().describe(\"Resource ID\") }),\n};\nconst READ_ONLY_ANNOTATIONS = {\n  readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true,\n} as const;\n\n// Per-request (created each time)\nfunction createMcpServer(ctx: Context) {\n  const server = new McpServer({ name: \"my-server\", version: \"1.0.0\" });\n  server.tool(\"search\", \"Search\", SCHEMAS.search, READ_ONLY_ANNOTATIONS, handler);\n  return server;\n}\n```\n\n### Token Bloat Mitigation\n\nTool definitions consume context window before any conversation starts. GitHub MCP: 20,444 tokens for 80 tools (SEP-1576).\n\n**Strategies**:\n1. **5-15 tools per server** - community sweet spot. Split beyond that.\n2. **Outcome-oriented tools** - bundle multi-step operations into single tools (e.g., `track_order(email)` not `get_user` + `list_orders` + `get_status`).\n3. **Response granularity** - return curated results, not raw API dumps. 800-token user object vs 20-token summary.\n4. **`outputSchema` + `structuredContent`** - lets clients process data programmatically without LLM parsing overhead.\n5. **Dynamic tool loading** - register only relevant tool subsets based on request context (e.g., `?tools=search,fetch` query parameter).\n\n### No-Parameter Tools\n\nFor tools with no inputs, use explicit empty schema:\n```typescript\ninputSchema: { type: \"object\" as const, additionalProperties: false }\n```\n\n## Security\n\n### Top Threats (real-world incidents, 2025)\n\n| Attack | Example | Mitigation |\n|--------|---------|------------|\n| **Tool poisoning** | Hidden instructions in descriptions (WhatsApp MCP, Apr 2025) | Review tool descriptions; clients should display them |\n| **Supply chain** | Malicious npm packages (Smithery breach, Oct 2025) | Pin versions, audit dependencies |\n| **Command injection** | `child_process.exec` with unsanitized input (CVE-2025-53967) | Never interpolate user input into shell commands |\n| **Cross-server shadowing** | Malicious server overrides legitimate tool names | Service-prefix tool names; validate tool sources |\n| **Token theft** | Over-privileged PATs with broad scopes | Minimal scopes; OAuth 2.1 Resource Indicators (RFC 8707) |\n| **Token passthrough** | Server accepts/forwards tokens not issued for it | Validate audience claim; never transit client tokens to upstream APIs |\n| **SSRF** | Malicious OAuth metadata URLs targeting internal services | HTTPS enforcement, block private IPs, validate redirect targets |\n| **Confused deputy** | Proxy server consent cookies exploited via DCR | Per-client consent before forwarding to third-party auth |\n| **Session hijacking** | Stolen/guessed session IDs for impersonation | Cryptographically random IDs, bind to user identity, never use for auth |\n\n### Server-Side Requirements (spec normative)\n\n- **Validate all inputs** at tool boundaries\n- **Implement access controls** per user/session\n- **Rate limit** tool invocations\n- **Sanitize outputs** before returning to client\n- **Validate `Origin` header** - respond 403 for invalid origins (2025-11-25 requirement)\n- **Require `MCP-Protocol-Version` header** on all requests after initialization (spec 2025-06-18+)\n- **Bind local servers to localhost** (127.0.0.1) only\n\n### Auth (OAuth 2.1)\n\nMCP normatively requires **OAuth 2.1** ([draft-ietf-oauth-v2-1-13](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13)). The spec states: \"Authorization servers MUST implement OAuth 2.1.\" PKCE is mandatory, implicit flow is removed. Always build against OAuth 2.1 - not 2.0.\n\nMCP servers are OAuth 2.1 Resource Servers. Clients MUST include Resource Indicators (RFC 8707) binding tokens to specific servers. Key requirements:\n\n- **Validate audience** - reject tokens not issued for your server (token passthrough is explicitly forbidden)\n- **PKCE mandatory** - use `S256` code challenge method\n- **Short-lived tokens** - reduce blast radius of leaked credentials\n- **Scope minimization** - start with minimal scopes, elevate incrementally via `WWW-Authenticate` challenges\n- **Don't implement token validation yourself** - use tested libraries (Keycloak, Auth0, etc.)\n- **Don't log credentials** - never log Authorization headers, tokens, or secrets\n\n> For full security attack/mitigation patterns and auth implementation details: see `references/security-auth.md`\n\n## Known SDK Bugs\n\n| Issue | Severity | Status | Workaround |\n|-------|----------|--------|------------|\n| [#1643](https://github.com/modelcontextprotocol/typescript-sdk/issues/1643) - `z.union()`/`z.discriminatedUnion()` silently dropped | High | Open | Use flat `z.object()` + `z.enum()` |\n| [#1699](https://github.com/modelcontextprotocol/typescript-sdk/issues/1699) - Transport closure stack overflow (15-25+ concurrent) | High | Open | `uncaughtException` handler + process restart |\n| [#1619](https://github.com/modelcontextprotocol/typescript-sdk/issues/1619) - HTTP/2 + SSE Content-Length error | Medium | Open | Use `enableJsonResponse: true` or avoid HTTP/2 upstream |\n| [#893](https://github.com/modelcontextprotocol/typescript-sdk/issues/893) - Dynamic registration after connect blocked | Medium | Open | Register all tools/resources before `connect()` |\n| [#1596](https://github.com/modelcontextprotocol/typescript-sdk/issues/1596) - Plain JSON Schema silently dropped | Fixed | v1.28.0 | Upgrade to v1.28+ |\n| GHSA-345p-7cg4-v4c7 - Shared instances leak cross-client data | Critical | v1.26.0 | Per-request server+transport (the canonical pattern) |\n\n## V2 Migration\n\n> For comprehensive migration guide with all breaking changes and before/after code: see `references/v2-migration.md`\n\n**Key breaking changes**:\n1. Package split: `@modelcontextprotocol/sdk` -> `@modelcontextprotocol/server` + `/client` + `/core`\n2. ESM only, Node.js 20+\n3. Zod v4 required (or any Standard Schema library)\n4. `McpError` -> `ProtocolError` (from `@modelcontextprotocol/core`)\n5. `extra` parameter -> structured `ctx` with `ctx.mcpReq`\n6. `server.tool()` -> `registerTool()` (config object, not positional args)\n7. SSE server transport removed (clients can still connect to legacy SSE servers)\n8. `@modelcontextprotocol/hono` and `@modelcontextprotocol/express` middleware packages\n9. DNS rebinding protection enabled by default for localhost servers\n\nv1.x gets 6 more months of support after v2 stable ships. No rush, but write new code with v2 patterns in mind.\n\n## Extensions\n\nMCP extensions are optional, strictly additive capabilities on top of the core protocol. Both sides negotiate support during initialization via `extensions` in capabilities.\n\n**Identifiers**: `{vendor-prefix}/{extension-name}`. Official: `io.modelcontextprotocol/*`. Third-party: reversed domain (e.g., `com.example/my-ext`).\n\n### Official Extensions\n\n| Extension | Identifier | Purpose |\n|-----------|-----------|---------|\n| **MCP Apps** | `io.modelcontextprotocol/ui` | Interactive HTML UIs in chat (charts, forms, dashboards) |\n| **OAuth Client Credentials** | `io.modelcontextprotocol/oauth-client-credentials` | Machine-to-machine auth (CI/CD, daemons, server-to-server) |\n| **Enterprise-Managed Auth** | `io.modelcontextprotocol/enterprise-managed-authorization` | Centralized access control via enterprise IdP |\n\n**Client support**: Claude (web + Desktop), ChatGPT, VS Code Copilot, Goose, Postman, MCPJam all support MCP Apps. Auth extensions not yet widely adopted.\n\n> For MCP Apps architecture, ext-apps SDK, and build patterns: see `references/mcp-apps.md`\n> For extensions system, auth extensions, and MCP Registry: see `references/extensions-registry.md`\n\n### Server Capabilities Beyond Tools\n\n| Capability | Purpose | v2 API |\n|-----------|---------|--------|\n| **Elicitation** | Request structured user input mid-tool | `ctx.mcpReq.elicitInput()` |\n| **Sampling** | Request LLM completion from client | `ctx.mcpReq.requestSampling()` |\n| **Tasks** (SEP-1686) | Long-running ops with lifecycle management | Pending |\n| **Progress** | Incremental progress on requests | `ctx.mcpReq.sendProgress()` |","tags":["mcp","best","practices","skills","tenequm","agent-skills","ai-agents","claude-code","claude-skills","clawhub","erc-8004","mpp"],"capabilities":["skill","source-tenequm","skill-mcp-best-practices","topic-agent-skills","topic-ai-agents","topic-claude-code","topic-claude-skills","topic-clawhub","topic-erc-8004","topic-mpp","topic-openclaw","topic-skills","topic-solana","topic-x402"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/tenequm/skills/mcp-best-practices","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add tenequm/skills","source_repo":"https://github.com/tenequm/skills","install_from":"skills.sh"}},"qualityScore":"0.461","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 23 github stars · SKILL.md body (18,616 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T01:01:39.801Z","embedding":null,"createdAt":"2026-04-18T23:05:17.965Z","updatedAt":"2026-04-22T01:01:39.801Z","lastSeenAt":"2026-04-22T01:01:39.801Z","tsv":"'-03':1033 '-06':1635 '-11':16,85,572,979,1619 '-12':115 '-128':575 '-13':1658 '-1303':974 '-15':1314 '-1576':1310 '-1686':2166 '-18':1636 '-2025':1466 '-25':17,86,573,980,1034,1620,1814 '-53967':1467 '/*':2037 '/client':107,1916 '/core':108,1917 '/doc/html/draft-ietf-oauth-v2-1-13)).':1661 '/enterprise-managed-authorization':2088 '/mcp':267,395,399,407 '/modelcontextprotocol/typescript-sdk/issues/1596)':1860 '/modelcontextprotocol/typescript-sdk/issues/1596)).':692 '/modelcontextprotocol/typescript-sdk/issues/1619)':1825 '/modelcontextprotocol/typescript-sdk/issues/1643)':1794 '/modelcontextprotocol/typescript-sdk/issues/1643)).':665 '/modelcontextprotocol/typescript-sdk/issues/1699)':1808 '/modelcontextprotocol/typescript-sdk/issues/343)).':252 '/modelcontextprotocol/typescript-sdk/issues/702)).':706 '/modelcontextprotocol/typescript-sdk/issues/893)':1844 '/modelcontextprotocol/typescript-sdk/pull/1075)).':1068 '/my-ext':2046 '/oauth-client-credentials':2070 '/registry/about))':146 '/ui':2056 '/v2':20 '1':574,811,861,1312,1657,1911 '1.0.0':279,1142,1278 '1075':1065 '127.0.0.1':1642 '1487':800 '15':1813 '1560':795 '1561':788 '1596':689,1857 '1619':1822 '1643':662,1791 '1699':1805 '1913':776 '1984':783 '2':816,873,1324,1918 '2.0':1684 '2.1':1505,1646,1651,1670,1682,1689 '20':477,527,1303,1363,1922 '2020':114 '2025':15,84,571,978,1425,1438,1454,1618,1634 '2026':110,1032 '3':821,889,1348,1923 '343':249 '345p':262,1873 '4':902,1366,1932 '403':1614 '444':1304 '5':910,1313,1378,1937 '6':1944,1983 '7':1952 '702':703 '7cg4':263,1874 '8':1965 '80':1307 '800':1358 '8707':1509,1698 '893':310,1841 '9':585,1971 'a-za-z0':581 'abil':824 'accepts/forwards':1513 'access':812,1596,2090 'accur':760 'across':599,622 'act':1116 'action':868 'activ':617 'add':871 'addit':748,2009 'additionalproperti':1416 'admin.tools.list':592 'adopt':2116 'allow':580,605 'alpha':97,105 'alreadi':64 'alway':1678 'ambigu':448 'annot':339,540,707,718,775,785,859,1248,1285 'api':349,440,756,950,1140,1146,1356,1528,2147 'app':36,132,391,2053,2110,2119,2123 'app.delete':406 'app.get':398 'app.post':266,394 'approv':770 'apr':1437 'architectur':2120 'arg':745,1951 'argument':636 'assum':62 'async':268,486,549,1197 'attack':1426 'attack/mitigation':1776 'attest':803 'audienc':1520,1707 'audit':1457 'auth':134,1564,1582,1644,1779,2075,2085,2111,2133 'auth/transport/runtime':920 'auth0':1760 'authent':1748 'author':39,1665,1768 'auto':769 'auto-approv':768 'avoid':850,1838 'await':312,319,321,555 'base':1145,1387 'before/after':1904 'behavior':864 'belong':918 'best':3,46 'better':896 'beyond':1322,2142 'bind':1575,1637,1699 'blast':1732 'bloat':1290 'block':1539,1849 'boundari':1594 'breach':1452 'break':648,1901,1909 'broad':1500 'bug':30,655,1053,1786 'build':5,51,1679,2126 'bundl':1329 'busi':952 'c':269 'c.req.raw':317 'cach':1209 'calendar':835,839 'call':742 'calltoolresult':942 'canon':236,1891 'capabl':2010,2026,2141,2144 'case':578 'case-sensit':577 'central':2089 'cf':190 'chain':1447 'challeng':1725,1749 'chang':338,865,1902,1910 'char':576 'chart':2062 'chat':2061 'chatgpt':2100 'child_process.exec':1461 'ci/cd':2076 'claim':1521 'classif':781 'claud':207,2097 'cli':206 'client':213,258,350,761,863,963,1084,1370,1442,1524,1556,1609,1692,1881,1957,2066,2095,2162 'closur':1810 'cloudflar':412 'code':843,1098,1724,1905,1997,2102 'collid':598 'com.example':2045 'com.example/my-ext':2044 'combin':810,909 'command':1459,1474 'communic':823 'communiti':1318 'complet':639,2160 'compon':80 'comprehens':784,1896 'concret':867 'concurr':1815 'condit':828 'config':186,347,453,496,1947 'config-object':452 'confirm':240 'confus':619,1545 'connect':309,1848,1856,1960 'consent':765,1549,1557 'const':270,286,390,553,1133,1229,1245,1258,1269,1415 'constant':361 'consum':1294 'contain':792 'content':563,794,820,1020,1092,1198,1829 'content-length':1828 'context':1268,1295,1390 'contract':916,917 'control':1597,2091 'convers':645,696,1299 'convert':1059 'cooki':1550 'copilot':2103 'core':2015 'correct':74,947,1006,1016 'could':890 'cover':13 'crash':971 'creat':825,1227,1262 'createmcpserv':1266 'creation':233 'credenti':1736,1765,2067 'critic':654,1883 'cross':257,1476,1880 'cross-client':256,1879 'cross-serv':1475 'cryptograph':1572 'ctx':1267,1941 'ctx.mcpreq':1943 'ctx.mcpreq.elicitinput':2156 'ctx.mcpreq.requestsampling':2163 'ctx.mcpreq.sendprogress':2180 'curat':1352 'current':81,442,1030 'cve':1465 'daemon':2077 'dashboard':2064 'data':259,780,815,826,1073,1077,1173,1372,1882 'datatracker.ietf.org':1660 'datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-13)).':1659 'date':997,1024,1031,1051 'dcr':1553 'decis':48,182,771 'deep':367 'default':116,210,476,526,719,1977 'definit':1293 'demonstr':830 'depend':1458 'deploy':227,376,900 'deputi':1546 'describ':466,473,516,523,626,1235,1242 'descript':344,505,1189,1434,1441 'design':24,438,846 'desktop':208,2099 'destruct':733 'destructivehint':480,543,729,1251 'detail':1781 'differ':928 'discrimin':671 'display':1444 'distinct':925 'dive':368 'dns':1972 'doc':461,501,588,602,1139,1149,1156 'docs-api':1138 'document':463,503,507,1170 'doesn':724,883 'domain':138,2042 'domain-specif':137 'draft':1653 'draft-ietf-oauth-v2':1652 'drop':679,1798,1865 'dump':1357 'dynam':1379,1845 'e.g':1337,1391,2043 'effect':749 'elev':1743 'elicit':2148 'els':1219 'email':1340 'emb':1071 'empti':660,1408 'enabl':944,1975 'enablejsonrespons':195,296,1835 'enforc':1538 'enterpris':2083,2093 'enterprise-manag':2082 'entiti':755 'environ':728 'error':25,922,938,954,956,960,983,988,991,1011,1038,1096,1102,1831 'error.data':1057 'errorcode.invalidparams':1049 'esm':1919 'etc':1761 'evalu':855 'event':836 'everi':628 'everyth':1218 'exampl':1099,1427 'execut':844,987,1010 'expand':774 'explicit':117,1407,1718 'exploit':1551 'expos':965,1169 'exposur':817 'express/node':422 'ext':2122 'ext-app':2121 'extens':34,40,130,135,2003,2005,2024,2032,2048,2049,2112,2131,2134 'extension-nam':2031 'extern':754,822 'extra':1938 'failur':951 'fals':481,544,722,738,740,1252,1417 'fast':75 'fetch':1238,1394 'fetchdoc':556 'field':629,672,1078 'final':318 'fix':682,1866 'flat':667,1802 'flow':1675 'forbidden':1719 'form':455,2063 'forward':1559 'framework':379,856 'full':1095,1152,1774 'full-text':1151 'function':1265 'futur':1002,1029 'ga':133,147 'generat':637 'generic':597,620 'get':589,1155,1342,1346,1982 'ghsa':261,1872 'ghsa-345p-7cg4-v4c7':260,1871 'github':611,1301 'github.com':251,664,691,705,1067,1793,1807,1824,1843,1859 'github.com/modelcontextprotocol/typescript-sdk/issues/1596)':1858 'github.com/modelcontextprotocol/typescript-sdk/issues/1596)).':690 'github.com/modelcontextprotocol/typescript-sdk/issues/1619)':1823 'github.com/modelcontextprotocol/typescript-sdk/issues/1643)':1792 'github.com/modelcontextprotocol/typescript-sdk/issues/1643)).':663 'github.com/modelcontextprotocol/typescript-sdk/issues/1699)':1806 'github.com/modelcontextprotocol/typescript-sdk/issues/343)).':250 'github.com/modelcontextprotocol/typescript-sdk/issues/702)).':704 'github.com/modelcontextprotocol/typescript-sdk/issues/893)':1842 'github.com/modelcontextprotocol/typescript-sdk/pull/1075)).':1066 'goos':2104 'gotcha':373 'governance/ux':787 'grant':851 'granular':1350 'guid':1188,1898 'handl':26,798,892,923 'handlemcpdelet':408 'handlemcprequest':396 'handlemcpss':400 'handler':490,1286,1819 'header':1612,1627,1769 'help':885,905 'hidden':1431 'high':1799,1816 'hijack':1566 'hint':711,782,914,1122 'hoist':325 'hono':381,387,389,393 'html':2058 'http':122,221 'http/2':372,1826,1839 'https':1537 'id':533,1160,1240,1244,1569,1574 'idempotenthint':482,545,739,1253 'ident':1578 'identifi':2027,2050 'idp':2094 'ietf':1654 'ihrpr':239 'imperson':1571 'implement':1595,1668,1752,1780 'implicit':1674 'import':150,154,158,162,167,171,175,386 'incid':1424 'includ':1694 'incomingmessag':435 'increment':1744,2176 'indic':1507,1696 'initi':1114,1632,2022 'inject':1460 'input':362,948,981,1405,1464,1471,1591,2152 'inputschema':512,1411 'instanc':246,254,1877 'instead':673,1093 'instruct':1108,1110,1143,1432 'integr':380 'interact':37,752,2057 'intern':1535 'interpol':1469 'invalid':1050,1616 'invoc':1603 'io.modelcontextprotocol':2036,2055,2069,2087 'io.modelcontextprotocol/*':2035 'io.modelcontextprotocol/enterprise-managed-authorization':2086 'io.modelcontextprotocol/oauth-client-credentials':2068 'io.modelcontextprotocol/ui':2054 'ip':1541 'iserror':939,1018,1086 'issu':1516,1711,1787 'jira':612 'json':112,298,643,675,697,958,1862 'json-rpc':957 'json.stringify':567 'k8s':189,375 'key':185,1704,1908 'keycloak':1759 'keyword':509 'knowledg':1144 'known':29,1052,1784 'layer':921 'leak':255,1735,1878 'legaci':211,1962 'legitim':1482 'length':1830 'let':1369 'lethal':808 'level':328,1121,1208,1226 'librari':1758,1931 'lifecycl':2172 'limit':1601 'list':1344 'live':1729 'llm':929,932,993,1012,1041,1125,1375,2159 'llms':618,633 'load':1381 'local':125,205,1638 'localhost':1641,1979 'log':1764,1767 'logic':953 'long':199,2168 'long-run':2167 'lose':1056 'machin':2072,2074 'machine-to-machin':2071 'main':99 'maintain':238 'make':72 'malform':968 'malici':834,1448,1479,1530 'manag':2084,2173 'mandatori':1673,1721 'max':469,474,488,519,524,551,558 'may':731,791,964,1080 'mayb':962 'mcp':2,7,33,35,43,45,53,131,838,1302,1436,1624,1647,1685,2004,2052,2109,2118,2136 'mcp-best-practic':1 'mcp-protocol-vers':1623 'mcperror':1048,1060,1075,1933 'mcpjam':2106 'mcpserver':155,172,248,273,352,1136,1211,1272 'mean':720 'mechan':926 'medium':1832,1850 'merg':975 'meta':891 'metadata':895,1532 'method':1726 'mid':2154 'mid-tool':2153 'middlewar':426,1969 'migrat':218,492,1894,1897 'mimetyp':1195 'mind':2002 'minim':1502,1738,1741 'mitig':1291,1428 'modelcontextprotocol.io':145 'modelcontextprotocol.io/registry/about))':144 'modelcontextprotocol/core':1936 'modelcontextprotocol/express':425,1968 'modelcontextprotocol/hono':1966 'modelcontextprotocol/sdk':93,1914 'modelcontextprotocol/sdk/server/mcp.js':157 'modelcontextprotocol/sdk/server/stdio.js':165 'modelcontextprotocol/sdk/server/webstandardstreamablehttp.js':161 'modelcontextprotocol/server':106,174,178,1915 'modifi':726 'modul':327,1207,1225 'module-level':1206,1224 'month':1985 'multi':1331 'multi-step':1330 'multipl':614 'must':305,354,984,998,1025,1212,1667,1693 'my-serv':275,1274 'name':274,569,621,1137,1273,1484,1489,2033 'namespac':894 'nativ':418 'need':70,901,994 'negoti':2019 'never':337,1468,1522,1579,1766 'new':272,288,392,858,1047,1135,1271,1996 'next':82 'no-paramet':1397 'node.js':1921 'nodestreamablehttpservertransport':428 'normat':1588,1648 'notif':405 'npm':1449 'oauth':1504,1531,1645,1650,1655,1669,1681,1688,2065 'object':340,454,497,677,1361,1413,1948 'oct':1453 'offici':136,2034,2047 'op':2170 'open':772,1800,1817,1833,1851 'openworldhint':484,547,750,1255 'oper':1181,1184,1187,1192,1202,1333 'operatorsmarkdown':1204 'option':401,409,472,522,710,2007 'order':1339,1345 'orient':1327 'origin':1611,1617 'outcom':1326 'outcome-ori':1325 'output':790,1605 'outputschema':528,1367 'outputschema/structuredcontent':650 'over-privileg':1495 'overflow':1812 'overhead':1377 'overload':449 'overrid':1481 'packag':1450,1912,1970 'paramet':1396,1399,1939 'pars':1376 'parti':1563,2040 'passthrough':1511,1716 'pat':1498 'pattern':223,237,415,651,1103,1777,1892,2000,2127 'payment':346,1101 'pend':148,2174 'per':229,332,357,716,972,1215,1260,1316,1555,1598,1886 'per-client':1554 'per-request':228,356,1214,1259,1885 'perform':28,732,1205 'phrase':511 'pin':1455 'pkce':1671,1720 'plain':674,1861 'poison':1430 'posit':1950 'possibl':457 'postman':2105 'pr':1064 'practic':4,47 'pre':96,104 'pre-alpha':95,103 'prefer':450 'prefix':608,1487,2030 'preview':142 'privat':814,1540 'privileg':1497 'process':1371,1820 'produc':659 'product':6,52,151 'profil':591 'programmat':1373 'progress':2175,2177 'prompt':283,766 'propos':860 'protect':1974 'protocol':955,990,1037,1625,2016 'protocolerror':1934 'proxi':1547 'purpos':2051,2145 'q1':109 'queri':464,468,487,514,518,550,557,1233,1237,1395 'quick':78 'radius':1733 'random':1573 'randomuuid':204 'rate':1600 'raw':1355 'reach':1082 'read':1165,1246,1283 'read-on':1164 'readon':737 'readonlyhint':341,478,541,721,1249 'real':1422 'real-world':1421 'reason':906 'rebind':1973 'recommend':224 'recreat':331 'redirect':1543 'reduc':1731 'refer':49,79 'references/error-handling.md':1105 'references/extensions-registry.md':2139 'references/mcp-apps.md':2129 'references/security-auth.md':1783 'references/tool-schema-guide.md':653 'references/transport-patterns.md':378 'references/v2-migration.md':1907 'reg':44 'regist':280,307,1382,1852 'registertool':284,494,1946 'registr':439,688,1168,1846 'registri':141,143,2137 'reject':1708 'relev':1384 'remot':123,187,197,226 'remov':127,215,1677,1956 'repeat':741 'repres':701 'request':230,333,358,969,1216,1261,1389,1630,1887,2149,2158,2179 'requir':876,1586,1621,1622,1649,1705,1926 'research':829 'resourc':282,1106,1167,1243,1506,1690,1695 'respond':1613 'respons':299,961,1115,1349 'restart':1821 'result':470,475,489,520,525,530,552,554,559,562,568,1063,1089,1353 'retriev':1158 'return':315,560,1017,1287,1351,1607 'revers':2041 'review':1439 'rfc':1508,1697 'rpc':959 'rule':625,646 'run':2169 'runtim':421 'rush':1993 's256':1723 'sampl':2157 'sanit':1604 'scenario':183 'schema':113,118,335,624,644,661,676,698,1230,1409,1863,1930 'schemas.search':1282 'scheme':1176 'scope':1501,1503,1737,1742 'sdk':12,18,58,90,101,1055,1785,2124 'search':460,462,467,500,504,506,517,587,595,601,1148,1154,1180,1183,1186,1191,1201,1231,1236,1280,1281,1393 'search-oper':1179,1182,1200 'secret':1772 'secrethint':796 'secrets/credentials':799 'secur':27,77,1418,1775 'see':377,652,933,996,1044,1104,1782,1906,2128,2138 'select':22 'self':946,1005,1015 'self-correct':945,1004,1014 'sensit':579,779 'sep':773,973,1309,2165 'server':8,54,68,179,231,271,277,285,404,600,615,623,715,802,840,888,970,1109,1131,1134,1270,1276,1288,1317,1477,1480,1512,1548,1584,1639,1666,1686,1691,1703,1714,1888,1954,1964,1980,2079,2081,2140 'server-sid':1583 'server-to-serv':2078 'server.close':322 'server.connect':313 'server.registertool':499 'server.resource':1178 'server.tool':444,459,1279,1945 'serverrespons':436 'servic':607,1486,1536 'service-prefix':606,1485 'session':294,371,410,1565,1568 'sessionidgener':193,203,290 'set':758,848,1111 'setup':180 'sever':1788 'shadow':1478 'share':253,1222,1876 'shell':1473 'ship':1991 'short':1728 'short-liv':1727 'side':1585,2018 'silent':649,658,678,1797,1864 'simultan':854 'singl':899,1335 'single-deploy':898 'skill' 'skill-mcp-best-practices' 'smitheri':1451 'sourc':1492 'source-tenequm' 'space':603 'spec':14,83,570,717,977,1587,1633,1663 'spec.modelcontextprotocol.io':87,88 'specif':139,1702 'split':1321,1913 'spot':1320 'sse':126,201,212,214,301,402,1827,1953,1963 'ssrf':1529 'stabl':91,111,169,443,1990 'stack':1811 'standard':384,432,1929 'start':1300,1739 'state':198,1664 'stateless':188,222,292 'status':1347,1789 'stdio':124 'stdioservertransport':163,209 'step':1332 'still':1959 'stolen/guessed':1567 'strategi':1311 'stream':302 'streamabl':121,220 'strict':2008 'string':345 'strip':694 'structur':1072,1091,1172,1940,2150 'structuredcont':561,1368 'subset':1386 'summari':1365 'suppli':1446 'support':119,1190,1987,2020,2096,2108 'sweet':1319 'syntax':1194 'system':1120,2132 'system-level':1119 'target':493,1534,1544 'task':200,2164 'taxonomi':1097 'termin':411 'test':1757 'text':535,565,566,1022,1023,1153,1203 'text/markdown':1196 'theft':827,1494 'third':1562,2039 'third-parti':1561,2038 'threat':1420 'three':853 'throw':686,1046 'time':1264 'titl':502,1185 'today':152 'token':1289,1305,1359,1364,1493,1510,1514,1525,1700,1709,1715,1730,1753,1770 'tool':23,281,343,437,610,723,797,805,845,847,908,937,967,986,1009,1062,1088,1162,1292,1308,1315,1328,1336,1380,1385,1392,1400,1402,1429,1440,1483,1488,1491,1593,1602,2143,2155 'tools/resources':304,1854 'top':1419,2012 'topic-agent-skills' 'topic-ai-agents' 'topic-claude-code' 'topic-claude-skills' 'topic-clawhub' 'topic-erc-8004' 'topic-mpp' 'topic-openclaw' 'topic-skills' 'topic-solana' 'topic-x402' 'track':295,1338 'transform':702 'transit':1523 'transport':21,120,181,184,232,242,287,314,370,433,1809,1889,1955 'transport.close':320 'transport.handlerequest':316 'tri':311 'trifecta':809 'true':196,297,342,479,483,485,542,546,548,730,751,940,1019,1087,1250,1254,1256,1836 'trust':777,877 'trustedhint':801 'trustworthi':806 'ts':89,100 'tutori':61 'two':924 'type':564,931,1021,1412 'typescript':11,57,153,170,265,385,458,498,1007,1132,1177,1223,1410 'ui':38,2059 'uncaughtexcept':1818 'undefin':194,291 'unknown':966 'unsafeoutputhint':789 'unsanit':1463 'untrust':712,714,793,819,887 'updat':734 'upgrad':1868 'upstream':348,1527,1840 'uri':1175,1199 'url':1533 'use':424,634,666,762,880,935,1085,1129,1147,1406,1580,1722,1756,1801,1834 'user':590,1343,1360,1470,1577,2151 'user/session':1599 'v1':149,441 'v1.26.0':1884 'v1.28':19,684,1870 'v1.28.0':92,681,1867 'v1.x':1981 'v2':94,102,129,166,217,423,491,1656,1893,1989,1999,2146 'v4':1925 'v4c7':264,1875 'valid':949,982,1040,1490,1519,1542,1589,1610,1706,1754 'vendor':2029 'vendor-prefix':2028 'version':278,1141,1277,1456,1626 'via':1174,1552,1745,2023,2092 'visibl':930 'vs':1362,2101 'web':383,431,757,2098 'web-standard':382 'webstandardstreamablehttpservertransport':159,176,192,202,289,397,416 'wgs':140 'whatsapp':1435 'wide':2115 'window':1296 'without':1374 'work':67,417,445 'workaround':32,1790 'worker':191,413,420 'world':1423 'wrap':429 'write':1995 'www':1747 'www-authent':1746 'yes':882,943 'yet':2114 'z.array':531 'z.boolean':539 'z.discriminatedunion':657,1796 'z.enum':670,1804 'z.number':471,521 'z.object':513,529,532,668,1232,1239,1803 'z.string':465,515,534,536,1234,1241 'z.transform':693 'z.union':656,1795 'z0':584 'za':583 'zod':334,641,1924 'zod-to-json-schema':640","prices":[{"id":"94614858-00ad-451b-8046-fe3e1620142c","listingId":"5650a825-376b-4ce1-a114-b47e158d0aa5","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"tenequm","category":"skills","install_from":"skills.sh"},"createdAt":"2026-04-18T23:05:17.965Z"}],"sources":[{"listingId":"5650a825-376b-4ce1-a114-b47e158d0aa5","source":"github","sourceId":"tenequm/skills/mcp-best-practices","sourceUrl":"https://github.com/tenequm/skills/tree/main/skills/mcp-best-practices","isPrimary":false,"firstSeenAt":"2026-04-18T23:05:17.965Z","lastSeenAt":"2026-04-22T01:01:39.801Z"}],"details":{"listingId":"5650a825-376b-4ce1-a114-b47e158d0aa5","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"tenequm","slug":"mcp-best-practices","github":{"repo":"tenequm/skills","stars":23,"topics":["agent-skills","ai-agents","claude-code","claude-skills","clawhub","erc-8004","mpp","openclaw","skills","solana","x402"],"license":"mit","html_url":"https://github.com/tenequm/skills","pushed_at":"2026-04-14T16:24:57Z","description":"Agent skills for building, shipping, and growing software products","skill_md_sha":"87d9087bf4ac871d957b1b7e08bde911860b8419","skill_md_path":"skills/mcp-best-practices/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/tenequm/skills/tree/main/skills/mcp-best-practices"},"layout":"multi","source":"github","category":"skills","frontmatter":{"name":"mcp-best-practices","description":"Build production MCP servers with the TypeScript SDK. Covers spec 2025-11-25, SDK v1.28+/v2, transport selection, tool design, error handling, security, performance, known bugs with workarounds, MCP extensions, MCP Apps (interactive UIs), authorization extensions, and the MCP Registry. Use this skill whenever building MCP servers, designing MCP tools, choosing MCP transports, handling MCP errors, migrating to MCP v2, reviewing MCP security, optimizing MCP token usage, building MCP Apps, using MCP extensions, publishing to the MCP Registry, or working with registerTool, McpServer, streamable HTTP, outputSchema, structuredContent, tool annotations, ext-apps, or ext-auth."},"skills_sh_url":"https://skills.sh/tenequm/skills/mcp-best-practices"},"updatedAt":"2026-04-22T01:01:39.801Z"}}