Skip to main content
Glama
deekshu05

MCP Runbook Search Server

by deekshu05

MCP Runbook 搜索服务器

一个模型上下文协议(MCP)服务器,将一组内部工程 runbook 的语义搜索暴露为工具——这样 Claude Desktop、兼容 MCP 的 IDE 或自定义代理就可以问"我们如何处理数据库故障转移?"并得到正确的 runbook,而不是有人去 wiki 里翻找。

概述

MCP 标准化了 LLM 客户端如何发现并调用由独立服务器进程通过 stdio 或 HTTP 暴露的工具。该服务器为这一协议实现了一个具体、真实的用例:让任何 MCP 客户端都能查询内部知识库(runbook、事后分析、playbook),而无需为每个客户端编写自定义集成。

服务器暴露三个工具:

  • search_runbooks(query, top_k) — 对 runbook 语料库进行语义搜索,按余弦相似度排序。

  • get_runbook(doc_id) — 按 id 获取单个 runbook 的全文。

  • list_runbooks() — 列出所有已索引 runbook 的 id 和标题。

主要特性

  • 真实的 MCP 协议,而非模拟 — 基于官方 mcp Python SDK 的 FastMCP 服务器构建,并通过真实的 ClientSession 通过 stdio 连接进行端到端验证(见下方示例运行)——而不仅仅是对底层函数的单元测试。

  • 无依赖的语义搜索 — 哈希嵌入器将每个文档转换为固定大小的向量,无需外部模型、API 密钥或网络调用,因此服务器完全离线运行。这些向量上的余弦相似度按含义对结果进行排序,而不仅仅是关键词重叠。

  • 工具逻辑与传输层解耦src/tools.py 保存对 Corpus 的普通函数,可独立进行单元测试;src/server.py 仅将这些函数接入 MCP 工具装饰器。将 stdio 换成 HTTP 传输,或将语料库换成真实的文档存储,都不会触及工具逻辑。

  • 清晰的错误处理get_runbook 对未知 id 返回结构化的 {"error": ...} 负载而不是抛出异常,因此客户端无论哪种情况都能得到可操作的响应。

架构

MCP client (Claude Desktop, IDE, custom agent)
        │  stdio / JSON-RPC
        ▼
 FastMCP server (src/server.py)
        │  registers tools
        ▼
 tools.py  ──▶  Corpus (src/corpus.py)
                  │
                  ▼
          hashing embedder + cosine similarity
                  │
                  ▼
          5 sample engineering runbooks

技术栈

工具

语言

Python

协议

模型上下文协议(mcp Python SDK,FastMCP

搜索

无依赖哈希嵌入器 + 余弦相似度

CI/CD

GitHub Actions

项目结构

.
├── src/
│   ├── corpus.py    # Hashing embedder, Corpus, sample runbook documents
│   ├── tools.py      # Pure tool functions (search / get / list)
│   └── server.py     # FastMCP server wiring tools.py into MCP tool decorators
├── tests/
│   ├── test_corpus.py
│   └── test_tools.py
├── .github/workflows/ci.yml
├── Dockerfile
├── requirements.txt
└── README.md

快速开始

前置条件

  • Python 3.10+

安装

git clone https://github.com/deekshu05/mcp-document-search-server.git
cd mcp-document-search-server
pip install -r requirements.txt

运行服务器

python -m src.server

这会在 stdio 上启动服务器,等待 MCP 客户端连接。

从 Claude Desktop 连接

将此添加到你的 claude_desktop_config.json

{
  "mcpServers": {
    "runbook-search": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/mcp-document-search-server"
    }
  }
}

重启 Claude Desktop,search_runbooksget_runbooklist_runbooks 就会成为 Claude 可以在对话中直接调用的工具。

使用 Docker 运行

docker build -t mcp-runbook-server .
docker run -i mcp-runbook-server

示例运行

Python MCP 客户端通过 stdio 连接到此服务器并调用其工具的真实输出——而非模拟记录:

Tools exposed: ['search_runbooks', 'get_runbook', 'list_runbooks']

search_runbooks('the primary database node is not responding'):
{
  "doc_id": "rb-001",
  "title": "Database failover procedure",
  "snippet": "Database failover procedure. When the primary Postgres node becomes
  unresponsive, promote the standby replica using the orchestrator's promote
  command, update the connection endpoint in the service config map, and verify",
  "score": 0.439
}
{
  "doc_id": "rb-003",
  "title": "Deploy rollback procedure",
  "snippet": "Deploy rollback procedure. If error rates exceed the alert
  threshold within ten minutes of a deploy, trigger the automated rollback to
  the previous stable image tag, confirm the health checks pass on all
  replicas, and po",
  "score": 0.3208
}

get_runbook('rb-001'):
{
  "doc_id": "rb-001",
  "title": "Database failover procedure",
  "text": "Database failover procedure. When the primary Postgres node becomes
  unresponsive, promote the standby replica using the orchestrator's promote
  command, update the connection endpoint in the service config map, and
  verify replication lag has dropped to zero on the new primary before
  resuming writes. Page the on-call DBA if promotion does not complete within
  five minutes."
}

查询从未提及"Postgres"或"故障转移"——它只是对症状的平实描述——而搜索仍然按含义而非关键词匹配将正确的 runbook 排在第一位,并且有一个真实的第二结果(回滚流程),它确实是最相关的下一个 runbook。

影响

这样的模式将原本需要有人知道该搜索哪个 wiki 页面的内部知识库,转变为任何兼容 MCP 的 AI 助手都可以直接查询和引用的东西,缩短了从"事件开始"到"正确的 runbook 出现在响应者面前"之间的时间。

路线图

  • 在针对更大语料库运行时,将哈希嵌入器替换为真实的嵌入模型

  • 在 stdio 之外增加可流式 HTTP 传输,用于远程 MCP 客户端

  • 写穿式索引,使新 runbook 无需重启服务器即可添加

  • 认证范围划分,使不同 MCP 客户端看到语料库的不同子集

许可证

MIT

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Knowledge coverage map and health score. Ingest docs into a governed knowledge graph via MCP.

  • Read-only MCP connector serving the Run It on AI book; index and Implementation Blocks are free.

  • Query any docs site via MCP. Submit a URL, ask questions, get cited answers.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deekshu05/mcp-document-search-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server