TL;DR
Modern AI coding assistants (Cursor, Claude Code, Windsurf, Cline) often dump 30,000+ to 120,000+ raw tokens per instruction, causing high latency, attention degradation ("Lost in the Middle"), and substantial API costs ($75+ per 1,000 requests).
We built NeuroMesh—a native Rust runtime and Model Context Protocol (MCP) server that applies biological routing (Physarum Polycephalum slime mold algorithms) and Genetic AST Slicing to reduce context size by 99.6% (from 25,000 raw tokens down to 96 tokens) while achieving a 100% Pass@1 rate.
🌿 NeuroMesh v0.2.7
The Biomimetic Context Engine & Neural Runtime for AI Coding Assistants
"Do not delete context. Deactivate it. Do not repeatedly rediscover the project. Learn it."
Quick Start • Features • Architecture • MCP Tools • Benchmarks • Web UI
💡 What is NeuroMesh?
NeuroMesh is a local-first, high-performance neural context runtime written natively in Rust. Operating as a Model Context Protocol (MCP) server with an embedded 3D/2D Web UI Monitor Dashboard, NeuroMesh solves context saturation and token bloat for modern AI coding tools (Cursor, Claude Desktop, Windsurf, VS Code, Roo Code, Continue.dev, Zed, Aider, Hermes).
Instead of blindly dumping thousands of lines of raw files into an LLM's context window—causing the notorious Lost in the Middle attention degradation, high latency, and massive token bills—NeuroMesh applies nature-inspired biomimetic algorithms to extract and deliver hyper-lean, 100% sound AST subgraphs with reversible code folds.
📑
…The Problem: The Cost and Degradation of Naive Context Injection
Most modern AI coding tools rely on naive context retrieval: when a task is received, dozens of entire source files are read from disk and concatenated directly into the LLM prompt.
flowchart LR
subgraph Traditional["Traditional Context Injection"]
direction TB
B1["User Task"] --> B2["Inject Raw Files (25k+ Tokens)"] --> B3["Attention Degradation & $75/1k Bills"]
end
subgraph NeuroMesh["NeuroMesh Biomimetic Engine"]
direction TB
G1["User Task"] --> G2["Physarum Routing & Genetic AST Slicing"] --> G3["Lean Context (96 Tokens) & 100% Pass@1"]
end
This brute-force strategy introduces three technical problems:
- Attention Degradation (Lost in the Middle): As context windows expand with irrelevant boilerplate, LLM attention mechanisms lose track of subtle domain constraints and variable declarations, increasing hallucination rates.
- Prefill Latency Penalty: Transmitting and processing tens of thousands of unneeded tokens introduces a 3 to 5-second Time-To-First-Token (TTFT) delay on every prompt.
- Compounding API Costs: At current frontier model pricing ($3.00/1M input tokens), naive context injection costs ~$75.00 per 1,000 requests. For an engineering team running hundreds of daily queries, this translates to thousands of dollars in wasted context tokens.
"Do not delete context. Deactivate it. Do not repeatedly rediscover the project. Learn it."
The Architecture: Nature-Inspired Context Runtime
Biological systems solved information routing and signal filtering with extreme energy efficiency millions of years ago. NeuroMesh translates five biological mechanisms into a local-first, native Rust architecture:
flowchart TD
Prompt["Task Intent / User Prompt"] --> TaskSig["1. Intent & Task Signature Extractor"]
TaskSig --> Physarum["2. Physarum Polycephalum Solver<br/>(Minimal Steiner Subgraph Discovery)"]
Physarum --> Hebb["3. Synaptic Hebbian STDP Plasticity<br/>(Reinforce Active Co-Access Edges)"]
Hebb --> Slicer["4. Bio-Genetic Code Slicing<br/>(Exon Preservation & Intron Folding)"]
Slicer --> Membrane["5. Cellular Osmotic Gate Membrane<br/>(Dynamic Permeability & Risk Tuning)"]
Membrane --> Output["6. Minimal Reversible Context View"]
1. Physarum Polycephalum (Slime Mold) Routing
Physarum polycephalum is a single-celled organism capable of solving optimal Steiner network problems without centralized control.
NeuroMesh models codebase symbols (functions, types, imports, call-graphs) as tubular network channels. When a user requests a change, the engine simulates Hagen-Poiseuille cytoplasmic fluid flux:
$$Q_{ij} = \frac{D_{ij}}{L_{ij}}(p_i - p_j)$$
Channels with high informational flux dilate, while inactive branches atrophy. This allows the solver to isolate the exact minimal Steiner subgraph connecting seed symbols in local RAM in <25 ms.
2. Genetic Code Slicing (Exons vs. Introns)
In molecular biology, exons are the coding sequences expressed in proteins, while non-coding introns are spliced out.
Using embedded Tree-Sitter parsers in Rust, NeuroMesh splits files into:
- Exons: Active target functions, critical type signatures, imported interfaces, and invariants.
- Introns: Inactive implementations folded into single-line reversible markers.
// Active target method remains fully unfolded:
const renderCart = () => {
const items = document.querySelector("[data-cart-items]");
const totalEl = document.querySelector("[data-cart-total]");
/* [neuromesh:fold:fold_if_3 | 7 lines folded | if (!items || !totalEl) return;] */
document.querySelectorAll("[data-cart-count]").forEach((el) => (el.textContent = count));
totalEl.textContent = money(total);
// ... active cart logic
};
// Untargeted functions are safely folded into reversible markers:
/* [neuromesh:fold:fold_slider_17 | 14 lines folded | if (!root) return;] */
/* [neuromesh:fold:fold_anim_18 | 6 lines folded | stop();] */
Reversible Lazy Context Materialization
If the AI agent requires the full body of a folded block during reasoning, it calls neuromesh_expand_fold via MCP, expanding only that specific fold on demand without re-ingesting the whole project.
3. Synaptic STDP Plasticity (Hebbian Learning)
NeuroMesh maintains an in-memory graph where edges adapt using Spike-Timing-Dependent Plasticity (STDP):
- Long-Term Potentiation (LTP): Co-edited files and co-referenced symbols strengthen their synaptic conductance ($w_{ij} \leftarrow w_{ij} + \Delta w$).
- Long-Term Depression (LTD): Distracting or unreferenced paths decay over time, making future context discovery faster and more accurate as development progresses.
4. Mycelial Hyphal Predictive Cache
Modeling symbol access as fungal nutrient gradients, NeuroMesh predicts downstream AST dependencies during keystrokes and pre-warms them in memory before an inference call is initiated.
5. Cellular Membrane Osmotic Quality Gate
Acts as a dynamic biological membrane that regulates context permeability (Hyper-Impermeable AST vs. Fully Permeable bodies) based on task risk tier, code complexity, and token budget constraints.
Empirical Benchmarks
We evaluated NeuroMesh against traditional raw context injection across 24 full-stack codebase files (pricing engines, auth middleware, payment webhooks, database pools):
| Benchmark Metric | Traditional Raw Context | NeuroMesh v2.0 | Improvement |
|---|---|---|---|
| Average Input Tokens per Task | 24,994 tokens | 96.8 tokens | 99.61% Reduction |
| Automated Test Pass Rate (Pass@1) | 90.0% | 100.0% (10/10 Passed) | +10.0% Precision |
| Local Graph Traversal Latency | N/A | 24.4 ms | Sub-50ms Context Delivery |
| API Cost per 1,000 Prompts (Claude 3.7 / GPT-4.5) | $74.98 | $0.29 | 99.6% Cost Reduction |
| Resident Memory Footprint (RAM) | N/A | ~195 MB | Ultra-lightweight |
| Concurrent Request Throughput | N/A | 20 req in 853 ms | 100% Zero-drop Concurrency |
Financial ROI Analysis
For an engineering team of 10 developers generating 500 prompts per day on Frontier LLMs:
-
Traditional Context Cost:
(5,000 × 24,994 × $0.000003) × 30= ~$3,374.19 / month -
NeuroMesh Cost:
(5,000 × 96.8 × $0.000003) × 30= ~$13.06 / month - Net Annual Financial Savings: $40,333.56 / year
pie title Monthly API Expenditure (10 Devs / 500 prompts per day)
"Traditional Raw Context ($3,374 / mo)" : 3374
"NeuroMesh ($13 / mo)" : 13
Embedded Web UI Monitor
NeuroMesh includes a zero-dependency local dashboard running on http://127.0.0.1:8765:
- 3D Constellation Explorer: Real-time visual graph of your codebase modules, symbols, and synaptic weights.
- Context Flow Simulator: Step-by-step visual inspection of Ingestion, Physarum routing, Hebbian plasticity, and AST slicing.
- Telemetry & Health: Live monitoring of token compression ratios, RAM consumption, and query latencies.
# Launch the Web UI Monitor and MCP Server
neuromesh monitor
Quick Start
NeuroMesh is packaged as a single native Rust binary with zero external runtime dependencies.
Installation
macOS & Linux (Bash / Zsh):
curl -fsSL https://raw.githubusercontent.com/pinoox/neuromesh/main/install.sh | bash
Windows (PowerShell):
irm https://raw.githubusercontent.com/pinoox/neuromesh/main/install.ps1 | iex
Cargo (Rust Developers):
cargo install --git https://github.com/pinoox/neuromesh.git neuromesh-cli --bin neuromesh
Universal MCP Configuration
NeuroMesh implements the open Model Context Protocol (MCP) and integrates with major AI coding environments:
Cursor IDE
Add to .cursor/mcp.json (or via Cursor Settings > Features > MCP):
{
"mcpServers": {
"neuromesh": {
"command": "neuromesh",
"args": ["mcp"]
}
}
}
VS Code / GitHub Copilot / Cline / Roo Code
Add to .vscode/mcp.json or cline_mcp_settings.json:
{
"mcpServers": {
"neuromesh": {
"command": "neuromesh",
"args": ["mcp"]
}
}
}
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"neuromesh": {
"command": "neuromesh",
"args": ["mcp"]
}
}
}
Claude Code CLI
claude mcp add neuromesh -- neuromesh mcp
Windsurf IDE & Zed Editor
Add neuromesh mcp to your respective editor MCP configuration.
Exposed MCP Tools
Once connected, your AI agents gain access to the following native tools:
-
neuromesh_get_context: Task-driven Physarum Steiner context routing. -
neuromesh_get_file_skeleton: Generates AST skeletons with active exons and folded introns. -
neuromesh_expand_fold: Reversibly unpacks any folded block on demand. -
neuromesh_search_symbols: Fast fuzzy symbol lookup across files, types, and functions. -
neuromesh_get_dependencies: Dependency and call-graph tracing. -
neuromesh_record_feedback: Updates Hebbian synaptic weights based on code generation success.
Open Source & Roadmap
NeuroMesh is open-source under the MIT License.
- GitHub Repository: github.com/pinoox/neuromesh
- Architecture Documentation: ARCHITECTURE.md
- Empirical Benchmark Report: BENCHMARK.md
Discussion
How are you managing context size and token budgets in your AI-assisted workflows? Have you experimented with AST slicing or graph-based context retrieval? Let's discuss in the comments.

Top comments (0)