r/opencodeCLI • u/Whole-Assignment6240 • Feb 21 '26
cocoindex-code - super light weight MCP that understand and searches codebase that just works on opencode
I built a a super light-weight, effective embedded MCP that understand and searches your codebase that just works (AST-based) ! Using CocoIndex - an Rust-based ultra performant data transformation engine. No blackbox. Works for opencode or any coding agent. Free, No API needed.
- Instant token saving by 70%.
- 1 min setup - Just claude/codex mcp add works!
https://github.com/cocoindex-io/cocoindex-code
Would love your feedback! Appreciate a star ⭐ if it is helpful!
To get started:
```
opencode mcp add
```
- Enter MCP server name:
cocoindex-code - Select MCP server type:
local - Enter command to run:
uvx --prerelease=explicit --with cocoindex>=1.0.0a16 cocoindex-code@latest
Or use opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"cocoindex-code": {
"type": "local",
"command": [
"uvx",
"--prerelease=explicit",
"--with",
"cocoindex>=1.0.0a16",
"cocoindex-code@latest"
]
}
}
}
43
Upvotes
View all comments
Show parent comment
1
u/Mlaz72 Feb 28 '26
I have this in global AGENTS.md file at beginnig:
```
# System Instructions
## 🛠 Codebase Search & Discovery Protocol
Follow this hierarchy and logic when searching the codebase to ensure high accuracy and context efficiency.
### 1. The "Semantic First" Rule
**Primary Tool:** `cocoindex-code_search`
You **must** prioritize semantic search for discovery and understanding.
- **Use Case:** Finding implementations, understanding features, or locating code when exact names/keywords are unknown.
- **Example:** Instead of guessing filenames for OTP, use: `cocoindex-code_search("input-otp component implementation")`.
- **Constraint:** Do not use `grep` or `glob` as a discovery tool until semantic search has been exhausted.
### 2. Specialized Tool Selection
Only use secondary tools when the search intent is specific and the exact pattern is known:
| Tool | When to Use |
| :-------------- | :------------------------------------------------------------------------ |
| **`glob`** | You know the **exact file patterns** or need to find files by name. |
| **`grep`** | You are searching for **exact text content** or specific string patterns. |
| **`Task tool`** | For **complex, multi-step searches** to keep context usage low. |
### 3. Execution Strategy
- **Batching:** Whenever possible, **batch tool calls**. Call multiple tools in parallel to reduce latency.
- **Escalation:** If `cocoindex-code_search` fails to provide the full picture, only then should you supplement with `grep` or `glob` to fill in the technical gaps.
> [!CAUTION]
> **Avoid "Guess-and-Check" Globbing:** Do not attempt to find components (like `input-otp`) via file patterns if you haven't performed a semantic search first.
```