Files
agent-fox/docs/clients/claude-code.md
2026-04-12 20:15:41 +08:00

71 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Claude Code
Claude Code 是 Anthropic 的 CLI 编程助手,支持项目级和全局两种 MCP 配置方式。
## 方式一:项目级配置(推荐)
在项目根目录创建 `.mcp.json` 文件:
```json
{
"mcpServers": {
"my-api": {
"type": "http",
"url": "https://www.agentfoxapp.com/mcp/{projectId}",
"headers": {
"Authorization": "Bearer {your-api-key}"
}
}
}
}
```
优点:配置跟随项目,团队成员可共享(注意不要将 API Key 提交到版本控制)。
## 方式二:全局配置
编辑 `~/.claude.json`,在顶层添加 `mcpServers`
```json
{
"mcpServers": {
"my-api": {
"type": "http",
"url": "https://www.agentfoxapp.com/mcp/{projectId}",
"headers": {
"Authorization": "Bearer {your-api-key}"
}
}
}
}
```
全局配置对所有项目生效。
## 验证连接
启动 Claude Code 后,可以通过以下方式验证:
```bash
# 列出已配置的 MCP 服务器
claude mcp list
```
或在对话中直接使用:
```
你:帮我看看这个 API 有哪些模块
Claude[调用 get_project_overview]
这个 API 包含以下模块:...
```
## 安全提示
如果使用项目级配置,建议将 `.mcp.json` 添加到 `.gitignore`,避免 API Key 泄露:
```bash
echo ".mcp.json" >> .gitignore
```
或者使用环境变量(如果客户端支持)来管理 API Key。