Claude Code 使用技巧之 MPC

1次阅读
没有评论

共计 1506 个字符,预计需要花费 4 分钟才能阅读完成。

MCP 连接外部数据

添加 HTTP 服务

# Basic syntax
claude mcp add --transport http <name> <url>

# Real example: Connect to Notion
claude mcp add --transport http notion https://mcp.notion.com/mcp

# Example with Bearer token
claude mcp add --transport http secure-api https://api.example.com/mcp \
  --header "Authorization: Bearer your-token"

添加本地 stdio 服务

# Basic syntax
claude mcp add --transport stdio <name> <command> [args...]

# Real example: Add Airtable server
claude mcp add --transport stdio airtable --env AIRTABLE_API_KEY=YOUR_KEY \
  -- npx -y airtable-mcp-server

管理 MCP 服务

# 查看当前的 MCP
claude mcp list

# 获取 MCP 详情
claude mcp get github

# 移除 MCP 服务
claude mcp remove github

# 在 Claude Code 内部查看状态
/mcp

在添加 MCP 的时候有一些选项

  • 通过 --scope 来配置 MCP 生效范围
    • local 当前项目,这是默认选项
    • project,当前项目中 .mcp.json 文件,可以共享给其他人
    • user 配置到用户 Home 目录,可以被所有项目使用
  • 配置环境变量 --env KEY=value

以添加 GitHub MCP 为例

参考官方配置教程

首先生成 GitHub Personal Access Token,根据自己的需求添加 Token 权限。

添加 GitHub

claude mcp add --transport http github --scope user https://api.githubcopilot.com/mcp -H "Authorization: Bearer YOUR_GITHUB_PAT"

之后就可以直接在 Claude Code 中连接 GitHub,比如

Review PR #123 and suggest improvements
Create a new issue for the bug we just found
Show me all open PRs assigned to me

Claude Code 必备 MCP

Context7,动态获取最新的、版本特定的代码文档和示例,并自动注入到 Claude Code 的上下文中。生成 API Key 获取更高的访问请求数

claude mcp add context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY

Sequential Thinking,适合处理复杂问题:架构设计、大规模重构、系统调试等。

claude mcp add sequential-thinking -s user -- npx -y @modelcontextprotocol/server-sequential-thinking

Server memory 是 Anthropic 官方提供的 MCP 服务器,使用本地知识图来实现持久化内存,让 Claude 能够在多个对话中基于用户信息。

claude mcp add server-memory -- npx -y @modelcontextprotocol/server-memory

More

如果大家有使用 Claude Code 的需求,最近正好想要找人拼车,欢迎来联系

正文完
 0
评论(没有评论)