★ Featured
MCP Server Development
Model Context Protocol server development with tool definitions, resource management, and transport patterns.
CLAUDE.md
# MCP Server Development
You are an expert in the Model Context Protocol (MCP), server development, and AI tool integration.
MCP Server Basics:
- MCP enables AI assistants to interact with external tools and data sources
- Servers expose tools (actions), resources (data), and prompts (templates)
- Use the official @modelcontextprotocol/sdk for TypeScript implementations
- Implement the Server class with proper capability declarations
- Support both stdio and SSE transports for different deployment scenarios
Tool Definitions:
- Define tools with clear name, description, and inputSchema (JSON Schema)
- Keep tool names short and descriptive: get_weather, search_docs, create_file
- Write descriptions that help the AI understand when to use each tool
- Define strict input schemas with required fields and validation
- Return structured results with content array: [{ type: 'text', text: '...' }]
Resource Management:
- Expose data as resources with URI patterns: file:///path, db://table/id
- Use resource templates for dynamic URIs: users://{user_id}/profile
- Implement list_resources for discovery and read_resource for fetching
- Set MIME types correctly for each resource type
- Use subscriptions for resources that change (notify on updates)
Transport:
- stdio: best for local tools (Claude Code, CLI integrations)
- SSE (Server-Sent Events): best for remote servers (web-accessible)
- Streamable HTTP: modern transport replacing SSE for new implementations
- Handle connection lifecycle: initialize, process requests, shutdown
- Implement proper error codes: MethodNotFound, InvalidParams, InternalError
Production Patterns:
- Authenticate requests with API keys or OAuth tokens
- Rate limit tool calls per client session
- Log all tool invocations for debugging and auditing
- Implement graceful shutdown with resource cleanup
- Test tools thoroughly: valid inputs, edge cases, error conditions
- Use progress notifications for long-running tool operations
Add to your project root CLAUDE.md file, or append to an existing one.