claude-code-mcp
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaude Code MCP
Claude Code MCP
Specification: https://modelcontextprotocol.io/specification/2025-11-25 (November 2025)
Use this skill when you need to:
- Configure for official/community MCP servers
.claude/.mcp.json - Build custom MCP servers (TypeScript or Python)
- Deploy and harden remote MCP servers (HTTP transport)
当你需要以下操作时使用此技能:
- 为官方/社区MCP服务器配置
.claude/.mcp.json - 构建自定义MCP服务器(TypeScript或Python)
- 部署并加固远程MCP服务器(HTTP传输)
Quick Start (Local stdio via npx)
快速开始(通过npx使用本地stdio)
- Create or edit :
.claude/.mcp.json
json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": { "POSTGRES_URL": "${DATABASE_URL}" }
}
}
}- Provide env vars and validate the connection:
bash
export DATABASE_URL="postgresql://user:pass@localhost:5432/db"
claude mcp list
claude mcp get postgresNotes:
- Default config path is typically . If needed, override via
.claude/.mcp.json.claude --mcp-config <path> - Prefer as the Python interpreter in server configs unless your environment guarantees
python3.python
- 创建或编辑:
.claude/.mcp.json
json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": { "POSTGRES_URL": "${DATABASE_URL}" }
}
}
}- 提供环境变量并验证连接:
bash
export DATABASE_URL="postgresql://user:pass@localhost:5432/db"
claude mcp list
claude mcp get postgres注意:
- 默认配置路径通常为。如有需要,可通过
.claude/.mcp.json覆盖。claude --mcp-config <路径> - 除非你的环境确保可用,否则在服务器配置中优先使用
python作为Python解释器。python3
Permission Management (Recommended)
权限管理(推荐)
bash
undefinedbash
undefinedAllow all tools from a server (wildcard)
允许服务器的所有工具(通配符)
claude mcp add --allow "mcp__postgres__*" postgres -- npx -y @modelcontextprotocol/server-postgres
claude mcp add --allow "mcp__postgres__*" postgres -- npx -y @modelcontextprotocol/server-postgres
Allow specific tools only
仅允许特定工具
claude mcp add --allow "mcp__postgres__query,mcp__postgres__list_tables" postgres -- npx -y @modelcontextprotocol/server-postgres
claude mcp add --allow "mcp__postgres__query,mcp__postgres__list_tables" postgres -- npx -y @modelcontextprotocol/server-postgres
Deny a specific tool
拒绝特定工具
claude mcp add --deny "mcp__filesystem__write_file" filesystem -- npx -y @modelcontextprotocol/server-filesystem ./data
undefinedclaude mcp add --deny "mcp__filesystem__write_file" filesystem -- npx -y @modelcontextprotocol/server-filesystem ./data
undefinedProduction Guardrails (Required)
生产环境防护措施(必填)
- Assume tool outputs are untrusted (prompt injection). Sanitize/structure before reuse.
- Default to least privilege: read-only DB, scoped filesystem allowlists, minimal tool allowlists.
- Keep secrets out of ; inject via env vars or a secret manager at runtime.
.mcp.json - Add timeouts, retries, and rate limits; log all tool invocations for audit.
- 假设工具输出不可信(存在提示注入风险)。在复用前需进行清理/结构化处理。
- 默认遵循最小权限原则:只读数据库、限定范围的文件系统允许列表、最小化的工具允许列表。
- 不要将密钥存入;在运行时通过环境变量或密钥管理器注入。
.mcp.json - 添加超时、重试和速率限制;记录所有工具调用以用于审计。
What To Read Next
接下来可阅读的内容
- Choose an existing server:
references/mcp-servers.md - Build a custom server:
references/mcp-custom.md - Implementation patterns (DB/API/filesystem):
references/mcp-patterns.md - Security hardening (OAuth, scopes, injection defense):
references/mcp-security.md - Templates: ,
assets/database/template-mcp-database.md,assets/filesystem/template-mcp-filesystem.md,assets/api/template-mcp-api.mdassets/deployment/template-mcp-docker.md - Curated links:
data/sources.json
- 选择现有服务器:
references/mcp-servers.md - 构建自定义服务器:
references/mcp-custom.md - 实现模式(数据库/API/文件系统):
references/mcp-patterns.md - 安全加固(OAuth、权限范围、注入防护):
references/mcp-security.md - 模板:,
assets/database/template-mcp-database.md,assets/filesystem/template-mcp-filesystem.md,assets/api/template-mcp-api.mdassets/deployment/template-mcp-docker.md - 精选链接:
data/sources.json