|
| 1 | +# MCP Setup - Quick Reference |
| 2 | + |
| 3 | +## ✅ What We Fixed |
| 4 | + |
| 5 | +1. **MCP Configuration Path Issue** |
| 6 | + - **Problem**: Used `"command": "knowcode"` (not in PATH) |
| 7 | + - **Solution**: Changed to `"/home/deeog/Desktop/KnowCode/.venv/bin/knowcode"` |
| 8 | + - **File**: `/home/deeog/.gemini/mcp_servers.json` |
| 9 | + |
| 10 | +## 📋 Current Status |
| 11 | + |
| 12 | +### ✅ Ready |
| 13 | +- [x] MCP configuration file updated with absolute path |
| 14 | +- [x] Knowledge store exists (1.1M, 1 day old) |
| 15 | +- [x] KnowCode CLI working (v0.2.1) |
| 16 | +- [x] Virtual environment configured |
| 17 | +- [x] Agent rules defined in `.agent/context.md` |
| 18 | + |
| 19 | +### ⚠️ Needs Attention |
| 20 | +- [ ] **Semantic index missing** - Will use lexical search only |
| 21 | +- [ ] **Knowledge store is 1 day old** - Consider re-analyzing |
| 22 | + |
| 23 | +### 🔄 Next Actions Required |
| 24 | +1. **Stop the manual MCP server** (Ctrl+C in terminal) |
| 25 | +2. **Restart Antigravity IDE** |
| 26 | +3. **Test the workflow** (see test_mcp_workflow.md) |
| 27 | + |
| 28 | +## 🎯 Expected Workflow After Restart |
| 29 | + |
| 30 | +``` |
| 31 | +User asks: "How does search work in KnowCode?" |
| 32 | + ↓ |
| 33 | +Agent calls: retrieve_context_for_query( |
| 34 | + query="How does search work in KnowCode?", |
| 35 | + task_type="auto", |
| 36 | + max_tokens=3000, |
| 37 | + limit_entities=3, |
| 38 | + expand_deps=true |
| 39 | +) |
| 40 | + ↓ |
| 41 | +KnowCode MCP Server returns: |
| 42 | +{ |
| 43 | + "context_text": "...", |
| 44 | + "sufficiency_score": 0.92, |
| 45 | + "evidence": [...], |
| 46 | + ... |
| 47 | +} |
| 48 | + ↓ |
| 49 | +Agent checks: sufficiency_score >= 0.88? |
| 50 | + ↓ |
| 51 | +YES → Answer from context_text only (no external LLM) |
| 52 | +NO → Use external LLM (Claude Sonnet 4.5) |
| 53 | +``` |
| 54 | + |
| 55 | +## 📁 Files Created |
| 56 | + |
| 57 | +1. **`verify_mcp_connection.sh`** - Check MCP setup status |
| 58 | +2. **`test_mcp_workflow.md`** - Test questions after restart |
| 59 | +3. **`docs/MCP_SETUP.md`** - Complete setup documentation |
| 60 | +4. **`README_MCP.md`** - This quick reference (you are here) |
| 61 | + |
| 62 | +## 🚀 Quick Commands |
| 63 | + |
| 64 | +### Check MCP Status |
| 65 | +```bash |
| 66 | +./verify_mcp_connection.sh |
| 67 | +``` |
| 68 | + |
| 69 | +### Check MCP Server Process |
| 70 | +```bash |
| 71 | +ps aux | grep "knowcode mcp-server" |
| 72 | +``` |
| 73 | + |
| 74 | +### View MCP Configuration |
| 75 | +```bash |
| 76 | +cat ~/.gemini/mcp_servers.json |
| 77 | +``` |
| 78 | + |
| 79 | +### Rebuild Knowledge Store (if needed) |
| 80 | +```bash |
| 81 | +source .venv/bin/activate |
| 82 | +knowcode analyze . -o . |
| 83 | +``` |
| 84 | + |
| 85 | +**Note:** This automatically rebuilds both the knowledge store AND the semantic index! |
| 86 | + |
| 87 | +## 🐛 Troubleshooting |
| 88 | + |
| 89 | +### MCP Tool Not Available After Restart? |
| 90 | + |
| 91 | +1. Check server is running: |
| 92 | + ```bash |
| 93 | + ps aux | grep "knowcode mcp-server" |
| 94 | + ``` |
| 95 | + |
| 96 | +2. Check configuration: |
| 97 | + ```bash |
| 98 | + cat ~/.gemini/mcp_servers.json |
| 99 | + ``` |
| 100 | + |
| 101 | +3. Restart IDE again |
| 102 | + |
| 103 | +### Low Sufficiency Scores? |
| 104 | + |
| 105 | +1. Verify index exists (should be created by analyze): |
| 106 | + ```bash |
| 107 | + ls -la knowcode_index/ |
| 108 | + ``` |
| 109 | + |
| 110 | +2. If missing, re-run analyze (it will rebuild the index): |
| 111 | + ```bash |
| 112 | + knowcode analyze . -o . |
| 113 | + ``` |
| 114 | + |
| 115 | +3. Increase token budget in `.agent/context.md`: |
| 116 | + ```markdown |
| 117 | + Use max_tokens=6000, limit_entities=5 |
| 118 | + ``` |
| 119 | + |
| 120 | +## 📊 Success Metrics |
| 121 | + |
| 122 | +After setup, you should see: |
| 123 | +- ✅ 70%+ queries with `sufficiency_score >= 0.88` |
| 124 | +- ✅ Faster responses for codebase questions |
| 125 | +- ✅ 50%+ reduction in external LLM token usage |
| 126 | +- ✅ Accurate answers from local context |
| 127 | + |
| 128 | +## 📚 Documentation |
| 129 | + |
| 130 | +- **Full Setup Guide**: `docs/MCP_SETUP.md` |
| 131 | +- **Test Plan**: `test_mcp_workflow.md` |
| 132 | +- **KnowCode Docs**: `README.md` |
| 133 | + |
| 134 | +## 🎓 Key Concepts |
| 135 | + |
| 136 | +**Sufficiency Score**: Confidence that retrieved context is enough to answer the query |
| 137 | +- `>= 0.88` → Answer locally |
| 138 | +- `< 0.88` → Use external LLM |
| 139 | + |
| 140 | +**Retrieval Modes**: |
| 141 | +- **Semantic**: Uses embeddings + vector search (better) |
| 142 | +- **Lexical**: Uses keyword matching (fallback) |
| 143 | + |
| 144 | +**Dependency Expansion**: Includes related code (callees, callers) for complete context |
| 145 | + |
| 146 | +## ⚡ Performance Tips |
| 147 | + |
| 148 | +1. **Build semantic index** - Much better than lexical |
| 149 | +2. **Keep knowledge store updated** - Re-analyze after major changes |
| 150 | +3. **Tune parameters** - Adjust max_tokens and limit_entities |
| 151 | +4. **Monitor scores** - Track sufficiency_score distribution |
| 152 | + |
| 153 | +## 🔒 Security Notes |
| 154 | + |
| 155 | +- MCP server runs **locally** (no external data transmission) |
| 156 | +- Knowledge store contains your **source code** (keep secure) |
| 157 | +- Embeddings may be sent to **external providers** (VoyageAI, OpenAI) |
| 158 | +- Store API keys in `.env` (never commit) |
| 159 | + |
| 160 | +## 🎉 You're Almost There! |
| 161 | + |
| 162 | +Just need to: |
| 163 | +1. Stop the manual MCP server (Ctrl+C) |
| 164 | +2. Restart Antigravity IDE |
| 165 | +3. Ask a test question |
| 166 | + |
| 167 | +Good luck! 🚀 |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +*Last updated: 2026-01-13* |
0 commit comments