Skill

mcp-patterns

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.

From ork
Install
1
Run in your terminal
$
npx claudepluginhub yonatangross/orchestkit --plugin ork
Tool Access

This skill is limited to using the following tools:

ReadGlobGrepWebFetchWebSearch
Supporting Assets
View in Repository
checklists/mcp-server-checklist.md
rules/_sections.md
rules/_template.md
rules/advanced-composition.md
rules/advanced-resources.md
rules/apps-ui.md
rules/auth-oauth21.md
rules/client-patterns.md
rules/elicitation.md
rules/registry-discovery.md
rules/sampling-tools.md
rules/security-hardening.md
rules/security-injection.md
rules/server-setup.md
rules/server-transport.md
rules/testing-debugging.md
rules/webmcp-browser.md
test-cases.json
Skill Content

MCP Patterns

Patterns for building, composing, and securing Model Context Protocol servers. Based on the 2025-11-25 specification — the latest stable release maintained by the Agentic AI Foundation (Linux Foundation), co-founded by Anthropic, Block, and OpenAI.

Scaffolding a new server? Use Anthropic's mcp-builder skill (claude install anthropics/skills) for project setup and evaluation creation. This skill focuses on patterns, security, and advanced features after initial setup.

Deploying to Cloudflare? See the building-mcp-server-on-cloudflare skill for Workers-specific deployment patterns.

Decision Tree — Which Rule to Read

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

Quick Reference

CategoryRuleImpactKey Pattern
Serverserver-setup.mdHIGHFastMCP lifespan, Tool/Resource/Prompt primitives
Serverserver-transport.mdHIGHstdio for CLI, Streamable HTTP for production
Authauth-oauth21.mdHIGHPKCE, RFC 8707 resource indicators, token validation
Advancedadvanced-composition.mdMEDIUMPipeline, parallel, and branching tool composition
Advancedadvanced-resources.mdMEDIUMResource caching with TTL, LRU eviction, lifecycle
Advancedelicitation.mdMEDIUMServer-initiated structured input from users
Advancedsampling-tools.mdMEDIUMServer-side agent loops with tool calling
Advancedapps-ui.mdMEDIUMInteractive UI via MCP Apps + @mcp-ui/* SDK
Clientclient-patterns.mdMEDIUMTypeScript/Python MCP client connection patterns
Securitysecurity-injection.mdHIGHDescription sanitization, encoding normalization
Securitysecurity-hardening.mdHIGHZero-trust allowlist, hash verification, rug pull detection
Qualitytesting-debugging.mdMEDIUMMCP Inspector, unit tests, transport debugging
Ecosystemregistry-discovery.mdLOWOfficial registry API, server metadata
Ecosystemwebmcp-browser.mdLOWW3C browser-native agent tools (complementary)

Total: 14 rules across 6 categories

Key Decisions

DecisionRecommendation
Transportstdio for CLI/Desktop, Streamable HTTP for production (SSE deprecated)
LanguageTypeScript for production (better SDK support, type safety)
AuthOAuth 2.1 with PKCE (S256) + RFC 8707 resource indicators
Server lifecycleAlways use FastMCP lifespan for resource management
Error handlingReturn errors as text content (Claude can interpret and retry)
Tool compositionPipeline for sequential, asyncio.gather for parallel
Resource cachingTTL + LRU eviction with memory cap
Tool trust modelZero-trust: explicit allowlist + hash verification
User inputElicitation for runtime input; never request PII via elicitation
Interactive UIMCP Apps with @mcp-ui/* SDK; sandbox all iframes
Token handlingNever pass through client tokens to downstream services

Spec & Governance

  • Protocol: Model Context Protocol, spec version 2025-11-25 (latest stable)
  • Governance: Agentic AI Foundation (Linux Foundation, Dec 2025)
  • Platinum members: AWS, Anthropic, Block, Bloomberg, Cloudflare, Google, Microsoft, OpenAI
  • Adoption: 10,000+ servers; Claude, Cursor, Copilot, Gemini, ChatGPT, VS Code
  • Spec URL: https://modelcontextprotocol.io/specification/2025-11-25
  • 2026 model: Working Groups and Interest Groups are now the primary vehicle for protocol evolution (no more milestone-based releases). Enterprise readiness lands as extensions, not core spec changes.

Feature Maturity

FeatureSpec VersionStatus
Tools, Resources, Prompts2024-11-05Stable
Streamable HTTP transport2025-03-26Stable (replaces SSE)
OAuth 2.1 + Elicitation (form)2025-06-18Stable
Sampling with tool calling2025-11-25Stable
Elicitation URL mode2025-11-25Stable
MCP Apps (UI extension)2026-01-26Extension (ext-apps)
WebMCP (browser-native)2026-02-14W3C Community Draft

Example

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])

Common Mistakes

  1. No lifecycle management (connection/resource leaks on shutdown)
  2. Missing input validation on tool arguments
  3. Returning secrets in tool output (API keys, credentials)
  4. Unbounded response sizes (Claude has context limits)
  5. Trusting tool descriptions without sanitization (injection risk)
  6. No hash verification on tool invocations (rug pull vulnerability)
  7. Storing auth tokens in session IDs (credential leak)
  8. Blocking synchronous code in async server (use asyncio.to_thread())
  9. Using SSE transport instead of Streamable HTTP (deprecated since March 2025)
  10. Passing through client tokens to downstream services (confused deputy)

Ecosystem

ResourceWhat For
mcp-builder skill (anthropics/skills)Scaffold new MCP servers + create evals
building-mcp-server-on-cloudflare skillDeploy MCP servers on Cloudflare Workers
@mcp-ui/* packages (npm)Implement MCP Apps UI standard
MCP RegistryDiscover servers: https://registry.modelcontextprotocol.io/
MCP InspectorDebug and test servers interactively

Related Skills

  • ork:llm-integration — LLM function calling patterns
  • ork:security-patterns — General input sanitization and layered security
  • ork:api-design — REST/GraphQL API design patterns
Stats
Parent Repo Stars132
Parent Repo Forks14
Last CommitMar 21, 2026