Skip to main content
Glama

🧠 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.

License: MIT Version Node.js MCP Protocol Dependencies WCAG 2.2 AA

English | Bahasa Indonesia


🌟 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 <8k token 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 --> ObservabilityLayer

Architecture Narrative (WCAG 2.2 AA Textual Description):

  1. 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.

  2. 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.

  3. 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.

  4. 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

package.json

NestJS, Express, Next.js, Fastify, React, Vue

.ts, .tsx, .js, .jsx, .mjs

Python

pyproject.toml, requirements.txt

FastAPI, Django, Flask, PyTorch, LangChain

.py

Go

go.mod

Gin, Fiber, Echo, Standard net/http

.go

Java / Kotlin / C#

pom.xml, build.gradle, *.csproj

Spring Boot, Quarkus, ASP.NET Core

.java, .kt, .cs

Rust

Cargo.toml

Axum, Actix-web, Tokio, Rocket

.rs

PHP

composer.json

Laravel, Symfony, Slim

.php

Ruby

Gemfile

Ruby on Rails, Sinatra

.rb

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 npx)

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 npx context-architect commands


πŸš€ Quick Start

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: "slice src/services/PaymentService.ts to skeleton and focus on processPayment()")

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:

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.md

Or 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.mdc

Copy 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.json

Copy instructions to your project root:

cp adapters/claude/CLAUDE.md ./CLAUDE.md

For Claude Desktop, configure the MCP server using Method A above.

Copy rules to your repository root:

cp adapters/windsurf/.windsurfrules ./.windsurfrules

Copy instructions to your GitHub configuration directory:

mkdir -p .github
cp adapters/copilot/copilot-instructions.md .github/copilot-instructions.md

Copy rules to your project root:

cp adapters/cline/.clinerules ./.clinerules

Copy 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.json

Import the Python or TypeScript middleware directly into your multi-agent workflow:

  • TypeScript: adapters/frameworks/langgraph.ts

  • Python: adapters/frameworks/autogen.py or adapters/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

context_inspect

text, model

Inspects token counts, pricing, and pressure gauge status for a given payload.

context_health_check

usedTokens, model

Performs a comprehensive context health check, memory count, and optimization recommendation.

context_generate_report

format (html/markdown/json), usedTokens, model

Exports a standalone visual telemetry report.

context_slice_code

code, extension, focusSymbol

Slices code into a zero-compiler AST skeleton or focuses on target symbol contracts.

context_compress_output

type (log/diff/tree), content

Collapses verbose test logs, minimalizes unified git diffs, or condenses file trees.

context_compact_history

turns

Compacts multi-turn conversation history into Tier-2 structured Fact Anchors ([FACT-XXX]).

context_checkpoint_save

id, state, label

Captures an atomic context state snapshot for Tree-of-Thought branch exploration.

context_checkpoint_restore

id

Restores a saved snapshot, instantly purging failed exploration turns.

context_sandbox_subagent

action (create/synthesize), taskDescription, rawOutput

Creates an isolated <8k micro-capsule or synthesizes subagent output for the parent.

context_memory_store

action (store/search/get), id, content, query

Stores or retrieves long-term knowledge from Tier-3 Archival Store using native BM25 ranking.

context_optimize_prompt

systemRules, codeSkeletons, activeUserGoal

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

skills/context-architect/SKILL.md

Native skill (@context-architect or auto-invoked)

Cursor

.cursor/rules/context-architect.mdc

Prompt Agent Mode / Composer

Claude Code

CLAUDE.md + MCP Config

Slash command or automatic MCP tool invocation

Windsurf

.windsurfrules

Cascade auto-injection

Kiro IDE

.kiro/steering/context-architect.md

Steering Prompt / MCP tools

VS Code / Copilot

.github/copilot-instructions.md

@workspace instruction rules

Roo Code / Cline

.clinerules

MCP tool suite invocation

Continue.dev

.continue/rules/context-architect.md

Context Rule & MCP tool invocation

LangGraph / AutoGen / CrewAI

adapters/frameworks/*.ts / *.py

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:

  1. Read our full Contributing Guide to understand the Zero External Dependencies and Sub-45ms Execution Speed architectural principles.

  2. Submit real-world token optimization benchmarks and RFCs in the Evaluation & Feedback Hub using TEMPLATE_FEEDBACK.md.

  3. Adding a new language profile: create profiles/<language>.profile.json, add test fixtures in tests/fixtures/, and verify with npm test.

  4. 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-Kauni

Built 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.

Maintenance

ActivityMaintained
ResponsivenessNo issues

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

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Provides 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.
    6
    22
    3
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables 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.
    14
    7
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Provides 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.
    5
    25
    MIT

Latest Blog Posts

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