kje-mcp
kje-mcp
兼容 Claude.ai 的 MCP 服务器,它封装了 Jim Brain(持久化内存 + 帝国状态 + 保险库)以及 RackNerd VPS 上的 无头 Claude Code 调度器,因此任何 Claude.ai Web 会话都可以:
读取帝国的当前状态、项目和近期记忆,
搜索语义记忆和凭据保险库,
将快速日志和语义记忆写回 Brain,
在 VPS 上调度
claude -p构建会话。
该服务器使用 MCP Streamable HTTP(Claude.ai 的“自定义连接器”UI 所期望的传输方式)。它使用 无状态 / JSON 响应 模式,因此可以在任何支持普通 HTTP API 的地方运行——在本例中是 Railway。
公开的工具
工具 | 功能描述 | ||
| Brain | ||
| 对 Qdrant 记忆进行语义搜索 ( | ||
| 深度为 `minimal | standard | full |
| 自然语言凭据查找 ( | ||
| 快速 Supabase 日志 ( | ||
| 语义记忆写入 ( | ||
| 在 RackNerd VPS 上生成无头 |
所有工具都使用小写的 x-brain-key 请求头向 Brain 进行身份验证(这是 Brain 唯一接受的请求头——在 2026-04-27 BridgeDeck 调试中固化)。MCP 层本身在 Authorization 请求头中接受一个 Bearer 令牌——这就是 Claude.ai 连接器 UI 发送的内容。
文件布局
kje-mcp/
├── main.py # FastAPI + FastMCP server (deployed to Railway)
├── requirements.txt
├── railway.toml
├── .env.example
├── README.md
└── vps/
├── cc_dispatch_server.py # Companion dispatcher — runs on the RackNerd VPS
├── requirements.txt
└── kje-cc-dispatch.service # systemd unit1. 将 kje-mcp 部署到 Railway
1a. 将仓库推送到 GitHub
cd C:\Users\Jim\Documents\GitHub\kje-mcp
git add .
git commit -m "feat: kje-mcp v1.0.0 — Claude.ai MCP wrapper for Jim Brain + CC dispatch"
gh repo create jharriGH/kje-mcp --public --source=. --remote=origin --push1b. 创建 Railway 服务
# from inside the kje-mcp dir
railway init # name it: kje-mcp
railway link # link to the new project
railway up # builds + deploys或者通过仪表板:New Project → Deploy from GitHub Repo → jharriGH/kje-mcp。Railway 会自动检测 Nixpacks Python 并使用 railway.toml 中的 startCommand。
1c. 设置环境变量
railway variables --set BRAIN_KEY=jim-brain-kje-2026-kingjames
railway variables --set BRAIN_URL=https://jim-brain-production.up.railway.app
railway variables --set MCP_AUTH_KEY=jim-brain-kje-2026-kingjames
# OPTIONAL — only set these once the VPS dispatcher is up (step 2):
# railway variables --set VPS_DISPATCH_URL=https://cc.kj.empire/dispatch
# railway variables --set VPS_DISPATCH_KEY=<long-random-string>根据 ENV VAR AUTOMATION RULE,由 Claude Code 驱动此操作——Jim 从不点击 Railway 仪表板。
1d. 验证部署
# replace <host> with the Railway-assigned URL (railway domain or your custom one)
curl -s https://<host>/health | jq
# expect: {"status":"ok","service":"kje-mcp",...,"vps_dispatch_configured":false,...}
# initialize handshake (Claude.ai will send the same)
curl -s -X POST https://<host>/mcp/ \
-H "Authorization: Bearer jim-brain-kje-2026-kingjames" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"curl","version":"1"}}}' | jq
# list tools
curl -s -X POST https://<host>/mcp/ \
-H "Authorization: Bearer jim-brain-kje-2026-kingjames" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | jq '.result.tools[].name'
# expect 7 names: brain_status, brain_search, brain_get_project, brain_vault_search,
# brain_log, brain_memory, cc_dispatch2. 从 Claude.ai Web 连接
打开 claude.ai → Settings → Connectors → Add custom connector。
Name:
KJE MCP。URL:
https://<your-railway-host>/mcp/(注意末尾的斜杠和/mcp/路径)。Auth:
API key / Bearer token→ 粘贴jim-brain-kje-2026-kingjames(或您设置的MCP_AUTH_KEY)。Save。Claude.ai 执行 MCP
initialize+tools/list握手;如果“KJE MCP”旁边出现绿色勾号,则 7 个工具在聊天中可用。
在任何新的 Claude.ai 对话中:
打开对话的工具/连接器菜单并切换 KJE MCP 为开启状态。
以
brain_session_start的等效内容开始您的提示词:"Use KJE MCP. Call
brain_statusandbrain_get_projectforkj_codedeck(depth=standard) before answering. Then [task]."
当您结束时,Claude.ai 将通过同一个连接器执行结束仪式——使用 brain_memory 进行总结,使用 brain_log 记录进度,如果需要在 VPS 上继续构建工作,则使用 cc_dispatch。
3. (可选) 为 cc_dispatch 搭建 VPS 调度器
如果不执行此操作,cc_dispatch 将返回一个干净的 cc_dispatch_not_configured 错误,其他六个工具可以正常工作。当您确实希望 Claude.ai 在 VPS 上启动 CC 会话时,请进行设置。
3a. 将 vps/ 文件夹同步到 104.223.120.21
# from your laptop, in the kje-mcp repo
scp -r vps/ jim@104.223.120.21:/home/jim/kje-mcp/3b. 在 VPS 上创建 venv 并安装依赖
ssh jim@104.223.120.21
cd /home/jim/kje-mcp
python3 -m venv .venv
.venv/bin/pip install -r vps/requirements.txt3c. 配置 .env
cat > /home/jim/kje-mcp/vps/.env <<'EOF'
VPS_DISPATCH_KEY=<long-random-string-paste-same-on-railway>
BRAIN_URL=https://jim-brain-production.up.railway.app
BRAIN_KEY=jim-brain-kje-2026-kingjames
PROJECT_REPOS_BASE=/home/jim/repos
# Optional overrides for slugs whose repo dir name differs from the slug:
# PROJECT_REPOS_OVERRIDES={"kj_autonomous":"/home/jim/n8n-canvas/kj-autonomous"}
CLAUDE_BIN=/usr/local/bin/claude
DISPATCH_LOG_DIR=/var/log/kje-cc-sessions
EOF
sudo mkdir -p /var/log/kje-cc-sessions
sudo chown jim:jim /var/log/kje-cc-sessions3d. 安装并启动 systemd 单元
sudo cp /home/jim/kje-mcp/vps/kje-cc-dispatch.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now kje-cc-dispatch
sudo systemctl status kje-cc-dispatch
curl -s http://127.0.0.1:8088/health3e. 使用 TLS 公开 (nginx + Let's Encrypt)
# /etc/nginx/sites-available/cc.kj.empire
server {
listen 443 ssl http2;
server_name cc.kj.empire;
ssl_certificate /etc/letsencrypt/live/cc.kj.empire/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cc.kj.empire/privkey.pem;
client_max_body_size 4m;
proxy_read_timeout 65s;
location /dispatch {
proxy_pass http://127.0.0.1:8088/dispatch;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Dispatch-Key $http_x_dispatch_key;
}
location /health {
proxy_pass http://127.0.0.1:8088/health;
}
}sudo ln -s /etc/nginx/sites-available/cc.kj.empire /etc/nginx/sites-enabled/
sudo certbot --nginx -d cc.kj.empire
sudo nginx -t && sudo systemctl reload nginx3f. 将 kje-mcp 服务连接到它
# from the kje-mcp repo on your laptop
railway variables --set VPS_DISPATCH_URL=https://cc.kj.empire/dispatch
railway variables --set VPS_DISPATCH_KEY=<same-random-string>
railway redeploykje-mcp 服务上的 /health 现在应该显示 "vps_dispatch_configured": true。
Claude.ai 会话如何端到端地使用此功能
会话开始。 开启连接器。Claude.ai 调用
brain_status→ 获取帝国上下文,然后调用brain_get_project("kj_codedeck", "standard")→ 注入提示词。工作进行中。 Claude.ai 根据聊天中的推理进行回答。在过程中,它会调用
brain_search来获取之前的决策,或调用brain_vault_search来获取它需要讨论的凭据。繁重工作。 当工作需要真正的 CC 构建会话时,Claude.ai 调用
cc_dispatch(project="kj_codedeck", prompt="<full build prompt>")。VPS 调度器立即以session_id确认。CC 会话在后台运行。移交。 当 CC 会话完成时,VPS 调度器向 Brain
/codedeck/handoff发布移交(快速日志 + 项目 next_action 更新 + 如果触及 3 个以上文件则生成构建卡片 + 排队语义记忆)。下一个 Claude.ai 会话通过brain_search看到它。结束仪式。 Claude.ai 调用
brain_memory(完整总结)、brain_log(进度事件),构建卡片保存通过移交在服务器端自动完成。不要问 Jim “选哪个?”——这就是规则。
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Cloud-hosted MCP server for durable AI memory
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
- mcpOAuthai.butlerbrain
Persistent memory for AI assistants. Save once; recall from Claude, ChatGPT, or any MCP client.