云托管文档MCP服务器
一种模型上下文协议(MCP)服务器,提供对Cloud Custodian文档的语义搜索和全文访问。使用FastMCP和SQLite FTS5构建,用于高性能文档检索。
特性
- 全文搜索 使用SQLite FTS5进行BM25排名
- 分段过滤 云提供商(AWS、Azure、GCP、Kubernetes、OCI)
- 预构建的Docker镜像 带有索引文档
- 快速查询 有词干支持(例如,“策略”匹配“策略”)
- 完整的文档访问权限 包括示例和API参考文献
快速开始
使用Docker(推荐)
Docker镜像包括预索引的Cloud Custodian文档:
docker pull mcp-cloudcustodian-documentation
docker run -i --rm mcp-cloudcustodian-documentation使用紫外线
# Clone repository
git clone https://github.com/martoc/mcp-cloudcustodian-documentation
cd mcp-cloudcustodian-documentation
# Initialise environment
make init
# Build documentation index
make index
# Run server
make runMCP客户端配置
添加到您的MCP客户端设置中(例如,Claude Desktop):
Docker配置
{
"mcpServers": {
"cloud-custodian-documentation": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp-cloudcustodian-documentation"]
}
}
}本地安装配置
{
"mcpServers": {
"cloud-custodian-documentation": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-cloudcustodian-documentation",
"run",
"mcp-cloudcustodian-documentation"
]
}
}
}可用工具
搜索文档
按关键字查询搜索云托管文档。
参数:
query(字符串,必填):支持词干的搜索词section(字符串,可选):按部分筛选
- 常见部分: aws, azure, gcp, kubernetes, oci, quickstart, developer, tools
limit(整数,可选):最大结果(默认值:10,最大值:50)
例子:
{
"query": "s3 bucket encryption policy",
"section": "aws",
"limit": 5
}read_文档
阅读特定文档页面的完整内容。
参数:
path(string,必填):搜索结果的相对路径(例如。,aws/examples/s3.rst)
例子:
{
"path": "aws/examples/s3.rst"
}CLI命令
索引文档
# Build index from GitHub (default: main branch)
uv run cloud-custodian-docs-index index
# Rebuild index (clear and reindex)
uv run cloud-custodian-docs-index index --rebuild
# Index specific branch
uv run cloud-custodian-docs-index index --branch main显示统计信息
uv run cloud-custodian-docs-index stats发展
需求
- Python 3.12+
- 紫外线0.5.0+
- Git
设置
# Initialise environment
make init
# Run tests
make test
# Run full build (lint, typecheck, test)
make build
# Format code
make format项目结构
mcp-cloudcustodian-documentation/
├── src/mcp_cloudcustodian_documentation/
│ ├── server.py # FastMCP server with tools
│ ├── database.py # SQLite FTS5 database
│ ├── parser.py # RST document parser
│ ├── indexer.py # Git repository indexer
│ ├── cli.py # CLI commands
│ └── models.py # Data structures
├── tests/ # pytest test suite
├── data/ # SQLite database (gitignored)
├── pyproject.toml # Dependencies and configuration
├── Makefile # Build automation
└── Dockerfile # Container with pre-built index建筑
RST文档解析
Cloud Custodian文档使用reStructuredText(RST)格式。解析器:
- 用途
docutils将RST解析为文档树 - 使用访问者模式提取元数据(标题、描述)
- 提取可搜索的文本内容(不包括代码块)
- 从文件路径生成cloudcustodian.io URL
搜索实施
- SQLite FTS5 使用波特词干进行全文搜索
- BM25排名 调整权重(标题:5.0,描述:2.0,内容:1.0)
- 章节索引 用于云提供商的快速过滤
- 代码段生成 带有突出显示的匹配项
数据流
GitHub Repo → Git Sparse Checkout → RST Parser → SQLite FTS5 → FastMCP Server测试
# Run all tests with coverage
make test
# Run specific test file
uv run pytest tests/test_parser.py
# Run with verbose output
uv run pytest -vv码头工人
塑造形象
make docker-build构建过程:
- 使用uv安装依赖项
- 克隆云托管库(仅限文档)
- 将所有RST文件编入SQLite数据库
- 使用预构建索引创建图像(约195个文档)
运行容器
make docker-run故障排除
找不到数据库
运行索引器以构建数据库:
make indexGit克隆失败
确保git已安装并且您具有网络访问权限:
git --version搜索未返回任何结果
重建索引:
uv run cloud-custodian-docs-index index --rebuild文档
许可证
MIT许可证-见 许可证 文件以获取详细信息。
贡献
欢迎捐款。请确保:
- 所有测试均通过(
make test) - 代码已格式化(
make format) - 类型检查通过(
make typecheck) - 测试覆盖率保持在80%以上
