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

Uploaded Python 3

File details

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

File metadata

  • Download URL: archai_mcp-0.4.1.tar.gz
  • Upload date:
  • Size: 36.7 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.1.tar.gz
Algorithm Hash digest
SHA256 210bd922ec541a138fd380d48aa8e64cd0be5bafe992e23cd344e5ccfdd18531
MD5 b7ea690606ceed3166ebc63ce0b42730
BLAKE2b-256 f010a6c1d4f5fa7b84381e43ccbcaad95627980228458fa243d54f1f881449bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: archai_mcp-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 42.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0830a4d7384cef16f1232826774f9f764dd0b5515f938241ffe19684908fd138
MD5 6a4e3677642006244fff0e14449da04f
BLAKE2b-256 98d56237884fc307417b559e439507d56330492aa57845884344a7dc937b7d6a

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