MCP 助手
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- 运维部署
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需手动接入
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 兼容的系统
- Docker
- 底层运行要求
- Node.js · Python · Docker
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: mcp-server
description: This skill should be used when the user asks to "build an MCP server", "create an MCP", "make an…
category: 运维部署
runtime: Node.js / Python / Docker
---
# mcp-server 输出预览
## PART A: 任务判断
- 适用问题:部署、CI、环境检查、发布或运维排障。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Overview / Phase 1: Discovery / 1. What does it connect to?”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于部署、CI、环境检查、发布或运维排障,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Overview / Phase 1: Discovery / 1. What does it connect to?”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、读取环境变量、会按任务需要访问外部网络、需要准备 Vendor-specific API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令、读取环境变量。
先用一个小任务确认它会围绕“Overview / Phase 1: Discovery / 1. What does it connect to?”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: mcp-server
description: This skill should be used when the user asks to "build an MCP server", "create an MCP", "make an…
category: 运维部署
source: tomevault-io/skills-registry
---
# mcp-server
## 什么时候使用
- 用于组织测试、定位失败并形成修复闭环 适合处理部署、CI、发布、回滚、环境检查和运维排障,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;使用前要准备 Ve…
- 面向部署、CI、环境检查、发布或运维排障,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Overview / Phase 1: Discovery / 1. What does it connect to?」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;需要准备 Vendor-specific API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "mcp-server" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Overview / Phase 1: Discovery / 1. What does it connect to?
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Node.js / Python / Docker | 读取文件、写入/修改文件、执行终端命令、读取环境变量 | 会按任务需要访问外部网络
安全层 -> 需要准备 Vendor-specific API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} MCP Server Development
Guide for designing and building MCP (Model Context Protocol) servers that connect Claude to external tools, APIs, and data sources.
Overview
MCP servers bridge Claude with external systems using a standardized protocol. Three primitives are available:
| Primitive | Controlled By | Purpose |
|---|---|---|
| Tools | Model (Claude) | Functions Claude can invoke |
| Resources | Application | Contextual data Claude can read |
| Prompts | User | Templates users can invoke |
Phase 1: Discovery
Before coding, understand the use case. Ask these questions:
1. What does it connect to?
| Connection Type | Recommended Approach |
|---|---|
| Cloud API (SaaS, REST, GraphQL) | Remote HTTP server |
| Local process, filesystem, desktop app | MCPB or local stdio |
| Hardware, OS-level APIs | MCPB |
| Pure logic/computation | Either - default to remote |
2. Who will use it?
- Just me / my team → Local stdio acceptable
- Anyone who installs it → Remote HTTP (preferred) or MCPB
- Claude desktop with UI widgets → MCP app
3. How many distinct actions?
- Under ~15 actions → One tool per action
- Dozens to hundreds → Search + execute pattern
4. Does a tool need user input mid-call?
- Simple forms (pick, enter, confirm) → Elicitation (spec-native)
- Rich UI (charts, search, dashboards) → MCP app widgets
- Neither → Plain tool returning text/JSON
5. What authentication does the service use?
- None / API key → Straightforward
- OAuth 2.0 → Remote server with CIMD or DCR support
Phase 2: Recommend Deployment Model
Based on discovery answers, recommend ONE path:
⭐ Remote HTTP Server (Default)
Hosted service speaking MCP over streamable HTTP. Best for cloud API wrappers.
Benefits:
- Zero install friction - users add a URL
- One deployment serves all users
- OAuth flows work properly
- Works across Claude desktop, Claude Code, Claude.ai
Choose unless server must touch local machine.
MCPB (Bundled Local Server)
Local server packaged with its runtime. No Node/Python needed on user machine.
Choose when server must run on user's machine:
- Reads local files
- Drives desktop apps
- Talks to localhost services
- Needs OS-level access
Local stdio (Prototypes Only)
Script launched via npx / uvx. Fine for personal tools and prototypes.
Not recommended for distribution - users need runtime, no update mechanism.
Phase 3: Pick Tool Design Pattern
Pattern A: One Tool Per Action (Small Surface)
When action space is small (< ~15 operations), each gets a dedicated tool.
create_issue — Create a new issue
update_issue — Update an existing issue
search_issues — Search issues by query
add_comment — Add a comment
Benefits: Claude reads tool list once, knows exactly what's possible.
Pattern B: Search + Execute (Large Surface)
When wrapping large APIs (dozens+ endpoints), use TWO tools:
search_actions — Return matching actions with IDs and schemas
execute_action — Run an action by ID with params
Benefits: Server holds catalog internally, context stays lean.
Hybrid: Promote 3-5 most-used actions to dedicated tools.
Phase 4: Pick Framework
| Framework | Language | When to Use |
|---|---|---|
| FastMCP 3.x | Python | Python preference, wrapping Python libraries |
| TypeScript SDK | TypeScript | Default choice, best spec coverage |
Both produce identical wire protocol.
Phase 5: Scaffold Server
FastMCP (Python)
from fastmcp import FastMCP
mcp = FastMCP("server-name")
@mcp.tool
def my_tool(query: str) -> dict:
"""Tool description Claude sees."""
return process(query)
if __name__ == "__main__":
mcp.run() # stdio (default)
# mcp.run(transport="http", port=8000) # HTTP
TypeScript SDK
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
const server = new McpServer({
name: "server-name",
version: "1.0.0"
});
server.tool("myTool", { query: z.string() }, async ({ query }) => ({
content: [{ type: "text", text: JSON.stringify(process(query)) }]
}));
server.connect(transport);
Phase 6: Test and Publish
Testing
# MCP Inspector - official testing tool
npx @modelcontextprotocol/inspector uv run python -m my_mcp
Critical: Log to stderr, NOT stdout (stdout is the protocol).
Testing Before Release:
- Test ALL tools with MCP Inspector before releasing
- Test with actual provider (e.g., real IMAP server) if wrapping external APIs
- Verify environment variables are passed correctly
- Check provider-specific quirks (see Provider Quirks section)
Claude Code Plugin Deployment
When bundling MCP servers in Claude Code plugins:
The cwd Bug (Issue #17565)
CRITICAL: Claude Code ignores the cwd field in .mcp.json. Always use the bash -c workaround:
{
"mcpServers": {
"my-server": {
"command": "bash",
"args": ["-c", "cd \"${CLAUDE_PLUGIN_ROOT}/my-server\" && exec uv run python -m my_mcp"]
}
}
}
Dependency Management
Use uv run for portable dependency management:
"command": "bash",
"args": ["-c", "cd \"${CLAUDE_PLUGIN_ROOT}/server\" && exec uv run python -m server"]
This ensures dependencies are automatically installed from pyproject.toml.
Environment Variables
Only include required environment variables in .mcp.json. Optional variables should use defaults in code:
# Bad - will fail if EMAIL_OAUTH2_TOKEN is empty
oauth2_token: str = Field(alias="OAUTH2_TOKEN")
# Good - optional with default
oauth2_token: str | None = Field(default=None, alias="OAUTH2_TOKEN")
For Pydantic settings, use env_parse_none_str="" to treat empty strings as None:
model_config = SettingsConfigDict(
env_prefix="MY_",
env_parse_none_str="", # Empty strings become None
)
Provider Quirks
When wrapping external services, test with the actual provider:
| Provider | Quirk | Solution |
|---|---|---|
| iCloud IMAP | SEARCH returns status message instead of IDs | Check for "completed" in response |
| iCloud IMAP | LIST requires specific quoting | Use list('""', '"*"') |
| iCloud IMAP | FETCH returns bytearray | Handle both bytes and bytearray |
Pre-submission Checklist
- Read/write tool split for destructive operations
- Required annotations on all tools
- Tool names under 128 characters
- No prompt injection in tool output
- Input validation on all parameters
- Tested with MCP Inspector
- Tested with actual provider (not just mocks)
Distribution
- Submit to Anthropic Directory
- Create plugin wrapper for skills
- Document installation clearly
- Require
uvfor dependency management
Security Essentials
| Priority | Practice |
|---|---|
| CRITICAL | Use stdio for local servers (no network) |
| CRITICAL | Require TLS for remote servers |
| CRITICAL | Validate all inputs (types, ranges, formats) |
| CRITICAL | Reject path traversal (../) |
| CRITICAL | Load credentials from environment only |
| CRITICAL | Never return secrets in tool output |
| HIGH | Run as non-root user |
| HIGH | Use argument lists, never shell strings |
Additional Resources
Reference Files
Consult these for detailed implementation guidance:
references/fastmcp-patterns.md— FastMCP decorator patterns, type hints, context injectionreferences/security-best-practices.md— Input validation, credential management, path traversal preventionreferences/testing-debugging.md— MCP Inspector, stderr logging, CI/CD integrationreferences/deployment-options.md— stdio, HTTP/SSE, Cloudflare Workers, Docker, MCPB
External Links
Source: christophevg/c3 — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核