使用说明
光标链接MCP服务器
用于Cursor IDE的自定义MCP(模型上下文协议)服务器,具有:
- 🌐 网络搜索 -深度网络搜索使用 API链接
- 📚 RAG(检索增强生成) -使用Ollama的LlamaIndex查询文档
✨ 主要特点
- ✅ 本地AI -使用Ollama(llama3.2)实现完全隐私
- ✅ API成本为零 -RAG工具完全免费(使用本地模型)
- ✅ 来源引用 -知道答案从哪里来
- ✅ 多种文档类型 -支持PDF、DOCX、MD、TXT等格式
- ✅ 光标集成 -在Cursor IDE中无缝工作
📋 先决条件
🚀 快速开始
1.克隆和安装依赖项
git clone https://github.com/RanneG/linkup_mcp.git
cd linkup_mcp
uv sync
默认安装 (uv sync / pip install -e .)是 光标MCP+RAG 只有(更轻的venv)。对于 stitch_rag_bridge.py、face/Outh/Gmail和服务器端语音STT,添加 --extra stitch-bridge.为 十一实验室 语音/音乐资产生成(elevenlabs-gen CLI),添加 --extra elevenlabs --看 docs/elevenlabs/README.md.
2.安装Ollama&Model
# Download from https://ollama.ai/download
# Then pull the model:
ollama pull llama3.2
3.配置环境(可选)
创建一个 .env 用于网络搜索的文件(RAG在没有API密钥的情况下工作):
LINKUP_API_KEY=your_linkup_api_key # Optional, for web_search tool
4.配置光标
添加 ~/.cursor/mcp.json (或 C:\Users\<username>\.cursor\mcp.json 在Windows上):
{
"mcpServers": {
"linkup-server": {
"command": "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe",
"args": [
"-m", "uv", "run",
"--directory", "C:\\path\\to\\linkup_mcp",
"python", "server.py"
]
}
}
}
替换 YOUR_USERNAME 并按照你的实际价值观走下去。
5.免费本地开发端口(可选)
如果 8765 (缝合桥/捆绑UI), 1420 (Tauri),或 5173 (Vite)撞车后卡住了,跑吧 Close-DevPorts.bat 在repo根目录(或 .\scripts\Close-StitchDevPorts.ps1).使用 -DryRun 列出听众而不杀人。这停止了 在这些端口上侦听的进程,而不是“localhost”本身。
6.重新启动游标并使用!
在Cursor的聊天中:
- “使用抹布工具告诉我[主题]”
- “使用rag_stritch工具获取UI就绪应答有效负载”
- “在网上搜索[query]” (需要Linkup API密钥)
- 本地耳语(无链接):
whisper_stt_status然后transcribe_wav_file有一条通往.wav文件。需要pip install -e ".[stitch-whisper]"并重新启动光标MCP。
7.语音提示热键工具(离线)
使用 voice_prompt_tool.py 将一次听写直接输入到您的编码流中:
uv sync --extra stitch-whisper --extra voice-prompt
python voice_prompt_tool.py --hotkey ctrl+shift+v
它的作用:
- 麦克风捕获的全局启动/停止热键
- 本地更快的耳语转录(离线)
- 文件引用提取(
auth.ts->@auth.ts) - 提示信封已复制到剪贴板:
[FILE REFERENCE: ...][TASK: ...]
复制后可选择直接粘贴:
python voice_prompt_tool.py --autopaste
📚 使用RAG工具
将文档添加到 data/ 文件夹:
data/
├── document1.pdf
├── notes.md
└── research/
└── paper.pdf
支持:PDF、DOCX、TXT、MD、HTML等。
针式响应形状
这 rag 工具现在返回一个JSON字符串:
answer:最终合成答案文本confidence:low,medium,或highfallback:true当证据不足时sources:已排序的源代码片段(source_id,score,snippet)
这 rag_stitch 工具返回一个面向UI的JSON字符串:
state:answered或fallbackanswerconfidence(low,medium,或high)source_cards(空时state是fallback因此UI保持干净)show_sources(false回退)debug_retrieval_cards(仅当STITCH_RAG_DEBUG=1以及回退——用于调试的原始顶部块)
存储库拆分(缝合生产)
这 Stitch桌面应用程序 (React+Tauri)是 迁移到 RanneG/缝合应用程序; linkup_mcp 仍然是 MCP服务器 和 HTTP网桥 用于本地RAG、OAuth、订阅、面部和应用内帮助。移交清单和文件清单: docs/缝合/MIGRATION.md (参见 docs/stick/README.md).
stitch-api-types (TypeScript)
NPM工作区 packages/stitch-api-types 出版 .d.ts 为了 POST /api/rag/stitch, POST /api/rag/stitch-help, GET /api/health,以及相关的有效载荷。从repo根构建: npm run build:stitch-api-types. 缝合应用程序 可以依靠它 file: 路径(参见 缝合应用程序 docs/BACKEND.md).
Stitch HTTP桥(用于Stitch桌面应用程序)
运行一个小型Flask服务器,该服务器暴露的有效负载与 rag_stitch,加上可选 本地人脸验证 (/api/face/*,DeepFace+OpenCV活跃度——请参阅 face_verification/).需要 stitch-bridge 附加:
uv sync --extra stitch-bridge
.\.venv\Scripts\python.exe stitch_rag_bridge.py
然后将Stitch应用程序的Vite开发代理指向 http://127.0.0.1:8765 (参见 缝合应用程序文档/BACKEND.md 或 集成/缝合/README.md;代理 /api 用于RAG、face、auth、订阅和帮助路由)。
谁需要什么: 任何人都可以运行 缝合UI 从 缝合应用程序 使用Node(请参见 docs/RUNNING.md). linkup_mcp 是必需的 /api/* 后端功能(身份验证、数据、RAG、面部、服务器支持的帮助)。
从该仓库开发Stitch UI(可选)
根脚本 npm run dev:browser, npm run dev:desktop, npm run build:stitch-web, npm run build:stitch-app 使用 scripts/run-stitch-ui.mjs,这解决了 STITCH_APP_ROOT 或兄弟姐妹 ../stitch-app 只有。看 docs/缝合/MIGRATION.md.
缝合单窗口GUI
规范捆绑流现在从 缝合应用程序 (Stitch.bat 在那里)。需要时,它将此仓库用于后端网桥功能。
- 构建 里面的Stitch桌面包 缝合应用程序 (
npm run build). - 跑
Stitch.bat从 缝合应用程序 根。 - 保持此仓库可用于网桥运行时(
stitch_rag_bridge.py)on127.0.0.1:8765.
Stitch作为原生桌面应用程序(无需长时间手动命令链)
史迪奇 apps/desktop 包装用途 陶瑞 对于一个真正的窗口应用程序(npm run dev 那里= tauri dev).运行这些从 缝合应用程序:
| 目标 | 做什么 |
|---|---|
| 双击一次 (桥接+同步+Tauri) | 跑步 Stitch-Desktop.bat 在 缝合应用程序 回购根。 |
| 与终端相同 | npm run dev (缝合应用程序) |
| Bridge已在运行 | 从Stitch应用程序启动Stitch并保持此repo桥打开 127.0.0.1:8765 |
| 仅限Tauri(你自己开始桥) | npm run dev:desktop |
| 仅浏览器选项卡(无Tauri) | npm run dev:browser (使用 缝合应用程序 通过 run-stitch-ui.mjs) |
包装好的 .exe /安装程序 |
npm run build:stitch-app (之后 牛磺酸先决条件 和一个 缝合应用程序 克隆) |
你需要 节点 上 PATH 以及当地 缝合应用程序 克隆(兄弟姐妹 ../stitch-app 或 STITCH_APP_ROOT).第一次Tauri开发运行可能会编译Rust依赖项(一次性等待)。
快速回归运行
要对本地PDF语料库运行v1提示套件:
python rag_regression.py
这将打印每个响应有效负载和一个小摘要(源计数、回退计数、低置信度计数)。
缝合JSON合约测试
python -m unittest tests.test_rag_stitch_contract -v
确认 rag_stitch_contract._to_stitch_view 形状(answered vs fallback, show_sources,可选 debug_retrieval_cards).
如果MCP安全提示回退,请将MCP横向图添加到 data/:
🛠️ 项目结构
linkup_mcp/
├── server.py # MCP entrypoint (stdio) — all MCP tools live here
├── agents.py # spawn_agent sub-agent system (Ollama)
├── rag.py # RAGWorkflow (LlamaIndex + Ollama)
├── rag_heuristics.py # Pure scoring heuristics (unit-tested, no LLM imports)
├── rag_runtime.py # Lazy shared RAG index (MCP + bridge)
├── rag_stitch_contract.py # Stitch view JSON contract + guide-grounded help
├── local_whisper_stt.py # faster-whisper loader/transcribe (MCP + bridge share it)
├── stitch_rag_bridge.py # HTTP bridge ENTRYPOINT — owns Flask app, registers bridge/
├── bridge/ # Bridge route modules (one per concern)
│ ├── rag_routes.py # /api/rag/stitch, /api/rag/stitch-help, /api/stitch-user-guide
│ ├── voice_routes.py # /api/voice/transcribe + STT engine selection
│ ├── face_routes.py # /api/face/* (DeepFace imports deferred)
│ ├── health.py # /health + /api/health (shared payload)
│ ├── spa.py # /, /favicon.ico, optional built-SPA serving
│ ├── cors.py # STITCH_ALLOWED_ORIGINS handling
│ └── errors.py # JSON error handler for /api/face|auth|subscriptions
├── stitch_auth/ # Google OAuth (PKCE), sessions, subscriptions SQLite
├── face_verification/ # Local 1:1 face match + liveness (used by bridge)
├── integrations/stitch/ # Pointer README — UI lives in stitch-app repo
├── docs/ # e.g. stitch_user_guide.md (bridge Help / Ask Stitch)
├── data/ # Your documents
├── tests/ # Contract + unit tests (see CI commands below)
├── pyproject.toml # Dependencies + extras
├── .cursorrules # AI context for Cursor
└── .env # Environment variables (create this)
在哪里添加东西
| 更改 | 位置 |
|---|---|
| 新MCP工具 | server.py (@mcp.tool());根模块中的共享逻辑 |
| 新建网桥HTTP路由 | 中的新/现有模块 bridge/ (烧瓶蓝图),注册 stitch_rag_bridge.py |
| 认证/订阅路由 | stitch_auth/flask_routes.py |
| RAG评分/阈值调整 | rag_heuristics.py (纯,单元测试)或按实例attrs RAGWorkflow |
| 桥接JSON形状更改 | rag_stitch_contract.py 和 packages/stitch-api-types (保持同步,碰撞那个包裹) |
stitch_rag_bridge.py 必须继续出口 app 和 register_stitch_spa_routes --缝合应用程序 stitch_gui.py 按名称导入它们。
测试矩阵
# Default profile (uv sync):
python -m unittest tests.test_rag_stitch_contract tests.test_rag_heuristics -v
# With stitch-bridge extra:
python -m unittest tests.test_face_storage tests.test_bridge_routes tests.test_stitch_auth_helpers -v
🔧 运作原理
Cursor IDE → MCP Server (server.py)
↓
┌────────────┴────────────┐
│ RAG Tool │ Web Search│
│ (rag.py) │ (Linkup) │
└──────┬──────┴────────────┘
↓
Ollama (llama3.2) - runs locally
💰 成本
| 工具 | 成本 |
|---|---|
| 抹布 | $0 (当地Ollama) |
| 网络搜索 | ~10-50美元/月(链接API) |
| 奥拉马 | $0 (在本地运行) |
🐛 故障排除
MCP服务器未加载?
- 检查Ollama是否正在运行:
ollama list - 验证路径
mcp.json - 检查游标日志:
%APPDATA%\Cursor\logs\
奥拉玛的联系被拒绝了?
ollama serve
🔐 隐私
- ✅ RAG工具:100%本地,文档永远不会离开您的机器
- ✅ 奥拉玛:本地运行,无云API调用
- ⚠️ 网络搜索:发送到Linkup服务器的查询
📖 相关项目
| 存储库 | 目的 |
|---|---|
| 聊天机器人rag core | 可重用的Python RAG库 |
| 聊天机器人api服务器 | 生产Docker API服务器 |
🎓 资源
📝 许可证
MIT许可证-请参阅 许可证
🙏 学分
- 原件: patchy631/ai工程中心
- 链接 用于网络搜索
- 骆驼索引 对于RAG
- 奥拉玛 对于本地AI
由...制作❤️ 适用于Cursor IDE用户
