Skip to content

Commit 0daf474

Browse files
shantanu patilclaude
authored andcommitted
feat: add MCP server for BetterCodeWiki
Standalone MCP server (api/mcp/server.py) that exposes 5 tools: - list_projects: discover cached wiki repos - get_wiki_overview: project architecture in one call - get_wiki_page: specific page with fuzzy title matching - search_wiki: full-text search across all pages - ask_codebase: returns relevant wiki context for agent reasoning Plus 2 MCP resources (wiki:// URI scheme). Zero imports from existing code — reads same ~/.adalflow/wikicache/ JSON files the main app writes. Tested against 6 cached repos. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4d21b1e commit 0daf474

3 files changed

Lines changed: 439 additions & 18 deletions

File tree

MCP_SETUP.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# BetterCodeWiki MCP Server — Plan & Setup Guide
1+
# BetterCodeWiki MCP Server — Setup Guide
22

3-
> How to expose BetterCodeWiki as an MCP server so Claude Desktop, Claude Code, Cursor, and Windsurf can query your codebase wikis in real-time.
3+
> Expose BetterCodeWiki as an MCP server so Claude Desktop, Claude Code, Cursor, and Windsurf can query your codebase wikis in real-time.
4+
>
5+
> **Status: Built and working.** Server is at `api/mcp/server.py`.
46
57
---
68

@@ -68,19 +70,20 @@ After analyzing what's actually useful for AI agents vs. what's noise, here are
6870

6971
---
7072

71-
## Implementation Plan
73+
## Implementation
7274

7375
### File Structure
7476

7577
```
7678
api/mcp/
77-
├── server.py # MCP server entry point (standalone script)
78-
└── requirements.txt # Just: mcp[cli]>=1.25
79+
├── server.py # MCP server (standalone script, ~250 lines)
80+
├── .venv/ # Python 3.13 venv with mcp[cli] installed
81+
└── .gitignore # Excludes .venv/ and __pycache__/
7982
```
8083

81-
That's it. One file + one dependency.
84+
One file. One dependency (`mcp[cli]`). Zero imports from existing code.
8285

83-
### server.py — What It Will Look Like
86+
### server.py — Source
8487

8588
```python
8689
"""
@@ -383,35 +386,33 @@ if __name__ == "__main__":
383386
mcp.run(transport="stdio")
384387
```
385388

386-
### What This Code Does
389+
See [`api/mcp/server.py`](api/mcp/server.py) for the full implementation.
390+
391+
### How It Works
387392

388393
1. **Reads `~/.adalflow/wikicache/` directly** — same JSON files the main app creates
389394
2. **No imports from existing code** — zero coupling, zero risk
390395
3. **All cached wiki tools are instant** — just file I/O and string search
391-
4. **`ask_codebase` returns context, not LLM output** — the calling agent's own model reasons about the wiki content (this is how MCP tools should work)
396+
4. **`ask_codebase` returns context, not LLM output** — the calling agent's own model reasons about the wiki content (this is the correct MCP pattern)
397+
5. **Large page content is truncated** in `ask_codebase` (8KB max per page) to keep responses manageable; use `get_wiki_page` for full content
392398

393399
---
394400

395401
## Setup Guide
396402

397403
### Prerequisites
398404

399-
1. BetterCodeWiki must be running and have generated at least one wiki (so cache files exist in `~/.adalflow/wikicache/`)
405+
1. BetterCodeWiki must have generated at least one wiki (so cache files exist in `~/.adalflow/wikicache/`)
400406
2. Python 3.10+ installed locally
401407

402408
### Step 1: Install the MCP SDK
403409

404-
```bash
405-
pip install "mcp[cli]"
406-
```
407-
408-
Or if using a virtual environment:
410+
The venv is already set up at `api/mcp/.venv/`. To recreate it:
409411

410412
```bash
411413
cd /path/to/BetterCodeWiki
412-
python -m venv .mcp-venv
413-
source .mcp-venv/bin/activate
414-
pip install "mcp[cli]"
414+
python3.13 -m venv api/mcp/.venv
415+
api/mcp/.venv/bin/pip install "mcp[cli]"
415416
```
416417

417418
### Step 2: Test the Server Locally

api/mcp/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv/
2+
__pycache__/
3+
*.pyc

0 commit comments

Comments
 (0)