Skip to main content

Cognitive Middleware for Architecture-Aware AI Coding Agents

Project description

archai-mcp

PyPI Version Python Versions License

Structural analysis engine for AI coding agents. archai analyzes your repository's architecture and exposes it as MCP tools — no LLM needed, no API keys, zero configuration.

pip install archai-mcp
cd my-project
archai init
opencode .

The agent automatically uses archai's tools to understand your codebase before making changes.


Quick Start

# 1. Install
pip install archai-mcp

# 2. Configure in your project
cd /path/to/your/project
archai init
# → Creates .opencode.json with MCP config

# 3. Open in OpenCode
opencode .
# → The agent has archai tools available automatically

That's it. No API keys, no ARCHAI_LLM_MODEL, no .env file.


CLI Commands

Command Description
archai init Configure the project for OpenCode MCP integration
archai mcp Start MCP server (stdio, for AI agents)

That's the entire surface. archai is designed to be used by AI agents through MCP, not by humans in a terminal.


MCP Tools

archai exposes 3 structural analysis tools for AI agents:

Tool Description
get_architecture_context Returns clusters, dependency edges, and file relationships for a query
get_blast_radius Analyzes the impact of changing a file (dependents, subsystems)
validate_code_change Returns structural data about proposed changes for the agent to evaluate

How agents use it

User: "Add a login endpoint in the auth module"

Agent:
  1. get_architecture_context("auth", repo_path)
     ← focus cluster, all clusters, dependency edges, file deps
     → Agent's LLM infers: "auth depends on db, API depends on auth"

  2. Writes code respecting inferred architecture

  3. get_blast_radius("src/auth/login.py", repo_path, depth=2)
     ← affected files and subsystems
     → Agent's LLM assesses: "safe change, expected impact"

archai returns raw structural data — the agent's own LLM interprets it. This means:

  • No duplicated LLM calls
  • Context-aware inference (the agent knows WHAT you're building)
  • Zero LLM configuration for archai

Configuration for OpenCode

Generated by archai init:

{
  "mcp": {
    "archai": {
      "type": "local",
      "command": ["archai", "mcp"],
      "enabled": true
    }
  }
}

No environment passthrough. No API keys. archai needs nothing but your files.


How It Works

                     archai MCP Server
                     (no LLM, no API keys)
                            │
     ┌──────────────────────┼──────────────────────┐
     │                      │                      │
     ▼                      ▼                      ▼
  Bootstrap             Clustering           Focus Resolution
  • File discovery      • Directory prox.    • Query matching
  • AST parsing         • Shared imports     • Subsystem rank
  • Dependency graph    • Call density       • Test file detection
  • Cycle detection

archai is a pure structural analysis engine. It discovers files, builds a dependency graph, clusters them into logical subsystems, and exposes everything as structured data. No LLM involved.


Why archai?

Problem Solution
Agents don't understand your codebase structure archai provides clusters, dependencies, and focus resolution
Agents make changes without knowing the impact get_blast_radius shows affected files and subsystems
LLM context windows fill with irrelevant files archai finds the relevant subsystem (focus resolution)
Agents violate architecture constraints Structural data enables the agent to self-validate
Configuring LLMs for tools is friction archai needs no LLM config — the agent uses its own

Development

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov=src --cov-report=html

# Format code
uv run black src/
uv run ruff check src/

Architecture

See docs/003-sdd-agent-native-architecture.md for the current architecture spec.


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

archai_mcp-0.3.2.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

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

archai_mcp-0.3.2-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file archai_mcp-0.3.2.tar.gz.

File metadata

  • Download URL: archai_mcp-0.3.2.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for archai_mcp-0.3.2.tar.gz
Algorithm Hash digest
SHA256 4fcf83d0ac449691fafff4e6b47c7a4ddfed9af1c1c810780a0e34a66edfed94
MD5 f43843a8d10acfdcb4b9a3b3bb78acce
BLAKE2b-256 d5ede6dfef005ac5dc68e49bf6377efbc9c1c396c79a65007a7b3d051467fbba

See more details on using hashes here.

File details

Details for the file archai_mcp-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: archai_mcp-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for archai_mcp-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f4a87063d64e4500a5631065eb143453807395cacd82a5187037e4b349a8cfb
MD5 dae8ba629e4e73073fc0a2679d7ea612
BLAKE2b-256 9805fcb8350e95c5bebd9ce2a51fd06ac6079890a568af28d4dec53a8f25e57f

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