Skip to main content

Structural analysis engine for 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 serve Start MCP server (stdio, for AI agents)
archai mcp Alias for archai serve (deprecated)

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.4.2.tar.gz (46.2 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.4.2-py3-none-any.whl (51.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: archai_mcp-0.4.2.tar.gz
  • Upload date:
  • Size: 46.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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":true}

File hashes

Hashes for archai_mcp-0.4.2.tar.gz
Algorithm Hash digest
SHA256 743778b3fb6f76caf2f994ff09a9ff1333f09acaf0f7f2d638502f9715b9f56f
MD5 288b5cee93c82b965b93ffacedf35bc3
BLAKE2b-256 a3115214fff8a61a5649f6860b814e2000b96b9e63544ff1a322b310f89a70d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: archai_mcp-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 51.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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":true}

File hashes

Hashes for archai_mcp-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cb21b97d07eb737d92cc981b9d755b4af5ba664dc4aa815c21a71dd29f575203
MD5 a3b6e6a7d5d335ecc23fee331e563009
BLAKE2b-256 dfdb808456390a960b88a08ecdd719b262b0f0a501b4ab74870a01d7f3804234

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