MCP (Model Context Protocol) server building principles. Tool design, resource patterns, best practices.
Principles for building MCP servers.
Model Context Protocol - standard for connecting AI systems with external tools and data sources.
| Concept | Purpose | |---------|---------| | Tools | Functions AI can call | | Resources | Data AI can read | | Prompts | Pre-defined prompt templates |
my-mcp-server/
├── src/
│ └── index.ts # Main entry
├── package.json
└── tsconfig.json
| Type | Use | |------|-----| | Stdio | Local, CLI-based | | SSE | Web-based, streaming | | WebSocket | Real-time, bidirectional |
| Principle | Description | |-----------|-------------| | Clear name | Action-oriented (get_weather, create_user) | | Single purpose | One thing well | | Validated input | Schema with types and descriptions | | Structured output | Predictable response format |
| Field | Required? | |-------|-----------| | Type | Yes - object | | Properties | Define each param | | Required | List mandatory params | | Description | Human-readable |
| Type | Use | |------|-----| | Static | Fixed data (config, docs) | | Dynamic | Generated on request | | Template | URI with parameters |
| Pattern | Example |
|---------|---------|
| Fixed | docs://readme |
| Parameterized | users://{userId} |
| Collection | files://project/* |
| Situation | Response | |-----------|----------| | Invalid params | Validation error message | | Not found | Clear "not found" | | Server error | Generic error, log details |
| Type | Encoding | |------|----------| | Text | Plain text | | Images | Base64 + MIME type | | Files | Base64 + MIME type |
| Field | Purpose | |-------|---------| | command | Executable to run | | args | Command arguments | | env | Environment variables |
| Type | Focus | |------|-------| | Unit | Tool logic | | Integration | Full server | | Contract | Schema validation |
Remember: MCP tools should be simple, focused, and well-documented. The AI relies on descriptions to use them correctly.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer