MCP (Model Context Protocol) server building principles. Tool design, resource patterns, best practices.
51
57%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.agents/skills/mcp-builder/SKILL.mdPrinciples 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 — McpServer from @modelcontextprotocol/sdk
├── package.json # dep: @modelcontextprotocol/sdk
└── tsconfig.jsonTypeScript SDK:
@modelcontextprotocol/sdk(McpServer). Python SDK:mcp(pip install "mcp[cli]",FastMCPbundled inmcp.server.fastmcp).
| Type | Use |
|---|---|
| stdio | Local, CLI-based |
| Streamable HTTP | Remote/web servers (replaced the deprecated HTTP+SSE transport) |
The current spec (2025-06-18) defines two standard transports: stdio and Streamable HTTP. WebSocket is not a standard transport. Validate the
Originheader on Streamable HTTP servers.
| 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 (stdio servers) |
| args | Command arguments |
| env | Environment variables |
MCP is multi-client — the same server works across Claude Desktop, Claude Code, and IDE hosts. Remote (Streamable HTTP) servers authenticate via OAuth rather than a local command.
Worth using in modern servers (spec 2025-06-18):
| Feature | Purpose |
|---|---|
| Tool annotations | Hint read-only/destructive behavior to the client |
Structured content / outputSchema | Typed, predictable tool results |
| Resource links | Return references to resources from tool results |
| OAuth | Auth for remote/Streamable HTTP servers |
| 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.
04514f0
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.