Skip to main content

Token-optimized semantic code search MCP server for AI coding assistants

Project description

WashedMCP — Token-Optimized Semantic Code Search

An MCP (Model Context Protocol) server that provides token-efficient semantic code search with automatic context expansion for AI coding assistants.

The Problem

When AI assistants search codebases, they get isolated results without context:

  • Need multiple searches to understand call chains
  • Waste tokens on redundant lookups
  • Lose context between tool calls

The Solution

WashedMCP returns comprehensive context in a single search:

Query: "user validation logic"

FOUND: validate() in src/auth.js:42 (82% match)

CODE:
  function validate(data) {
    if (!checkEmail(data.email)) return false;
    if (!checkPassword(data.password)) return false;
    return sanitize(data);
  }

CALLS: checkEmail, checkPassword, sanitize
CALLED BY: processUser, createUser
SAME FILE: [sanitize, normalizeInput, validateSchema]

One search → full context → immediate action.

Features

  • Semantic Search — Find code by meaning, not just keywords
  • Context Expansion — Automatically include callers/callees
  • Code Graph — Track function relationships (calls, called_by)
  • TOON Format — Token-Optimized Object Notation (~30-40% fewer tokens than JSON)
  • Multi-Language — Python, JavaScript, TypeScript, JSX, TSX

Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Index Your Codebase

python src/cli.py index /path/to/your/codebase

3. Search

python src/cli.py search "authentication flow"

4. Use with Claude Code

Add to .mcp.json:

{
  "mcpServers": {
    "washedmcp": {
      "command": "python3",
      "args": ["src/mcp_server.py"]
    }
  }
}

MCP Tools

Tool Description
index_codebase Index a codebase for semantic search
search_code Search with context expansion (depth parameter)
get_index_status Check if codebase is indexed

How It Works

┌─────────────────────────────────────────────────┐
│               CONTEXT EXPANSION                  │
├─────────────────────────────────────────────────┤
│                                                  │
│  Query: "validation failing"                     │
│              │                                   │
│              ▼                                   │
│  ┌────────────────────────────┐                 │
│  │  1. Semantic Search        │                 │
│  │     (embeddings + cosine)  │                 │
│  └────────────────────────────┘                 │
│              │                                   │
│              ▼                                   │
│  ┌────────────────────────────┐                 │
│  │  2. Context Expansion      │                 │
│  │     • CALLS: [...]         │                 │
│  │     • CALLED BY: [...]     │                 │
│  │     • SAME FILE: [...]     │                 │
│  └────────────────────────────┘                 │
│              │                                   │
│              ▼                                   │
│  ┌────────────────────────────┐                 │
│  │  3. TOON Output            │                 │
│  │     (token-efficient)      │                 │
│  └────────────────────────────┘                 │
│                                                  │
└─────────────────────────────────────────────────┘

Tech Stack

  • Parsing: tree-sitter (multi-language AST extraction)
  • Embeddings: sentence-transformers/all-MiniLM-L6-v2
  • Vector DB: ChromaDB (persistent, cosine similarity)
  • MCP: fastmcp
  • Summarization: Google Generative AI (optional)

Project Structure

washedmcp/
├── src/
│   ├── parser.py         # AST parsing + call extraction
│   ├── embedder.py       # Embedding generation
│   ├── database.py       # ChromaDB + relationships
│   ├── indexer.py        # Indexing orchestration
│   ├── searcher.py       # Search + context expansion
│   ├── summarizer.py     # Function summarization
│   ├── toon_formatter.py # TOON output format
│   ├── mcp_server.py     # MCP server
│   └── cli.py            # CLI interface
├── tests/                 # Test codebase samples
├── docs/                  # Design documents
└── requirements.txt       # Dependencies

Context Expansion Depth

Control how many hops of relationships to include:

  • depth=1 (default): Direct callers + callees
  • depth=2: Include callers of callers (for debugging chains)
# MCP tool call
search_code(query="validation", depth=2)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

washedmcp-0.1.0.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

washedmcp-0.1.0-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

Details for the file washedmcp-0.1.0.tar.gz.

File metadata

  • Download URL: washedmcp-0.1.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for washedmcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15bfda80d50449633cd3a58d1c9d00b801df33c4b47b6c1962cb9e724b23f366
MD5 02f24bdb060b7a3640125040cd62b4ba
BLAKE2b-256 d0704413ebb40d0fba23d1c386d1de6d30f724da0d0f80216a6e50adbabcd35c

See more details on using hashes here.

File details

Details for the file washedmcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: washedmcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for washedmcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a8ae2b6d92b89e44bc3298232d42b64815c92d8a640066e0efa54ad6df2c295
MD5 3740050df10b27a126c9f9294c198395
BLAKE2b-256 96c279e8223e4e0360c63e7a434fe69273f60dace6f14a04ca88f8544f4758f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page