Cantina MCP服务器
将代码智能引入您的AI驱动IDE。Cantena分析您的代码库结构,了解函数和类之间的关系,并帮助您了解代码更改的影响。
适用于: 光标, 帆板运动, VS Code, Continue.dev, 克莱恩, 泽德,以及 克劳德桌面版
特性
- 🔍 代码库分析:立即了解整个代码库结构
- 💥 爆炸半径:查看任何函数或类的更改会影响哪些代码
- 🔎 智能搜索:按名称查找函数、类和变量
- 🤖 人工智能原生:与IDE的AI助手无缝协作-只需自然提问
快速开始
1.获取API密钥
注册地址: 坎特纳.dev 获取您的API密钥。
2.配置IDE
选择您的IDE并按照设置说明进行操作:
Cursor
添加到 .cursor/mcp.json (或全局配置位于 ~/Library/Application Support/Cursor/mcp.json 在Mac上):
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}重新启动Cursor,您就准备好了!
Windsurf
添加到 ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}重新启动Windsurf,您就准备好了!
VS Code (with Continue.dev)
添加到Continue.dev配置(~/.continue/config.json):
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Claude Desktop
添加到配置文件:
- 苹果电脑:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}重新启动克劳德桌面。
Cline
添加到临床MCP配置:
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}Zed
添加到Zed设置:
{
"language_models": {
"mcp_servers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
}3.开始使用它!
在任何代码库中打开IDE,只需提出问题:
- “这个代码库的结构是什么?”
- “显示所有函数和类”
- “如果我更改UserService类,还有什么会受到影响?”
- “查找与身份验证相关的所有功能”
- “什么取决于这个功能?”
AI将自动使用Cantena进行应答,无需特殊命令!
使用示例
了解您的代码库
You: What's in this codebase?
AI: [Uses Cantena automatically]
This codebase contains 127 functions, 23 classes, and 45 variables...影响分析
You: If I modify the authenticateUser function, what would break?
AI: [Uses Cantena blast radius tool]
Modifying authenticateUser would affect 12 other functions including...查找代码
You: Where is the login function defined?
AI: [Uses Cantena search]
The login function is defined in src/auth/login.ts at line 42...配置选项
环境变量
而不是通过 --api-key 每次设置环境变量:
export CANTENA_API_KEY=sk_live_abc123...
export CANTENA_API_URL=https://api.cantena.dev # Optional: custom API URL然后你的IDE配置变得更简单:
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": ["-y", "cantena-mcp"]
}
}
}自定义API URL
如果您是自托管或使用自定义Cantena实例:
{
"mcpServers": {
"cantena": {
"command": "npx",
"args": [
"-y",
"cantena-mcp",
"--api-key", "YOUR_API_KEY",
"--api-url", "https://your-custom-api.com"
]
}
}
}运作原理
- 文件发现:Cantena会自动发现存储库中的所有TypeScript和JavaScript文件
- 云分析:文件被发送到Cantena的API以生成图形(您的代码被安全地处理,而不是存储)
- 图形生成Cantena构建了一个全面的代码结构图
- 人工智能集成:IDE的AI可以查询此图以回答有关代码的问题
支持的文件类型
- TypeScript(
.ts,.tsx) - JavaScript(
.js,.jsx)
自动排除:
node_modules/- 构建目录(
build/,dist/,.next/) - 测试文件(
*.test.ts,*.spec.js)
隐私和安全
- 您的代码被发送到Cantena的API进行分析
- 代码是实时处理的,而不是永久存储的
- 所有通信均通过HTTPS加密
- 身份验证需要API密钥
故障排除
“需要API密钥”错误
确保您已经:
- 在cantna.dev注册并获得您的API密钥
- 将API密钥添加到IDE配置中
- 配置更改后重新启动IDE
“无缓存图形”消息
这很正常——Cantena会在你第一次提问时分析你的代码库。同一会话中的后续问题使用缓存的分析。
IDE中未显示工具
- 验证配置文件语法是否正确(有效的JSON)
- 确保在添加配置后重新启动IDE
- 检查IDE日志中的MCP连接错误
- 试着跑步
npx cantena-mcp --api-key YOUR_KEY手动测试
大型代码库耗时过长
Cantena分析你的整个代码库。对于非常大的项目(10000+个文件),初始分析可能需要30-60秒。后续查询使用缓存的图即时进行。
CLI使用情况
您也可以直接从命令行运行Cantena:
# With API key as argument
npx cantena-mcp --api-key sk_live_abc123...
# With environment variable
export CANTENA_API_KEY=sk_live_abc123...
npx cantena-mcp
# Show help
npx cantena-mcp --help
# Show version
npx cantena-mcp --version许可证
麻省理工学院
支持
- 文档: cantena.dev/docs
- 问题:
- 电子邮件:support@cantena.dev
