context-architect
Supports context-aware analysis, skeletonization, and JIT hydration of Actix-web projects for token optimization.
Supports CrewAI multi-agent swarms with subagent sandboxing, state rewind, and token-budget management.
Supports context-aware analysis and optimization of Django projects.
Supports context-aware analysis and optimization of Express/Node.js projects.
Supports context-aware analysis and optimization of FastAPI projects.
Supports context-aware analysis and optimization of Fastify projects.
Supports context-aware analysis and optimization of Flask projects.
Supports context-aware analysis and optimization of Gin projects.
Integrates with GitHub Copilot via agent rules to apply context-window management, token reduction, and prompt-cache optimization.
Integrates with Google Antigravity and Gemini CLI to manage context windows, cache prompts, and monitor token usage.
Supports context-aware analysis and optimization of LangChain projects.
Supports LangGraph multi-agent swarms with subagent sandboxing, state rewind, and token-budget management.
Supports context-aware analysis and optimization of Laravel projects.
Supports context-aware analysis and optimization of NestJS projects.
Supports context-aware analysis and optimization of .NET projects, including ASP.NET Core.
Supports context-aware analysis and optimization of Next.js projects.
Supports context-aware analysis and optimization of PyTorch codebases.
Supports context-aware analysis and optimization of Quarkus projects.
Supports context-aware analysis and optimization of React projects.
Supports context-aware analysis and optimization of Rocket (Rust) projects.
Supports context-aware analysis and optimization of Ruby on Rails projects.
Supports context-aware analysis and optimization of Spring Boot projects.
Supports context-aware analysis and optimization of Symfony projects.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@context-architectTrim context to last 10 messages and summarize the rest to save tokens."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π§ Context-Architect
Universal Autonomous Context Window Management, Prompt Caching, Token Optimization & Observability AI Skill Agent
Slash LLM API costs by 80%β90%, guarantee β₯85% prompt cache hits, eliminate Lost-in-the-Middle degradation, and monitor context telemetry in real time across any IDE and any AI Agent.
π Overview
Context-Architect is an industrial-grade autonomous skill agent and MCP server engineered to eliminate LLM context window exhaustion, prevent cognitive degradation (Lost-in-the-Middle phenomenon), maximize KV-cache reuse, and provide end-to-end token observability for autonomous coding agents.
Operating with zero external dependencies on native Node.js (v18+), Context-Architect dynamically slices massive codebases, collapses verbose logs/diffs, manages a 3-tier memory hierarchy, and enforces deterministic prompt layoutsβenabling AI agents to maintain lightning-fast response times and up to 90% token cost reduction.
Core Highlights:
π Zero External Dependencies: Pure native Node.js ES Module with sub-45ms execution latency. No external compiler or tree-sitter binaries needed.
β‘ 80%β90% Token Reduction: Zero-compiler AST structural skeletonization and Just-in-Time (JIT) line-range hydration.
π° Deterministic KV-Cache Freezing: Invariant prefix ordering guaranteeing β₯85%β95% prompt cache hit rates on Claude 3.7/3.5 Sonnet, Gemini 2.0/1.5, DeepSeek-V3, and OpenAI GPT-4o.
π― Lost-in-the-Middle Elimination: Dual-Anchor layout (Primacy at Head, Recency at Tail) ensuring 100% adherence to critical constraints.
βͺ Tree-of-Thought State Rewind: Snapshot save & instant rollback preventing context pollution during failed exploration loops.
π‘οΈ Subagent Micro-Capsule Sandboxing: Strict
<8ktoken scoping for multi-agent swarms (LangGraph, AutoGen, CrewAI).π Built-in Live Observability Sub-Engine: Real-time ASCII/ANSI terminal TUI dashboard and standalone responsive HTML/SVG reports.
π 100% Universal Agent Compatibility: 11 Native MCP tools and seamless adapters for Google Antigravity, Cursor, Claude Code, Windsurf, Kiro, Copilot, Cline, and Continue.dev.
Related MCP server: GraphHub
ποΈ System Architecture
%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#7aa2f7', 'primaryBorderColor': '#3d59a1', 'actorBkg': '#24283b', 'actorBorder': '#7aa2f7', 'lineColor': '#bb9af7', 'altBkg': '#1f2335' }}}%%
graph TB
subgraph ClientLayer ["1. Universal Agent & IDE Layer"]
A1["Google Antigravity<br/>(@context-architect)"]
A2["Cursor<br/>(.cursor/rules/*.mdc)"]
A3["Claude Code<br/>(CLAUDE.md)"]
A4["Windsurf<br/>(.windsurfrules)"]
A5["Kiro IDE<br/>(.kiro/steering/*.md)"]
A6["VS Code / Copilot<br/>(.github/copilot-instructions)"]
A7["Roo Code / Cline<br/>(.clinerules)"]
A8["Continue.dev<br/>(.continue/rules/*.md)"]
A9["Multi-Agent Swarms<br/>(LangGraph / AutoGen / CrewAI)"]
end
subgraph CoreEngine ["2. Context-Architect Core Orchestrator"]
C1["MCP JSON-RPC Protocol & CLI Dispatcher"]
C2["Tokenizer & Pareto Budget Allocator"]
C3["Early Warning Pressure Gauge (Green/Amber/Red/Panic)"]
end
subgraph SevenPillars ["3. The 7 Optimization Pillars"]
P1["P1: Token Telemetry<br/>& Cost Model"]
P2["P2: AST JIT Slicing<br/>& Skeletonizer"]
P3["P3: Log & Diff<br/>Collapser"]
P4["P4: Tri-Tier Memory<br/>& Semantic GC"]
P5["P5: KV-Cache Prefix<br/>Freezing"]
P6["P6: State Rewind &<br/>Subagent Sandbox"]
P7["P7: Stream Guard &<br/>Secret Scrubber"]
end
subgraph ObservabilityLayer ["4. Observability & Layout Sub-Engine"]
O1["Dual-Anchor Layout Assembler (Head 15% / Mid 70% / Tail 15%)"]
O2["Live Terminal TUI Dashboard"]
O3["Standalone HTML / Markdown Telemetry Reports"]
end
ClientLayer --> CoreEngine
CoreEngine --> SevenPillars
SevenPillars --> ObservabilityLayerArchitecture Narrative (WCAG 2.2 AA Textual Description):
Universal Agent Layer: AI assistants (Antigravity, Cursor, Claude Code, Windsurf, Kiro, Copilot, Cline, Continue.dev, LangGraph, AutoGen) send execution contexts and prompts to the Context-Architect Core Orchestrator.
Core Orchestrator: The MCP JSON-RPC protocol router, Universal Tokenizer, and Early Warning Pressure Gauge evaluate token pressure (Green, Amber, Red, Panic) and assign optimal Pareto budgets across system invariants, active code, history, memory, and output headroom.
The 7 Optimization Pillars:
Pillar 1 (Telemetry) calculates real-time token consumption across models (cl100k, o200k, Gemini, Claude, Llama).
Pillar 2 (AST Slicing) creates zero-compiler AST skeletons and hydrates focused line ranges Just-in-Time.
Pillar 3 (Compression) collapses repetitive test logs and minimalizes unified git diffs.
Pillar 4 (Memory) manages Hot Working Memory, Warm Episodic Fact Anchors, and Cold Archival Store with native BM25 search.
Pillar 5 (Prompt Caching) enforces deterministic static prefix freezing for 100% cache hits.
Pillar 6 (Branching) enables Tree-of-Thought state snapshots, rewind, and subagent micro-capsule sandboxing.
Pillar 7 (Guardrails) clamps tool output buffers and redacts sensitive credentials.
Observability Sub-Engine: The Dual-Anchor Layout Assembler places critical directives at the Head (15%) and immediate user objectives at the Tail (15%) with middle code skeletons (70%), accompanied by Live Terminal TUI Dashboards and interactive HTML telemetry reports.
π Supported Language Profiles
Context-Architect includes native, zero-compiler language profiles for all major ecosystems:
Ecosystem | Manifest File | Typical Frameworks Supported | File Extensions |
TypeScript / JavaScript |
| NestJS, Express, Next.js, Fastify, React, Vue |
|
Python |
| FastAPI, Django, Flask, PyTorch, LangChain |
|
Go |
| Gin, Fiber, Echo, Standard |
|
Java / Kotlin / C# |
| Spring Boot, Quarkus, ASP.NET Core |
|
Rust |
| Axum, Actix-web, Tokio, Rocket |
|
PHP |
| Laravel, Symfony, Slim |
|
Ruby |
| Ruby on Rails, Sinatra |
|
Generic Fallback | Any text file | Standard Clean Architecture, REST, Config | All text code files |
π― Choose Your Integration Method
Context-Architect offers three equal, high-fidelity integration paths:
Feature | Method A: Universal MCP Server | Method B: Pure Skill Agent / Rule | Method C: Terminal CLI |
Node.js Required? | Yes (Node.js >= 18.0.0 via | No (Zero Runtime Dependencies) π | Yes (CLI Runner) |
How it Operates | Runs in background via stdio JSON-RPC | LLM Agent's native reasoning engine | Executed directly from terminal |
Best For | Autonomous tool-calling & swarms | Environments without Node.js daemon | Scripts, CI/CD & Quick Audits |
Setup | Add MCP JSON to IDE settings | Drop rule/skill file into repository | Run |
π Quick Start
π¬ Method A: AI Agent Chat via MCP (Recommended β Requires Node.js)
Add Context-Architect directly to your AI IDE (Cursor, Claude Desktop, Google Antigravity, Windsurf, Kiro, Continue.dev, etc.) via MCP:
{
"mcpServers": {
"context-architect": {
"command": "npx",
"args": [
"-y",
"github:hanifalkauni/context-architect",
"--mcp"
]
}
}
}Now prompt your AI assistant naturally in chat:
"@context-architect inspect current token consumption and optimize our prompt layout"
(or: "slicesrc/services/PaymentService.tsto skeleton and focus onprocessPayment()")
The agent autonomously invokes the native MCP tools, optimizes the context window, and isolates root cause errorsβno manual intervention needed!
π Method B: Pure Skill Agent / Rule File (No Node.js Required)
If you don't have Node.js running as an MCP background daemon, you can still use Context-Architect with 100% fidelity by adding the rule/skill adapter directly into your project:
π Option 1: Automatic via skills.sh (Recommended β 30+ AI Agents)
Install with a single command directly into Cursor, Claude Code, Windsurf, Copilot, or Gemini CLI:
npx skills add hanifalkauni/context-architectβ‘ Option 2: Automatic Adapter Injection via CLI
Run this command in any target project root to export all agent adapters automatically:
npx -y github:hanifalkauni/context-architect initπ¦ Option 3: Manual Installation per AI Agent
Copy adapter to local workspace skill directory:
mkdir -p .agents/skills/context-architect
cp adapters/antigravity/SKILL.md .agents/skills/context-architect/SKILL.mdOr install globally for all workspaces at: ~/.gemini/config/skills/context-architect/SKILL.md.
Copy rules to your Cursor directory:
mkdir -p .cursor/rules
cp adapters/cursor/context-architect.mdc .cursor/rules/context-architect.mdcCopy steering file and MCP configuration to your Kiro project:
mkdir -p .kiro/steering
cp adapters/kiro/context-architect.md .kiro/steering/context-architect.md
# (Optional) For MCP mode in Kiro:
cp adapters/kiro/config.json .kiro/config.jsonCopy instructions to your project root:
cp adapters/claude/CLAUDE.md ./CLAUDE.mdFor Claude Desktop, configure the MCP server using Method A above.
Copy rules to your repository root:
cp adapters/windsurf/.windsurfrules ./.windsurfrulesCopy instructions to your GitHub configuration directory:
mkdir -p .github
cp adapters/copilot/copilot-instructions.md .github/copilot-instructions.mdCopy rules to your project root:
cp adapters/cline/.clinerules ./.clinerulesCopy rules and configuration to your Continue directory:
mkdir -p .continue/rules
cp adapters/continue/context-architect.md .continue/rules/context-architect.md
# (Optional) For MCP mode in Continue:
cp adapters/continue/config.json .continue/config.jsonImport the Python or TypeScript middleware directly into your multi-agent workflow:
TypeScript:
adapters/frameworks/langgraph.tsPython:
adapters/frameworks/autogen.pyoradapters/frameworks/crewai.py
Your AI Agent will read the rule file and enforce the 7 Pillars of Context Optimization directly using its native reasoning engineβzero runtime installation needed!
π» Method C: Terminal CLI (For Scripts, CI/CD, or Standalone Use)
Execute token optimization and context telemetry directly from your terminal:
# View live context status & health dashboard
npx -y github:hanifalkauni/context-architect status
# Live monitoring mode with real-time refresh
npx -y github:hanifalkauni/context-architect monitor --live
# Audit repository token bloat and AST compression potential
npx -y github:hanifalkauni/context-architect audit ./src --html ./context-report.html
# Slice a large source code file into a lightweight structural AST skeleton
npx -y github:hanifalkauni/context-architect slice ./src/services/PaymentService.ts
# Focus AST slice on a specific symbol & its dependencies
npx -y github:hanifalkauni/context-architect slice ./src/services/PaymentService.ts --focus processPayment
# Compress test logs, stack traces, or git diffs
npx -y github:hanifalkauni/context-architect compress ./test-output.log
# Generate standalone visual HTML report
npx -y github:hanifalkauni/context-architect report --format html --out ./context-report.html
# (Optional) Inject IDE rule adapters into your project
npx -y github:hanifalkauni/context-architect init --ide cursor,windsurf,kiro --role coder(Or use node ./bin/context-architect.js --mcp if developing locally)
π οΈ The 11 Native MCP Tools
Tool Name | Key Parameters | Description |
|
| Inspects token counts, pricing, and pressure gauge status for a given payload. |
|
| Performs a comprehensive context health check, memory count, and optimization recommendation. |
|
| Exports a standalone visual telemetry report. |
|
| Slices code into a zero-compiler AST skeleton or focuses on target symbol contracts. |
|
| Collapses verbose test logs, minimalizes unified git diffs, or condenses file trees. |
|
| Compacts multi-turn conversation history into Tier-2 structured Fact Anchors ( |
|
| Captures an atomic context state snapshot for Tree-of-Thought branch exploration. |
|
| Restores a saved snapshot, instantly purging failed exploration turns. |
|
| Creates an isolated |
|
| Stores or retrieves long-term knowledge from Tier-3 Archival Store using native BM25 ranking. |
|
| Assembles final prompt with deterministic KV-cache prefix freezing & dual-anchoring. |
π Multi-IDE & Multi-Agent Compatibility
Platform / Framework | Configuration / Adapter | Usage Mode |
Google Antigravity IDE |
| Native skill ( |
Cursor |
| Prompt Agent Mode / Composer |
Claude Code |
| Slash command or automatic MCP tool invocation |
Windsurf |
| Cascade auto-injection |
Kiro IDE |
| Steering Prompt / MCP tools |
VS Code / Copilot |
|
|
Roo Code / Cline |
| MCP tool suite invocation |
Continue.dev |
| Context Rule & MCP tool invocation |
LangGraph / AutoGen / CrewAI |
| Python / TypeScript SDK tool injection |
π Evaluation & Token Efficiency Benchmarks
Test Scenario | Raw Baseline | Context-Architect Target | Savings / Improvement |
Large Class File (2,500 LOC TS/Java) | $\approx 18,500$ tokens | $\approx 2,100$ tokens | 88.6% Token Reduction |
Failed Test Suite Log (800 lines) | $\approx 6,200$ tokens | $\approx 580$ tokens | 90.6% Token Reduction |
Multi-Turn Trajectory (25 turns) | $\approx 65,000$ tokens | $\approx 9,500$ tokens | 85.4% Token Reduction |
KV-Cache Reuse Rate ($\ge 20$ turns) | $0%$ (Cache Misses) | $\ge 88.5%$ (Prefix Frozen) | 80%β90% API Cost Slash |
State Rewind Latency on Error Loop | $N/A$ (Polluted Context) | $12\text{ ms}$ (Clean Restore) | Zero Cognitive Contamination |
Needle-in-a-Haystack at 50% Depth | $\approx 54%$ Accuracy | $\ge 96.5%$ Accuracy | Solved Lost-in-the-Middle |
π§ͺ Testing & Validation
Context-Architect includes a complete zero-dependency test suite covering all 11 MCP tools, slicers, memory tiers, and compressors:
npm testπ§ͺ Running Context-Architect Test Suite...
β
PASS: Tokenizer & Model Database
β
PASS: Pressure Gauge & Budget Allocator
β
PASS: AST Engine - TypeScript Slicing
β
PASS: AST Engine - Python Slicing
β
PASS: AST Engine - Go Slicing
β
PASS: Dependency Slicer & JIT Hydrator
β
PASS: Log Collapser
β
PASS: Diff Minimalizer
β
PASS: Tree Condenser
β
PASS: Tier 1 Hot Working Memory
β
PASS: Tier 2 Warm Episodic Memory
β
PASS: Tier 3 Cold Archival Store (BM25 Search)
β
PASS: Semantic Garbage Collector
β
PASS: KV-Cache Optimizer & Boundary Manager
β
PASS: Checkpoint Manager & Subagent Sandbox & Symbol Guard
β
PASS: Guardrails: Stream Interceptor, Secret Scrubber, Image Optimizer
β
PASS: Attention Anchoring (Dual-Anchor) & Role Profiler
β
PASS: Report Generator (HTML, Markdown, JSON)
β
PASS: MCP Server - 11 Native Tools
========================================
π Test Results: 19 passed, 0 failed
========================================π€ Contributing & Evaluation Hub
Contributions are warmly welcomed! Whether you want to add new language AST profiles, create new AI IDE adapters, optimize token compressors, or submit real-world benchmark evaluations:
Read our full Contributing Guide to understand the Zero External Dependencies and Sub-45ms Execution Speed architectural principles.
Submit real-world token optimization benchmarks and RFCs in the Evaluation & Feedback Hub using
TEMPLATE_FEEDBACK.md.Adding a new language profile: create
profiles/<language>.profile.json, add test fixtures intests/fixtures/, and verify withnpm test.Report issues, submit bug reports, or propose feature RFCs via GitHub Issues.
π License & Citation
Distributed under the MIT License. See LICENSE for full details.
SPDX-License-Identifier: MIT
Copyright (c) 2026 Hanif Al-KauniBuilt with β€οΈ for the universal AI agent ecosystem.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Production-readiness for your AI coding agents.
SaaS intelligence for AI agents. 5 unified tools cover 1,000+ services with 91-96% token savings.
Build, validate, and deploy multi-agent AI solutions from any AI environment.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.6223MIT
- FlicenseNot gradedqualityCmaintenanceTransforms codebases into a knowledge graph for AI agents, enabling semantic search, impact analysis, and persistent session memory with up to 94% token savings.516-
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to query a pre-built semantic knowledge graph of code, reducing token usage and tool calls. Supports 16 tools for code exploration, analysis, and context building.147MIT
- AlicenseAqualityBmaintenanceProvides persistent memory and a codebase knowledge graph for AI coding assistants, enabling shared context across multiple tools like Claude, Cursor, and ChatGPT, with significant token reduction.525MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hanifalkauni/context-architect'
If you have feedback or need assistance with the MCP directory API, please join our Discord server