$npx -y skills add One-Man-Company/Skills-ContextManager --skill mcp-builderMCP (Model Context Protocol) server building principles. Tool design, resource patterns, best practices.
| 1 | # MCP Builder |
| 2 | |
| 3 | > Principles for building MCP servers. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## 1. MCP Overview |
| 8 | |
| 9 | ### What is MCP? |
| 10 | |
| 11 | Model Context Protocol - standard for connecting AI systems with external tools and data sources. |
| 12 | |
| 13 | ### Core Concepts |
| 14 | |
| 15 | | Concept | Purpose | |
| 16 | |---------|---------| |
| 17 | | **Tools** | Functions AI can call | |
| 18 | | **Resources** | Data AI can read | |
| 19 | | **Prompts** | Pre-defined prompt templates | |
| 20 | |
| 21 | --- |
| 22 | |
| 23 | ## 2. Server Architecture |
| 24 | |
| 25 | ### Project Structure |
| 26 | |
| 27 | ``` |
| 28 | my-mcp-server/ |
| 29 | ├── src/ |
| 30 | │ └── index.ts # Main entry |
| 31 | ├── package.json |
| 32 | └── tsconfig.json |
| 33 | ``` |
| 34 | |
| 35 | ### Transport Types |
| 36 | |
| 37 | | Type | Use | |
| 38 | |------|-----| |
| 39 | | **Stdio** | Local, CLI-based | |
| 40 | | **SSE** | Web-based, streaming | |
| 41 | | **WebSocket** | Real-time, bidirectional | |
| 42 | |
| 43 | --- |
| 44 | |
| 45 | ## 3. Tool Design Principles |
| 46 | |
| 47 | ### Good Tool Design |
| 48 | |
| 49 | | Principle | Description | |
| 50 | |-----------|-------------| |
| 51 | | Clear name | Action-oriented (get_weather, create_user) | |
| 52 | | Single purpose | One thing well | |
| 53 | | Validated input | Schema with types and descriptions | |
| 54 | | Structured output | Predictable response format | |
| 55 | |
| 56 | ### Input Schema Design |
| 57 | |
| 58 | | Field | Required? | |
| 59 | |-------|-----------| |
| 60 | | Type | Yes - object | |
| 61 | | Properties | Define each param | |
| 62 | | Required | List mandatory params | |
| 63 | | Description | Human-readable | |
| 64 | |
| 65 | --- |
| 66 | |
| 67 | ## 4. Resource Patterns |
| 68 | |
| 69 | ### Resource Types |
| 70 | |
| 71 | | Type | Use | |
| 72 | |------|-----| |
| 73 | | Static | Fixed data (config, docs) | |
| 74 | | Dynamic | Generated on request | |
| 75 | | Template | URI with parameters | |
| 76 | |
| 77 | ### URI Patterns |
| 78 | |
| 79 | | Pattern | Example | |
| 80 | |---------|---------| |
| 81 | | Fixed | `docs://readme` | |
| 82 | | Parameterized | `users://{userId}` | |
| 83 | | Collection | `files://project/*` | |
| 84 | |
| 85 | --- |
| 86 | |
| 87 | ## 5. Error Handling |
| 88 | |
| 89 | ### Error Types |
| 90 | |
| 91 | | Situation | Response | |
| 92 | |-----------|----------| |
| 93 | | Invalid params | Validation error message | |
| 94 | | Not found | Clear "not found" | |
| 95 | | Server error | Generic error, log details | |
| 96 | |
| 97 | ### Best Practices |
| 98 | |
| 99 | - Return structured errors |
| 100 | - Don't expose internal details |
| 101 | - Log for debugging |
| 102 | - Provide actionable messages |
| 103 | |
| 104 | --- |
| 105 | |
| 106 | ## 6. Multimodal Handling |
| 107 | |
| 108 | ### Supported Types |
| 109 | |
| 110 | | Type | Encoding | |
| 111 | |------|----------| |
| 112 | | Text | Plain text | |
| 113 | | Images | Base64 + MIME type | |
| 114 | | Files | Base64 + MIME type | |
| 115 | |
| 116 | --- |
| 117 | |
| 118 | ## 7. Security Principles |
| 119 | |
| 120 | ### Input Validation |
| 121 | |
| 122 | - Validate all tool inputs |
| 123 | - Sanitize user-provided data |
| 124 | - Limit resource access |
| 125 | |
| 126 | ### API Keys |
| 127 | |
| 128 | - Use environment variables |
| 129 | - Don't log secrets |
| 130 | - Validate permissions |
| 131 | |
| 132 | --- |
| 133 | |
| 134 | ## 8. Configuration |
| 135 | |
| 136 | ### Claude Desktop Config |
| 137 | |
| 138 | | Field | Purpose | |
| 139 | |-------|---------| |
| 140 | | command | Executable to run | |
| 141 | | args | Command arguments | |
| 142 | | env | Environment variables | |
| 143 | |
| 144 | --- |
| 145 | |
| 146 | ## 9. Testing |
| 147 | |
| 148 | ### Test Categories |
| 149 | |
| 150 | | Type | Focus | |
| 151 | |------|-------| |
| 152 | | Unit | Tool logic | |
| 153 | | Integration | Full server | |
| 154 | | Contract | Schema validation | |
| 155 | |
| 156 | --- |
| 157 | |
| 158 | ## 10. Best Practices Checklist |
| 159 | |
| 160 | - [ ] Clear, action-oriented tool names |
| 161 | - [ ] Complete input schemas with descriptions |
| 162 | - [ ] Structured JSON output |
| 163 | - [ ] Error handling for all cases |
| 164 | - [ ] Input validation |
| 165 | - [ ] Environment-based configuration |
| 166 | - [ ] Logging for debugging |
| 167 | |
| 168 | --- |
| 169 | |
| 170 | > **Remember:** MCP tools should be simple, focused, and well-documented. The AI relies on descriptions to use them correctly. |