
Autodev代码库
STDIO支持语义搜索和MCP服务器的代码分析库
支持语义搜索和MCP服务器的代码分析库
A platform-agnostic code analysis library with semantic search capabilities and MCP (Model Context Protocol) server support. This library provides intelligent code indexing, vector-based semantic search, and can be integrated into various development tools and IDEs.
# Install Ollama (macOS) brew install ollama # Start Ollama service ollama serve # In a new terminal, pull the embedding model ollama pull nomic-embed-text
ripgrep
is required for fast codebase indexing. Install it with:
# Install ripgrep (macOS) brew install ripgrep # Or on Ubuntu/Debian sudo apt-get install ripgrep # Or on Arch Linux sudo pacman -S ripgrep
Start Qdrant using Docker:
# Start Qdrant container docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
Or download and run Qdrant directly:
# Download and run Qdrant wget https://github.com/qdrant/qdrant/releases/latest/download/qdrant-x86_64-unknown-linux-gnu.tar.gz tar -xzf qdrant-x86_64-unknown-linux-gnu.tar.gz ./qdrant
# Check Ollama curl http://localhost:11434/api/tags # Check Qdrant curl http://localhost:6333/collections
npm install -g @autodev/codebase
Alternatively, you can install it locally:
git clone https://github.com/anrgct/autodev-codebase
cd autodev-codebase
npm install
npm run build
npm link
The CLI provides two main modes:
# Basic usage: index your current folder as the codebase. # Be cautious when running this command if you have a large number of files. codebase # With custom options codebase --demo # Create a local demo directory and test the indexing service, recommend for setup codebase --path=/my/project codebase --path=/my/project --log-level=info
# Start long-running MCP server cd /my/project codebase mcp-server # With custom configuration codebase mcp-server --port=3001 --host=localhost codebase mcp-server --path=/workspace --port=3002
Configure your IDE to connect to the MCP server:
{ "mcpServers": { "codebase": { "url": "http://localhost:3001/sse" } } }
For clients that do not support SSE MCP, you can use the following configuration:
{ "mcpServers": { "codebase": { "command": "codebase", "args": [ "stdio-adapter", "--server-url=http://localhost:3001/sse" ] } } }
import { createNodeDependencies } from '@autodev/codebase/adapters/nodejs' import { CodeIndexManager } from '@autodev/codebase' const deps = createNodeDependencies({ workspacePath: '/path/to/project', storageOptions: { /* ... */ }, loggerOptions: { /* ... */ }, configOptions: { /* ... */ } }) const manager = CodeIndexManager.getInstance(deps) await manager.initialize() await manager.startIndexing()
--path=<path>
- Workspace path (default: current directory)--demo
- Create demo files in workspace--ollama-url=<url>
- Ollama API URL (default: http://localhost:11434)--qdrant-url=<url>
- Qdrant vector DB URL (default: http://localhost:6333)--model=<model>
- Embedding model (default: nomic-embed-text)--config=<path>
- Config file path--storage=<path>
- Storage directory path--cache=<path>
- Cache directory path--log-level=<level>
- Log level: error|warn|info|debug (default: error)--help, -h
- Show help--port=<port>
- HTTP server port (default: 3001)--host=<host>
- HTTP server host (default: localhost)http://localhost:3001
- Server status and configurationhttp://localhost:3001/health
- JSON status endpointhttp://localhost:3001/sse
- SSE/HTTP MCP protocol endpointsearch_codebase
- Semantic search through your codebase
query
(string), limit
(number), filters
(object)get_search_stats
- Get indexing status and statisticsconfigure_search
- Configure search parameters at runtime# Development mode with demo files npm run dev # Build for production npm run build # Type checking npm run type-check # Run TUI demo npm run demo-tui # Start MCP server demo npm run mcp-server
This is a platform-agnostic library extracted from the roo-code VSCode plugin.
See the examples/
directory for complete usage examples:
nodejs-usage.ts
- Node.js integration examplesrun-demo-tui.tsx
- TUI demo application