cdn mcp服务器
MCP服务器与内部CDN文档交互。
目标
提供模型上下文协议工具,以允许:
- 在完整的CDN文档中搜索术语
- 探索特定组件(CDN-Action-Runner、CDN-AD-Server-Mock等)
- 列出可用组件
- 获取特定文档的内容
- 搜索DTS(设计和技术规范)文件
- 搜索Wiki文档
文件存放在:
http://cdn-docs.cdn.hi.inet/cdn/repositories//docs/components/可用工具
1. search_cdn_docs
在所有CDN文档中进行一般搜索。
参数:
query(字符串,必填):要搜索的术语version(字符串,可选):文档版本(默认:25.11.100)
示例:
{"query": "cdn-build", "version": "25.11.100"}2. list_cdn_components
列出所有可用的CDN组件。
参数:
version(字符串,可选):文档版本(默认:25.11.100)
示例:
{"version": "25.11.100"}结果: 具有组件名称的数组,例如 ["cdn-action-runner", "cdn-ad-server-mock", "cdn-alto", ...]
3. search_cdn_component
搜索特定组件或探索其结构。
参数:
component(字符串,必填):组件名称(例如:cdn-action-runner)query(字符串,可选):要搜索的术语。如果省略,则返回组件的结构version(字符串,可选):文档版本(默认:25.11.100)
示例:
// Buscar "makefile" en cdn-action-runner
{"component": "cdn-action-runner", "query": "makefile"}
// Explorar estructura de cdn-ad-server-mock
{"component": "cdn-ad-server-mock"}4. get_cdn_doc
获取特定文档的完整内容。
参数:
component(字符串,必填):组件名称path(字符串,可选):文件路径(默认:index.adoc)version(字符串,可选):文档版本(默认:25.11.100)
示例:
// Obtener index principal de cdn-action-runner
{"component": "cdn-action-runner", "path": "index"}
// Obtener guía de desarrollo
{"component": "cdn-action-runner", "path": "includes/development_guide"}
// Obtener docs de makefile
{"component": "cdn-action-runner", "path": "code-docs/makefile/index"}5. search_dts
搜索位于 cdn-documentation/dts.
参数:
query(字符串,可选):要搜索的术语。如果省略,请列出可用的结构version(字符串,可选):文档版本(默认:25.11.100)
示例:
// Buscar "design" en DTS
{"query": "design"}
// Listar toda la estructura de DTS
{}6. search_wiki
搜索位于 cdn-documentation/wiki.
参数:
query(字符串,可选):要搜索的术语。如果省略,请列出可用的结构version(字符串,可选):文档版本(默认:25.11.100)
示例:
// Buscar "architecture" en Wiki
{"query": "architecture"}
// Listar toda la estructura de Wiki
{}结构
src/index.ts:带有6个工具的主MCP服务器package.json:依赖项和脚本tsconfig.json:TypeScript配置
安装
cd mcp-servers-manu
npm install执行(独立)
npm start服务器根据MCP通过STDIO进行通信。您必须在您的配置中注册它 mcp.json VS代码/GitHub副驾驶。
环境变量
CDN_DOCS_BASE_URL(opcial)默认值:http://cdn-docs.cdn.hi.inet/cdn/repositoriesCDN_DOCS_VERSION(opcial)默认值:25.11.100
配置示例 .vscode/mcp.json
{
"servers": {
"cdn-docs-search": {
"command": "npm",
"args": ["start"],
"cwd": "${workspaceFolder}/mcp-servers-manu",
"env": {
"CDN_DOCS_BASE_URL": "http://cdn-docs.cdn.hi.inet/cdn/repositories",
"CDN_DOCS_VERSION": "25.11.100"
}
}
}
}实施的改进(v0.2.0)
🎯 优化搜索
- 组件缓存: 组件列表缓存1小时以更快地搜索
- 重点搜索: 用于搜索特定组件的专用工具
- 改进的提取: 用于呈现ASCIIDOC的更精确的HTML选择器
📚 结构探索
- 动态列出可用组件
- 在不需要查询的情况下探索每个组件的结构
- 获取特定文档的完整内容
🔍 丰富的元数据
- 结果包括文件部分
- 可用时提取的目录
- 标准化和绝对URL
推荐工作流
- 发现组件:
{"tool": "list_cdn_components"}- 探索组件结构:
{"tool": "search_cdn_component", "component": "cdn-action-runner"}- 搜索特定术语:
{"tool": "search_cdn_component", "component": "cdn-action-runner", "query": "makefile"}- 阅读完整文件:
{"tool": "get_cdn_doc", "component": "cdn-action-runner", "path": "code-docs/makefile/index"}测试-脚本 test-mcp.ts
档案馆 test-mcp.ts 它允许直接测试MCP,而无需将其集成到VS Code或GitHub Copilot中。
安装依赖项
npm install使用测试脚本
Sintaxi概述:
npx tsx test-mcp.ts [args-json]使用示例
1.列出所有可用组件:
npx tsx test-mcp.ts list_cdn_components
# O especificar versión
npx tsx test-mcp.ts list_cdn_components '{"version":"25.11.100"}'2.寻找特定组件:
# Explorar estructura de cdn-action-runner
npx tsx test-mcp.ts search_cdn_component '{"component":"cdn-action-runner"}'
# Buscar documentos con "makefile" en cdn-action-runner
npx tsx test-mcp.ts search_cdn_component '{"component":"cdn-action-runner","query":"makefile"}'3.在所有文档中进行全球搜索:
npx tsx test-mcp.ts search_cdn_docs '{"query":"makefile"}'
# Con versión específica
npx tsx test-mcp.ts search_cdn_docs '{"query":"docker","version":"25.11.100"}'测试环境变量
您可以使用环境变量自定义行为:
# Especificar URL base diferente
export CDN_DOCS_BASE_URL="http://custom-url/cdn/repositories"
# Especificar versión por defecto
export CDN_DOCS_VERSION="25.9.100"
npx tsx test-mcp.ts list_cdn_components退出脚本
每个命令都返回以结果格式设置的JSON:
{
"version": "25.11.100",
"count": 42,
"components": ["cdn-action-runner", "cdn-ad-server-mock", ...]
}解决问题
- 连接超时: 通过修改中的常量来增加超时
test-mcp.ts或验证连接到cdn-docs.cdn.hi.inet - 404未找到: 验证组件是否存在
list_cdn_components - JSON 解析错误 : 确保正确转义JSON中的引号
未来扩展
可能的其他改进:
- 使用嵌入的语义搜索
- 用于更快搜索的倒排索引
- 提取Plantuml图表
- 组件之间的依赖性分析
- 支持多个同时版本
技术说明
- HTML提取被优化为将ASCIIDOC转换为HTML
- 选择器优先
.toc,.sect1,.sect2典型的海鞘 - 每个HTTP请求超时8秒
- 文件内容限制为5000个字符,以避免过载
