MCP Knowledge Bridge
README.md
# MCP Knowledge Bridge
手写、可教学的 MCP **子集**实现。v0.3.0 在 stdio 上支持 `2025-11-25` 协议协商,以及 tools / resources / prompts / ping 与初始化生命周期。体积刻意保持小,**不是**完整 MCP SDK,也不是生产网关。
[](https://www.python.org/)
[](LICENSE)
## 安装与运行
```bash
python -m pip install -e ".[dev]"
python -m examples.demo_protocol
python -m mcp_bridge.server
```
stdio 传输:每行一条 UTF-8 JSON-RPC(非 `Content-Length` 分帧)。
```bash
mcp-knowledge-bridge
```
### Cursor 配置示例
```json
{
"mcpServers": {
"knowledge-bridge": {
"command": "python",
"args": ["-m", "mcp_bridge.server"],
"cwd": "/absolute/path/to/mcp-knowledge-bridge"
}
}
}
```
## 自研 REST companion
`mcp_bridge.http_server` 是带鉴权的 **自定义 REST 伴生服务**。
它**不是** MCP Streamable HTTP,也不实现 MCP-over-HTTP / OAuth。
```bash
export MCP_BRIDGE_TOKEN="replace-with-a-secret"
mcp-knowledge-bridge-rest
curl -H "Authorization: Bearer replace-with-a-secret" http://127.0.0.1:8765/tools
```
PowerShell:
```powershell
$env:MCP_BRIDGE_TOKEN = "replace-with-a-secret"
```
## 范围
已实现:`initialize`、`notifications/initialized`、`ping`、`tools/list`、`tools/call`、`resources/list`、`resources/read`、`prompts/list`、`prompts/get`。
未声称:sampling、roots、elicitation、subscriptions、Streamable HTTP 等。
## 开发
```bash
python -m ruff check .
python -m pytest --cov=mcp_bridge --cov-report=term-missing
```
MIT © Brian20040323
TDQS
B3.2/5.0
Scored across 4 tools
Disambiguation5/5
Each tool has a clearly distinct purpose: search, fetch by ID, compare two topics, and a debug echo. No overlap in functionality.
Naming Consistency3/5
Three tools follow the 'kb_' prefix with verbs, but 'echo_debug' breaks the pattern by omitting the prefix. Mixed conventions reduce consistency.
Tool Count5/5
Four tools is well within the typical 3-15 range and feels appropriate for a focused knowledge bridge server.
Completeness2/5
Only read and compare operations are present. Missing create, update, and delete for knowledge entries, which are essential for managing a knowledge base.
Maintenance
ActivitySlowing
ResponsivenessNo issues