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.1.tar.gz (33.6 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.1-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: archai_mcp-0.3.1.tar.gz
  • Upload date:
  • Size: 33.6 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.1.tar.gz
Algorithm Hash digest
SHA256 c25ecfceffbbd0d853d12dba81ea6af4151385e8c577c143afd408862919e92e
MD5 10bee98a22d69e212c968a41357d1812
BLAKE2b-256 172844b6645b125ec5e03eb0397798391924a9c9e87da03366db0e6ed67f7d24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: archai_mcp-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 38.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e477ed218cf8971daab1e87d651898176f789d52d28bb46f6a0f9e4b47ad2cde
MD5 1cb734e6065ce8e53c43e208ee6c4e31
BLAKE2b-256 f6f698d4af24feda170b7755bcb784f50fce7549a74adbac3ed43854484be3d4

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