Skip to content

Repository files navigation

Context Engine MCP Server

A high-performance, memory-safe Model Context Protocol (MCP) server written in Rust for AI-powered codebase context retrieval.

Overview

Context Engine provides semantic code search and AI-powered context retrieval for coding agents. It integrates with the Augment Code SDK to offer:

  • Semantic Code Search: AI-powered codebase retrieval using embeddings
  • File Indexing: Automatic workspace indexing with intelligent file filtering
  • MCP Protocol: Full Model Context Protocol support (JSON-RPC over stdio/HTTP)
  • Code Review: Multi-pass review pipeline with risk scoring and invariant checking
  • Planning: AI-assisted task planning and step management
  • Memory: Persistent memory storage for context across sessions

Features

MetricValue
Binary Size~7 MB (optimized ARM64)
Lines of Code~10,500 Rust
Unit Tests201 tests
Integration Tests11 tests
MCP Tools72 tools
Agent Skills7 skills
Supported Languages18+ (symbol detection)
Startup Time<10ms
Memory Usage~20 MB idle

Installation

Prerequisites

  • Rust 1.83+ (with cargo)
  • Augment API credentials (via ~/.augment/session.json or environment variables)

Build from Source

cargo build --release

The binary will be at target/release/context-engine.

Usage

Command Line

# Start MCP server (stdio transport - default)
./target/release/context-engine --workspace /path/to/project
# Start with HTTP transport
./target/release/context-engine --workspace /path/to/project --transport http --port 3000
# Enable metrics endpoint
./target/release/context-engine --workspace /path/to/project --metrics --metrics-port 9090
# Debug mode
./target/release/context-engine --workspace /path/to/project --debug

Environment Variables

VariableDescription
AUGMENT_API_TOKENAPI authentication token
AUGMENT_API_URLAPI base URL
CONTEXT_ENGINE_DEBUGEnable debug logging

Configuration

Credentials are resolved in order:

  1. Command-line options
  2. Environment variables
  3. Session file (~/.augment/session.json)

MCP Tools (72 Total)

Retrieval Tools (7)

ToolDescription
codebase_retrievalSemantic search across the codebase
semantic_searchSearch for code patterns and text
get_fileRetrieve file contents with optional line range
get_context_for_promptGet comprehensive context bundle
enhance_promptAI-powered prompt enhancement with context injection
bundle_promptBundle raw prompt with codebase context (no AI rewriting)
tool_manifestDiscover available capabilities

Index Tools (5)

ToolDescription
index_workspaceIndex files for semantic search
index_statusCheck indexing status
reindex_workspaceClear and rebuild index
clear_indexRemove index state
refresh_indexRefresh the codebase index

Memory Tools (6)

ToolDescription
store_memoryStore persistent memories
retrieve_memoryRecall stored memories
list_memoryList all memories
delete_memoryDelete a memory
memory_storeStore with rich metadata (kind, language, tags, priority)
memory_findHybrid search with filtering

Planning Tools (20)

ToolDescription
create_planCreate AI-powered implementation plans
get_planGet plan details
list_plansList all plans
add_stepAdd a step to a plan
update_stepUpdate step status
refine_planRefine plan with AI
visualize_planGenerate visual representation
execute_planExecute plan steps
save_planSave plan to storage
load_planLoad plan from storage
delete_planDelete a plan
start_stepMark step as in progress
complete_stepMark step as completed
fail_stepMark step as failed
view_progressView plan progress
view_historyView execution history
request_approvalCreate approval request
respond_approvalRespond to approval request
compare_plan_versionsGenerate diff between versions
rollback_planRollback to previous version

Review Tools (14)

ToolDescription
review_diffReview code changes with risk analysis
analyze_riskAnalyze risk level of changes
review_changesReview code changes in files
review_git_diffReview current git diff
review_autoAutomatically review recent changes
check_invariantsCheck code invariants
run_static_analysisRun static analysis
scrub_secretsScan for potential secrets
validate_contentValidate content against rules
get_review_statusGet review status
reactive_review_prStart parallelized PR review
pause_reviewPause a running review session
resume_reviewResume a paused review session
get_review_telemetryGet detailed review metrics

Navigation Tools (3)

ToolDescription
find_referencesFind all references to a symbol
go_to_definitionNavigate to symbol definition
diff_filesCompare two files with unified diff

Workspace Tools (7)

ToolDescription
workspace_statsGet workspace statistics and metrics
git_statusGet current git status
extract_symbolsExtract symbols from a file
git_blameGet git blame information
git_logGet git commit history
dependency_graphGenerate dependency graph
file_outlineGet file structure outline

Specialized Search Tools (7)

ToolDescription
search_tests_forFind test files with preset patterns
search_config_forFind config files (yaml/json/toml/ini/env)
search_callers_forFind callers/usages of a symbol
search_importers_forFind files importing a module
info_requestSimplified retrieval with explanation mode
pattern_searchStructural code pattern matching
context_searchContext-aware semantic search

Skills Tools (3)

ToolDescription
list_skillsList all available Agent Skills
search_skillsSearch skills by query (metadata only)
load_skillLoad full skill instructions on demand

Agent Skills

Context Engine implements the Tool Search Tool pattern for progressive disclosure of Agent Skills. This reduces token overhead by ~75% compared to loading all tool definitions upfront.

Available Skills

SkillCategoryDescription
planningworkflowTask planning and execution for complex multi-step tasks
code_reviewqualityComprehensive code review workflow
search_patternssearchSpecialized search patterns for tests, configs, callers
debuggingtroubleshootingSystematic debugging workflow for identifying and fixing bugs
refactoringqualitySafe code refactoring workflow with impact analysis
documentationqualityDocumentation generation and maintenance workflow
testingqualityComprehensive test writing and maintenance workflow

How Skills Work

  1. Discovery: Call list_skills() or search_skills(query) to find relevant skills
  2. Loading: Call load_skill(id) to get full instructions
  3. Execution: Follow the skill instructions using primitive MCP tools
  4. Via Prompts: Skills are also available as MCP prompts (e.g., skill:debugging)

Skills are loaded from skills/ directory as SKILL.md files following the Agent Skills specification.

Client Compatibility

ClientHow Skills Are Accessed
Claude CodeNative Agent Skills support (reads SKILL.md directly)
CursorMCP tools (search_skills, load_skill)
GitHub CopilotAGENTS.md + MCP tools
WindsurfMCP tools
VS Code + ContinueMCP prompts (skill:*)
OpenAI CodexAGENTS.md

Architecture

src/
├── main.rs # Entry point with CLI
├── lib.rs # Library exports
├── error.rs # Error types
├── config/ # Configuration management
├── sdk/ # Augment API client
│ ├── api_client.rs # HTTP client
│ ├── blob.rs # SHA256 blob naming
│ ├── credentials.rs # Auth resolution
│ └── direct_context.rs # Context operations
├── service/ # Business logic layer
│ ├── context.rs # Context service
│ ├── memory.rs # Memory service
│ └── planning.rs # Planning service
├── mcp/ # MCP protocol layer
│ ├── server.rs # MCP server
│ ├── handler.rs # Request handler
│ ├── protocol.rs # JSON-RPC types
│ └── transport.rs # Stdio/HTTP transports
├── tools/ # MCP tool implementations
├── reviewer/ # Code review pipeline
├── reactive/ # Reactive review system
├── watcher/ # File system watcher
├── http/ # HTTP server (axum)
├── metrics/ # Prometheus metrics
└── types/ # Shared type definitions

Docker Support

The Docker image is ~20 MB (Alpine-based with statically linked binary).

Build Docker Image

docker build -t context-engine .

Run with Docker

# HTTP mode
docker run -d \
-v /path/to/project:/workspace:ro \
-v ~/.augment:/home/context-engine/.augment:ro \
-p 3000:3000 \
-p 9090:9090 \
context-engine \
--workspace /workspace \
--transport http \
--metrics
# Stdio mode (for MCP integration)
docker run -i \
-v /path/to/project:/workspace:ro \
-v ~/.augment:/home/context-engine/.augment:ro \
context-engine \
--workspace /workspace

Docker Compose

# Set your project pathexport PROJECT_PATH=/path/to/project
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down

Development

Running Tests

# Run all unit tests (170 tests)
cargo test --lib
# Run integration tests (basic CLI tests)
cargo test --test mcp_integration_test
# Run full integration tests including MCP protocol tests
cargo test --test mcp_integration_test -- --ignored
# Run all tests
cargo test --all-targets

Test Categories

CategoryCountDescription
Unit Tests201Core functionality tests
Integration Tests11MCP protocol and CLI tests

Linting

cargo clippy --all-targets --all-features -- -D warnings

Formatting

cargo fmt

Code Coverage

# Install cargo-tarpaulin
cargo install cargo-tarpaulin
# Run with coverage
cargo tarpaulin --out Html

MCP Client Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
"mcpServers": {
"context-engine": {
"command": "/path/to/context-engine",
"args": ["--workspace", "/path/to/your/project"]
}
}
}

Cursor

Add to your MCP configuration:

{
"context-engine": {
"command": "/path/to/context-engine",
"args": ["--workspace", "."]
}
}

License

MIT License - See LICENSE file for details.

About

MCP Server for semantic code search and AI-powered prompt enhancement using Augment SDK

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages