Loading...
Loading...
MCP server building, advanced patterns, and security hardening. Use when building MCP servers, implementing tool handlers, adding authentication, creating interactive UIs, hardening MCP security, or debugging MCP integrations.
npx skill4agent add yonatangross/orchestkit mcp-patternsScaffolding a new server? Use Anthropic'sskill (mcp-builder) for project setup and evaluation creation. This skill focuses on patterns, security, and advanced features after initial setup.claude install anthropics/skillsDeploying to Cloudflare? See theskill for Workers-specific deployment patterns.building-mcp-server-on-cloudflare
What are you building?
│
├── New MCP server
│ ├── Setup & primitives ──────► rules/server-setup.md
│ ├── Transport selection ─────► rules/server-transport.md
│ └── Scaffolding ─────────────► mcp-builder skill (anthropics/skills)
│
├── Authentication & authorization
│ └── OAuth 2.1 + OIDC ───────► rules/auth-oauth21.md
│
├── Advanced server features
│ ├── Tool composition ────────► rules/advanced-composition.md
│ ├── Resource caching ────────► rules/advanced-resources.md
│ ├── Elicitation (user input) ► rules/elicitation.md
│ ├── Sampling (agent loops) ──► rules/sampling-tools.md
│ └── Interactive UI ──────────► rules/apps-ui.md
│
├── Client-side consumption
│ └── Connecting to servers ───► rules/client-patterns.md
│
├── Security hardening
│ ├── Prompt injection defense ► rules/security-injection.md
│ └── Zero-trust & verification ► rules/security-hardening.md
│
├── Testing & debugging
│ └── Inspector + unit tests ──► rules/testing-debugging.md
│
├── Discovery & ecosystem
│ └── Registries & catalogs ──► rules/registry-discovery.md
│
└── Browser-native tools
└── WebMCP (W3C) ───────────► rules/webmcp-browser.md| Category | Rule | Impact | Key Pattern |
|---|---|---|---|
| Server | | HIGH | FastMCP lifespan, Tool/Resource/Prompt primitives |
| Server | | HIGH | stdio for CLI, Streamable HTTP for production |
| Auth | | HIGH | PKCE, RFC 8707 resource indicators, token validation |
| Advanced | | MEDIUM | Pipeline, parallel, and branching tool composition |
| Advanced | | MEDIUM | Resource caching with TTL, LRU eviction, lifecycle |
| Advanced | | MEDIUM | Server-initiated structured input from users |
| Advanced | | MEDIUM | Server-side agent loops with tool calling |
| Advanced | | MEDIUM | Interactive UI via MCP Apps + @mcp-ui/* SDK |
| Client | | MEDIUM | TypeScript/Python MCP client connection patterns |
| Security | | HIGH | Description sanitization, encoding normalization |
| Security | | HIGH | Zero-trust allowlist, hash verification, rug pull detection |
| Quality | | MEDIUM | MCP Inspector, unit tests, transport debugging |
| Ecosystem | | LOW | Official registry API, server metadata |
| Ecosystem | | LOW | W3C browser-native agent tools (complementary) |
| Decision | Recommendation |
|---|---|
| Transport | stdio for CLI/Desktop, Streamable HTTP for production (SSE deprecated) |
| Language | TypeScript for production (better SDK support, type safety) |
| Auth | OAuth 2.1 with PKCE (S256) + RFC 8707 resource indicators |
| Server lifecycle | Always use FastMCP lifespan for resource management |
| Error handling | Return errors as text content (Claude can interpret and retry) |
| Tool composition | Pipeline for sequential, |
| Resource caching | TTL + LRU eviction with memory cap |
| Tool trust model | Zero-trust: explicit allowlist + hash verification |
| User input | Elicitation for runtime input; never request PII via elicitation |
| Interactive UI | MCP Apps with @mcp-ui/* SDK; sandbox all iframes |
| Token handling | Never pass through client tokens to downstream services |
| Feature | Spec Version | Status |
|---|---|---|
| Tools, Resources, Prompts | 2024-11-05 | Stable |
| Streamable HTTP transport | 2025-03-26 | Stable (replaces SSE) |
| OAuth 2.1 + Elicitation (form) | 2025-06-18 | Stable |
| Sampling with tool calling | 2025-11-25 | Stable |
| Elicitation URL mode | 2025-11-25 | Stable |
| MCP Apps (UI extension) | 2026-01-26 | Extension (ext-apps) |
| WebMCP (browser-native) | 2026-02-14 | W3C Community Draft |
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("my-server")
@mcp.tool()
async def search(query: str) -> str:
"""Search documents. Returns matching results."""
results = await db.search(query)
return "\n".join(r.title for r in results[:10])asyncio.to_thread()| Resource | What For |
|---|---|
| Scaffold new MCP servers + create evals |
| Deploy MCP servers on Cloudflare Workers |
| Implement MCP Apps UI standard |
| MCP Registry | Discover servers: https://registry.modelcontextprotocol.io/ |
| MCP Inspector | Debug and test servers interactively |
llm-integrationsecurity-patternsapi-design