A local-first, agent-agnostic Model Context Protocol (MCP) server implementation using the Auggie SDK as the core context engine.
π New here? Check out INDEX.md for a complete documentation guide!
This implementation follows a clean 5-layer architecture as outlined in plan.md:
ββββββββββββββββββββββββββββββ
β Coding Agents (Clients) β Layer 4: Claude, Cursor, etc.
β Codex | Claude | Cursor β
ββββββββββββββ²ββββββββββββββββ
β MCP (tools)
ββββββββββββββ΄ββββββββββββββββ
β MCP Interface Layer β Layer 3: server.ts, tools/
β (standardized tool API) β
ββββββββββββββ²ββββββββββββββββ
β internal API
ββββββββββββββ΄ββββββββββββββββ
β Context Service Layer β Layer 2: serviceClient.ts
β (query orchestration) β
ββββββββββββββ²ββββββββββββββββ
β domain calls
ββββββββββββββ΄ββββββββββββββββ
β Core Context Engine β Layer 1: Auggie SDK
β (indexing, retrieval) β
ββββββββββββββ²ββββββββββββββββ
β storage
ββββββββββββββ΄ββββββββββββββββ
β Storage / Index Backend β Layer 5: Auggie's internal
β (vectors, metadata) β
ββββββββββββββββββββββββββββββ
- Layer 1 (Core Engine): Auggie SDK handles file ingestion, chunking, embedding, and semantic retrieval
- Layer 2 (Service): Orchestrates context, formats snippets, deduplicates, enforces limits
- Layer 3 (MCP Interface): Exposes tools, validates I/O, maps calls to service layer
- Layer 4 (Agents): Consume context and generate responses
- Layer 5 (Storage): Persists embeddings and metadata
index_workspace(force)- Index workspace files for semantic searchcodebase_retrieval(query, top_k)- PRIMARY semantic search, JSON output for programmatic usesemantic_search(query, top_k)- Semantic code search across the codebase (markdown output)get_file(path)- Retrieve complete file contentsget_context_for_prompt(query)- Get relevant context for prompt enhancement (primary tool)enhance_prompt(prompt)- Transform simple prompts into detailed, structured prompts using AI-powered enhancement
index_status()- View index health metadata (status, fileCount, lastIndexed, isStale)reindex_workspace()- Clear and rebuild the entire indexclear_index()- Remove index state without rebuildingtool_manifest()- Capability discovery for agents (lists all available tools)
- β Local-first: No cloud dependencies, no exposed ports, no data leakage
- β Agent-agnostic: Works with any MCP-compatible coding agent
- β LLM-agnostic: No LLM-specific logic in the engine
- β Storage-agnostic: Auggie SDK handles storage abstraction
- β Extensible: Clean separation allows easy feature additions
- β Real-time watching: Automatic incremental indexing on file changes (v1.1.0)
- β Background indexing: Non-blocking indexing via worker threads (v1.1.0)
- β Offline policy: Enforce local-only operation with environment variable (v1.1.0)
- Node.js 18+
- Auggie CLI - Install globally:
npm install -g @augmentcode/auggie
- Authentication - Run
auggie loginor set environment variables:export AUGMENT_API_TOKEN="your-token" export AUGMENT_API_URL="https://api.augmentcode.com"
# Clone or navigate to the repository
cd context-engine
# Install dependencies
npm install
# Build the project
npm run build# Start server with current directory
node dist/index.js
# Start with specific workspace
node dist/index.js --workspace /path/to/project
# Index workspace before starting
node dist/index.js --workspace /path/to/project --index
# Enable file watcher for automatic incremental indexing (v1.1.0)
node dist/index.js --workspace /path/to/project --watch| Option | Alias | Description |
|---|---|---|
--workspace <path> |
-w |
Workspace directory to index (default: current directory) |
--index |
-i |
Index the workspace before starting server |
--watch |
-W |
Enable filesystem watcher for incremental indexing |
--help |
-h |
Show help message |
-
Build the project:
npm run build
-
Add the MCP server to Codex CLI:
codex mcp add context-engine -- node /absolute/path/to/context-engine/dist/index.js --workspace /path/to/your/project
Or edit
~/.codex/config.tomldirectly:[mcp_servers.context-engine] command = "node" args = [ "/absolute/path/to/context-engine/dist/index.js", "--workspace", "/path/to/your/project" ]
-
Restart Codex CLI
-
Type
/mcpin the TUI to verify the server is connected
For other MCP clients, add this server to your client's MCP configuration:
{
"mcpServers": {
"context-engine": {
"command": "node",
"args": [
"/absolute/path/to/context-engine/dist/index.js",
"--workspace",
"/path/to/your/project"
]
}
}
}See QUICKSTART.md - Step 5B for detailed instructions for each client.
# Watch mode for development
npm run dev
# Build for production
npm run build
# Run the server
npm startcontext-engine/
βββ src/
β βββ index.ts # Entry point with CLI parsing
β βββ mcp/
β β βββ server.ts # MCP server implementation
β β βββ serviceClient.ts # Context service layer
β β βββ tools/
β β βββ index.ts # index_workspace tool
β β βββ search.ts # semantic_search tool
β β βββ file.ts # get_file tool
β β βββ context.ts # get_context_for_prompt tool
β β βββ enhance.ts # enhance_prompt tool
β β βββ status.ts # index_status tool (v1.1.0)
β β βββ lifecycle.ts # reindex/clear tools (v1.1.0)
β β βββ manifest.ts # tool_manifest tool (v1.1.0)
β βββ watcher/ # File watching (v1.1.0)
β β βββ FileWatcher.ts # Core watcher logic
β β βββ types.ts # Event types
β β βββ index.ts # Exports
β βββ worker/ # Background indexing (v1.1.0)
β βββ IndexWorker.ts # Worker thread
β βββ messages.ts # IPC messages
βββ tests/ # Unit tests (106 tests)
βββ plan.md # Architecture documentation
βββ package.json
βββ tsconfig.json
βββ README.md
Once connected to Codex CLI, you can use natural language:
- "Search for authentication logic in the codebase"
- "Show me the database schema files"
- "Get context about the API endpoints"
- "Find error handling patterns"
The server will automatically use the appropriate tools to provide relevant context.
| Variable | Description | Default |
|---|---|---|
AUGMENT_API_TOKEN |
Auggie API token (or use auggie login) |
- |
AUGMENT_API_URL |
Auggie API URL | https://api.augmentcode.com |
CONTEXT_ENGINE_OFFLINE_ONLY |
Enforce offline-only policy (v1.1.0) | false |
To enforce that no data is sent to remote APIs, set:
export CONTEXT_ENGINE_OFFLINE_ONLY=trueWhen enabled, the server will fail to start if a remote API URL is configured. This is useful for enterprise environments with strict data locality requirements.
- Check
~/.codex/config.tomlfor syntax errors - Ensure paths are absolute
- Restart Codex CLI
- Run
codex mcp listto see configured servers - Use
/mcpcommand in the TUI to check connection status
Run auggie login or verify environment variables are set correctly.
Index your workspace first:
node dist/index.js --workspace /path/to/project --index- Ensure you started the server with
--watchflag - Check that the file is not in
.gitignoreor.contextignore - Wait for the debounce period (default: 500ms) after the last change
- Check server logs for watcher status messages
If you see an error about offline-only mode:
- Remove the
CONTEXT_ENGINE_OFFLINE_ONLYenvironment variable, or - Configure a localhost API URL in
AUGMENT_API_URL
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Interactive MCP testing
npm run inspectorTest Status: 106 tests passing β
MIT