🔒 锁定:不再默默等待代码
Lock In将Cursor的AI代理从无声代码生成器转换为主动配对程序员。您可以听到代理实时解释其推理过程,并在生成中期提出问题,而不是盯着加载旋转器。
建于 mcp使用 --将任何LLM连接到任何MCP服务器
🎯 问题
当Cursor的代理生成代码时,您将静默等待30-60秒:
- ❌ 不知道它在想什么
- ❌ 课程不能早改
- ❌ 浪费时间感到脱节
- ❌ 错过学习机会
✨ 解决方案
锁定为Cursor的代理发出声音:
- ✅ 实时听取推理(“我正在检查您的身份验证设置…”)
- ✅ 问中年人的问题(“我们应该使用智威汤逊还是会话?”)
- ✅ 在编写代码之前发现错误
- ✅ 了解做出决策的原因
- ✅ 保持参与并“锁定”流程
🎥 演示
老办法:
User: "Add authentication to my API"
[30 seconds of loading spinner]
[Code appears]锁定方式:
User: "Add authentication to my API"
Agent: "Alright, let me think about authentication for your API..."
Agent: "I'm checking your existing user model... I see you have password hashing already, good."
User: "Should we use JWT or sessions?"
Agent: "Great question! Since this is a REST API, JWT tokens would be better for stateless auth..."
Agent: "Now I'm creating the auth middleware file..."
[Code appears with full understanding of decisions]🚀 快速开始
# 1. Setup
cd lock-in
chmod +x scripts/setup.sh
./scripts/setup.sh
# 2. Add API keys to .env
# Edit .env with your Cartesia API key
# 3. Run the MCP Server (HTTP mode for testing)
./scripts/run.sh mcp-http
# 4. Test with MCP Inspector
npx @modelcontextprotocol/inspector --transport http --server-url http://localhost:8000/mcp
# 5. Or run everything (voice agent + MCP server + audio client)
./scripts/run.sh all测试MCP服务器
MCP服务器运行在 http://localhost:8000 使用这些端点:
/mcp--MCP协议端点(可流式HTTP)/openmcp.json--OpenMCP架构/inspector--内置检查器UI/docs-API文件
# Test with curl
curl http://localhost:8000/openmcp.json | jq .tools
# Test with MCP Inspector (local)
npx @modelcontextprotocol/inspector --transport http --server-url http://localhost:8000/mcp
# Test with ngrok (for remote access)
ngrok http 8000
# Then use the ngrok URL in MCP Inspector web UI🏗️ 建筑
Cursor Agent (generating code)
↓ (reasoning traces via MCP tools)
Lock-In MCP Server (mcp-use, port 8000)
↓ (narration text via WebSocket)
Voice Agent (Pipecat pipeline, port 8765)
↓ (TTS via Cartesia, protobuf frames)
Audio Client (browser, connects to port 8765)
↓
User's Speakers 🔊
User's Microphone 🎤
↓ (captured by Audio Client)
Voice Agent (STT via Cartesia)
↓ (question via WebSocket)
MCP Server (answers using session context)
↓ (answer text)
Voice Agent → Audio Client → User's SpeakersMCP服务器模式
MCP服务器支持两种传输模式:
| 模式 | 命令 | 用例 |
|---|---|---|
| 超文本传输协议 | ./scripts/run.sh mcp-http | Web客户端、MCP检查器、ChatGPT、Claude |
| 标准 | ./scripts/run.sh mcp | 光标IDE,克劳德桌面 |
管道流量
┌─────────────────────────────────────────────────────────┐
│ VOICE AGENT │
├─────────────────────────────────────────────────────────┤
│ │
│ User Audio Input (microphone) │
│ ↓ │
│ Cartesia STT (speech → text) │
│ ↓ │
│ UserQuestionHandler (detect questions) │
│ ↓ │
│ NarrationInjector (queue + inject narration text) │
│ ↓ │
│ Cartesia TTS (text → speech) │
│ ↓ │
│ User Audio Output (speakers) │
│ │
│ ← MCP Server sends narration/answers via WebSocket → │
│ │
└─────────────────────────────────────────────────────────┘📁 项目结构
lock-in/
├── README.md # This file
├── SETUP.md # Detailed setup instructions
├── COMMANDS.md # All commands reference
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
│
├── scripts/
│ ├── setup.sh # Automated setup script
│ └── run.sh # Multi-command run script
│
├── audio_client/
│ └── index.html # Browser audio client (WebSocket + protobuf)
│
├── mcp_server/
│ ├── __init__.py
│ ├── server.py # MCP server with tools (mcp-use SDK)
│ ├── trace_listener.py # Parse Cursor agent traces
│ ├── narration_generator.py # Convert traces to natural speech
│ ├── context_manager.py # Session context for Q&A
│ └── models.py # Pydantic data models
│
├── voice_agent/
│ ├── __init__.py
│ ├── agent.py # Main voice agent orchestrator
│ ├── config.py # Pydantic Settings configuration
│ └── pipeline.py # Pipecat pipeline (STT→LLM→TTS)
│
├── tests/
│ ├── __init__.py
│ ├── test_mcp_server.py # MCP server component tests
│ ├── test_voice_agent.py # Voice agent component tests
│ └── test_integration.py # Integration tests
│
└── examples/
├── example_traces.json # Sample reasoning traces
└── test_narration.py # Standalone narration demo🛠️ 技术栈
- mcp使用 --MCP服务器Python SDK(流式HTTP+stdio)
- Pipecat --语音管道编排
- 卡特尔 --超低延迟TTS/STT(\ “好吧,所以你需要身份验证。我在考虑JWT令牌,因为这是一个REST API。让我计划一下我们需要接触哪些文件。”
分析阶段:
“我在models/user.py中查看您现有的用户模型。我看到您已经有了密码哈希,这很好。”
实施阶段:
“现在我正在创建auth_middleware.py。正在为受保护的路由编写verify_token函数…”
调试阶段:
“嗯,我注意到你的代币到期时间设置为15分钟——这可能对开发来说太短了。”
测试阶段:
“让我验证一下这是否有效……对身份验证流进行快速检查。”
🔊 音频客户端
音频客户端是一个基于浏览器的前端,在端口8765上连接到语音代理的WebSocket。它从Pipecat管道接收protobuf编码的音频帧,并通过扬声器播放。可选地,它为语音转文本问题流捕获麦克风音频。
# Serve the audio client (default port 8080)
./scripts/run.sh client
# Or specify a custom port
./scripts/run.sh client 9000
# Or start everything at once (voice agent + MCP server + audio client)
./scripts/run.sh all然后打开 http://localhost:8080 (或 http://:8080 从另一台机器),然后单击 连接.
🔧 配置
在中自定义叙述风格、声音、速度等 .env:
# Use a different Cartesia voice
CARTESIA_VOICE_ID=your_preferred_voice_id
# Adjust narration speed (1.0 = normal, 1.2 = faster)
NARRATION_SPEED=1.1
# Enable/disable user interruptions
ENABLE_INTERRUPTIONS=true
# Set log level
LOG_LEVEL=DEBUG看 .env.example 对于所有可用设置。
📚 文档
🧪 测试
# Run all tests
./scripts/run.sh test
# Run with coverage
./scripts/run.sh test-coverage
# Run a specific test file
PYTHONPATH=. pytest tests/test_mcp_server.py -v📄 许可证
MIT许可证
