Expanso MCP服务器
用于Expanso文档语义搜索和检索的模型上下文协议(MCP)服务器。部署在Cloudflare Workers上,使用Vectorize进行矢量搜索。
特性
- 语义搜索:使用自然语言查询文档
- MCP协议:与Claude、ChatGPT和其他AI助手兼容
- 多域:在扩展.io、docs.expansio.io、docs.bacalhau.org、examples.expansion.io中搜索
- HTTP API:用于自定义集成的API直接访问
- 边缘部署:通过Cloudflare的全球网络实现低延迟
建筑
┌─────────────────────────────────────────────────────────────┐
│ Cloudflare Workers │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────────┐ │
│ │ HTTP API │ │ MCP Protocol │ │ Resource Handler │ │
│ └──────┬──────┘ └──────┬───────┘ └────────┬──────────┘ │
│ │ │ │ │
│ └────────────────┼────────────────────┘ │
│ │ │
│ ┌───────────────────────▼───────────────────────────────┐ │
│ │ Search Handler │ │
│ └───────────────────────┬───────────────────────────────┘ │
│ │ │
│ ┌────────────────┼────────────────┐ │
│ ▼ ▼ ▼ │
│ ┌────────────┐ ┌────────────────┐ ┌─────────────┐ │
│ │ Workers AI │ │ Vectorize │ │ KV Cache │ │
│ │ (Embeddings)│ │ (Vector Store) │ │ (Content) │ │
│ └────────────┘ └────────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘设置
先决条件
- Cloudflare帐户 采用工人付费计划(适用于Vectorize)
- 牧马人CLI
- Node.js 18+
安装
cd mcp-server
npm install创建Cloudflare资源
# Login to Cloudflare
wrangler login
# Create KV namespace for content cache
wrangler kv namespace create CONTENT_CACHE
# Update wrangler.toml with the returned ID
# Create Vectorize index
wrangler vectorize create expanso-docs --dimensions=768 --metric=cosine索引内容
# Set environment variables
export CLOUDFLARE_ACCOUNT_ID=your-account-id
export CLOUDFLARE_API_TOKEN=your-api-token
# Run indexer
npm run index部署
# Deploy to production
npm run deploy
# Or development
npm run devapi参考
HTTP API
搜索文档
GET /api/search?q=&limit=&domain=参数:
q(必填):搜索查询limit(可选):最大结果(默认值:5,最大值:20)domain(可选):按域筛选
例子:
curl "https://mcp.expanso.io/api/search?q=circuit+breaker+pattern&limit=3"列出资源
GET /api/resources返回所有可用的文档资源。
获取资源内容
GET /api/resources/例子:
curl "https://mcp.expanso.io/api/resources/https%3A%2F%2Fdocs.expanso.io%2Fllms%2Fgetting-started.txt"MCP协议
服务器实现MCP协议版本2024-11-05。
工具
- search_docs:文档语义搜索
- query (字符串,必填):搜索查询 - limit (数字,可选):最大结果 - domain (字符串,可选):按域筛选
- 获取资源:检索资源的完整内容
- uri (字符串,必填):资源URI
- 列表_资源:列出所有可用资源
MCP请求示例
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_docs",
"arguments": {
"query": "how to configure circuit breakers",
"limit": 5
}
}
}配置
克劳德桌面版
添加 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"expanso-docs": {
"url": "https://mcp.expanso.io/mcp"
}
}
}自定义集成
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
const client = new Client({
name: 'my-app',
version: '1.0.0',
});
await client.connect({
url: 'https://mcp.expanso.io/mcp',
});
const results = await client.callTool('search_docs', {
query: 'kafka to snowflake pipeline',
});发展
# Start local dev server
npm run dev
# Run tests
npm test
# View logs
npm run tail已索引的域名
| 域 | 内容 |
|---|---|
| expano.io | 产品概述、行业、用例 |
| docs.expanso.io | 平台文档、CLI、组件 |
| docs.bacalhau.org | bacalhau分布式计算文档 |
| examples.expanso.io | 生产就绪管道示例 |
许可证
麻省理工学院
