Skip to content

Commit e6afc13

Browse files
committed
update readme, fix lint
1 parent d00b623 commit e6afc13

2 files changed

Lines changed: 105 additions & 12 deletions

File tree

README.md

Lines changed: 101 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,93 @@ class Authenticator:
5151

5252
Code-RAG works as an MCP server, letting Claude automatically search your codebase during conversations.
5353

54+
### Quick Setup
55+
56+
**Option 1: Using uvx (after publishing to PyPI)**
5457
```bash
58+
# Claude Desktop (config.json)
59+
claude mcp add code-rag
60+
61+
# Or with Claude Code
62+
claude mcp add code-rag --transport stdio uvx code-rag-mcp
63+
```
64+
65+
**Option 2: Local installation**
66+
```bash
67+
# Install in virtual environment
68+
pip install -e .
69+
5570
# Register with Claude Code
5671
claude mcp add code-rag --transport stdio path/to/venv/bin/code-rag-mcp
5772
```
5873

59-
Then talk to Claude:
74+
### Configuration
75+
76+
The MCP server reads configuration from environment variables or config files. Configure via your MCP client's settings:
77+
78+
**Claude Desktop (`~/Library/Application Support/Claude/claude_desktop_config.json`)**:
79+
```json
80+
{
81+
"mcpServers": {
82+
"code-rag": {
83+
"command": "uvx",
84+
"args": ["code-rag-mcp"],
85+
"env": {
86+
"CODE_RAG_EMBEDDING_MODEL": "nomic-ai/CodeRankEmbed",
87+
"CODE_RAG_DATABASE_TYPE": "chroma",
88+
"CODE_RAG_RERANKER_ENABLED": "true"
89+
}
90+
}
91+
}
92+
}
93+
```
94+
95+
**Claude Code (via claude mcp add)**:
96+
```bash
97+
# Basic setup
98+
claude mcp add code-rag --transport stdio uvx code-rag-mcp
99+
100+
# Then configure via environment variables or config files
101+
```
102+
103+
**Common Configuration Options**:
104+
- `CODE_RAG_EMBEDDING_MODEL` - Embedding model (default: `nomic-ai/CodeRankEmbed`)
105+
- `nomic-ai/CodeRankEmbed` - Code-optimized, runs locally
106+
- `text-embedding-3-small` - OpenAI embeddings (requires `OPENAI_API_KEY`)
107+
- `CODE_RAG_DATABASE_TYPE` - Database backend: `chroma` or `qdrant` (default: `chroma`)
108+
- `CODE_RAG_CHUNK_SIZE` - Chunk size in characters (default: `1024`)
109+
- `CODE_RAG_RERANKER_ENABLED` - Enable result reranking (default: `false`)
110+
- `CODE_RAG_SHARED_SERVER` - Share embedding server across instances (default: `true`)
111+
112+
**Example with OpenAI embeddings**:
113+
```json
114+
{
115+
"mcpServers": {
116+
"code-rag": {
117+
"command": "uvx",
118+
"args": ["code-rag-mcp"],
119+
"env": {
120+
"CODE_RAG_EMBEDDING_MODEL": "text-embedding-3-small",
121+
"OPENAI_API_KEY": "sk-...",
122+
"CODE_RAG_RERANKER_ENABLED": "true"
123+
}
124+
}
125+
}
126+
}
127+
```
128+
129+
### Usage
130+
131+
Once configured, Claude can automatically search your codebase:
132+
60133
```
61134
You: "Find the database connection logic"
62135
63136
Claude: [Automatically searches and finds the code]
64137
"I found the database connection logic in src/db/connection.py..."
65138
```
66139

67-
See [docs/mcp.md](docs/mcp.md) for detailed setup.
140+
See [docs/mcp.md](docs/mcp.md) for detailed setup and troubleshooting.
68141

69142
## Basic Usage
70143

@@ -87,7 +160,20 @@ code-rag --database qdrant
87160

88161
## Configuration
89162

90-
Set via environment variables:
163+
### Priority Order
164+
165+
Configuration is loaded in this order (higher priority overrides lower):
166+
167+
1. **Environment variables** (highest priority)
168+
2. Custom config file via `CODE_RAG_CONFIG_FILE` environment variable
169+
3. Project config: `./code-rag.config`
170+
4. User config: `~/.config/code-rag/config` (auto-created with defaults)
171+
172+
**For MCP servers**: Set environment variables in your MCP client config (see MCP Integration section above).
173+
174+
**For CLI usage**: Use environment variables or config files.
175+
176+
### Environment Variables
91177

92178
```bash
93179
# Use code-optimized embeddings (recommended)
@@ -103,20 +189,24 @@ export CODE_RAG_DATABASE_TYPE="qdrant"
103189
# Adjust chunk size
104190
export CODE_RAG_CHUNK_SIZE="2048"
105191

192+
# Enable reranking for better results
193+
export CODE_RAG_RERANKER_ENABLED="true"
194+
106195
# Add custom ignore patterns (comma-separated)
107196
export CODE_RAG_ADDITIONAL_IGNORE_PATTERNS="*.tmp,*.bak,logs/"
108197
```
109198

199+
### Config File Format
110200

111-
### Configuration Files
201+
Config files use the same format (key=value):
112202

113-
Code-RAG looks for configuration in the following order (first found wins):
114-
115-
1. `CODE_RAG_CONFIG_FILE` environment variable
116-
2. `code-rag.config` in the current directory (project-specific)
117-
3. `~/.config/code-rag/config` (user-global)
118-
- **Auto-created with default values** if it doesn't exist.
119-
4. Shell environment variables (highest priority - these override files)
203+
```bash
204+
# ~/.config/code-rag/config or ./code-rag.config
205+
CODE_RAG_EMBEDDING_MODEL=nomic-ai/CodeRankEmbed
206+
CODE_RAG_DATABASE_TYPE=chroma
207+
CODE_RAG_CHUNK_SIZE=1024
208+
CODE_RAG_RERANKER_ENABLED=false
209+
```
120210

121211
Full configuration options in [docs/IMPLEMENTATION.md](docs/IMPLEMENTATION.md#configuration-system).
122212

tests/test_mcp_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,10 @@ async def test_full_workflow_index_and_search(self, api_instance, temp_codebase)
10341034
async def test_multiple_codebase_searches(self, api_instance):
10351035
"""Test searching different codebases in same session."""
10361036
# Create two temporary codebases
1037-
with tempfile.TemporaryDirectory() as temp1, tempfile.TemporaryDirectory() as temp2:
1037+
with (
1038+
tempfile.TemporaryDirectory() as temp1,
1039+
tempfile.TemporaryDirectory() as temp2,
1040+
):
10381041
# Create files in first codebase
10391042
(Path(temp1) / "test1.py").write_text("def function1():\n pass")
10401043

0 commit comments

Comments
 (0)