使用说明
TabbyML MCP服务器
MCP服务器桥将TabbyML连接到AI助手,用于搜索和理解任何代码库。
先决条件
- TabbyML在本地运行(默认值:http://localhost:8080)
- TabbyML身份验证令牌
- Python 3.12+
- uv包管理器
设置
# Clone and install
git clone https://github.com/cbusillo/tabby-mcp-server.git
cd tabby-mcp-server
uv sync --all-groups
# Set up your TabbyML token (optional - can also pass via MCP config)
echo "TABBY_TOKEN=your_tabby_token_here" > .env
使用Claude CLI快速设置
# Add the MCP server to Claude Code
claude mcp add-json tabby-mcp-server '{
"command": "uv",
"args": ["run", "--directory", "/path/to/tabby-mcp-server", "tabby-mcp-server"],
"env": {
"TABBY_TOKEN": "your_tabby_token_here",
"TABBY_URL": "http://localhost:8080"
}
}'
# If using absolute path to uv (recommended)
claude mcp add-json tabby-mcp-server '{
"command": "/opt/homebrew/bin/uv",
"args": ["run", "--directory", "/path/to/tabby-mcp-server", "tabby-mcp-server"],
"env": {
"TABBY_TOKEN": "your_tabby_token_here"
}
}'
环境变量
TABBY_TOKEN- 必需:您的TabbyML身份验证令牌TABBY_URL-可选:TabbyML服务器URL(默认值:http://localhost:8080)
工具
list_repositories-列出TabbyML中索引的所有存储库search_code-在索引存储库中搜索代码模式chat_with_context-使用存储库上下文与TabbyML AI聊天search_documentation-在文档存储库中搜索信息
发展
uv run test # Run tests
uv run format # Format code
uv run lint # Lint code
uv run update-graphql # Update GraphQL client from TabbyML
更新GraphQL客户端
当TabbyML更新其GraphQL模式或您修改查询时:
# Fetch latest schema and regenerate client code
uv run update-graphql
# This command will:
# 1. Fetch the latest schema from TabbyML
# 2. Convert it to GraphQL SDL format
# 3. Generate typed Python client code
# 4. Update src/tabby_mcp_server/graphql_client/
备注:确保TabbyML正在运行 TABBY_TOKEN 在更新之前设置。
运行集成测试
集成测试需要一个正在运行的TabbyML实例:
# Skip integration tests (default)
uv run test
# Run all tests including integration tests
TABBY_TOKEN=your_token pytest tests/test_integration.py -v
# Run specific integration test
TABBY_TOKEN=your_token pytest tests/test_integration.py::TestTabbyIntegration::test_real_tabby_connection -v
集成测试标记为 @pytest.mark.skipif 并且在以下情况下将被跳过:
- TabbyML未运行
TABBY_TOKEN未设置- 与TabbyML的连接失败
可选:Git预提交钩子
创建 .git/hooks/pre-commit:
#!/bin/bash
set -e
uv run format
uv run lint
uv run test
然后: chmod +x .git/hooks/pre-commit
需求
- TabbyML在本地运行(默认值:http://localhost:8080)
- Python 3.12+(兼容3.13)
- 紫外线
文档代理
tabby-mcp服务器包括一个内置的文档代理,用于解决多语言文档站点的TabbyML超时问题。看 DOC_PROXY.md 了解详情。
# Start proxy for any documentation site
uv run tabby-doc-proxy --url https://docs.example.com/
# Configure TabbyML to use: http://localhost:8888/
您项目的CLAUDE.md示例
将此添加到项目的CLAUDE.md中,以利用TabbyML进行代码理解:
# CLAUDE.md
Project instructions for AI assistance.
## Available Tools
### TabbyML Integration
When working with this codebase, use the TabbyML MCP tools:
- `list_repositories` - View all indexed repositories
- `search_code` - Search for patterns, classes, methods in the codebase
- `chat_with_context` - Ask questions about the code with repository context
- `search_documentation` - Search in documentation repositories
## Code Search Strategy
1. **Before making changes**:
- Use `search_code` to find similar implementations
- Use `chat_with_context` to understand complex code sections
- Use `search_documentation` for API references and guides
2. **Understanding existing code**:
- List repositories to see what's available
- Search for usage patterns before implementing new features
- Ask contextual questions about specific repositories
## Example Workflow
When implementing a new feature:
1. First use `list_repositories` to see available codebases
2. Use `search_code` to find similar implementations
3. Use `chat_with_context` to understand the patterns
4. Check `search_documentation` for best practices
5. Implement following the discovered patterns
