Skip to main content

Topos MCP server — structural code-quality tools (SIMPLE/COMPOSABLE/SECURE) for AI coding agents.

Project description

Topos

CI PyPI Python versions License topos MCP server

Agent harness for tree-sitter and graph-based coding tools — so agents write clean, composable, secure code.
Docs · Quick Start · MCP Server · Issues

Topos is a category theory–inspired framework, built in Rust, that sits on top of tree-sitter, GitNexus, Graphify, and Sighthound — one scored target for structural code quality instead of four disconnected tools. Passing unit tests proves your code works; Topos proves it's built to last, scoring complexity, coupling, and data-flow risk so agents have something concrete to optimize toward, instead of a vague "clean it up."

v0.4.0 is a pure Rust binary — topos evaluate/inspect/compare/coverage/graphify/mcp — no Python runtime involved. See Distribution below.


Quick Start

Install:

curl -fsSL https://docs.krv.ai/topos/install.sh | sh

From your repo root (or cd /path/to/your/repo first):

topos evaluate . -r

evaluate . -r scores every file under the current directory and prints a ranked digest: which pillars pass, the worst-scoring files, and the cheapest fixes to flip a failing pillar. Add -h to any command for help, or --json for CI.

Other install paths and the full command tour live at docs.krv.ai/topos/installation. Note: pip install topos-mcp / uvx topos-mcp installs only the MCP server binary (as the topos-mcp command) — the topos CLI itself ships via the install script above, a GitHub release binary, or cargo build --release -p topos from source.

Built on

Topos doesn't reinvent graph analysis for code — it orchestrates three specialist tools most agents would otherwise have to run separately, and scores their combined output as one medal:

Tool Integration What it gives Topos
GitNexus wired in (subprocess) the module dependency graph that COMPOSABLE scores
Graphify wired in (subprocess) a tree-sitter knowledge graph powering advisory dead-code and fragile-edge detection
Sighthound embedded (compiled in) supplementary SAST detail alongside the SECURE verdict

Full credit and integration details: docs.krv.ai/topos/architecture.

What you get

Three independent pillars, computed natively in topos-engine from tree-sitter ASTs, roll up into one Code Quality Medal:

  • SIMPLE — avoids unnecessary complexity (AST entropy & CFG cyclomatic complexity)
  • COMPOSABLE — cleanly decoupled from other modules (MDG Martin instability, over GitNexus's dependency graph)
  • SECURE — free of dangerous API reachability and taint paths (CPG analysis)
Medal Criteria
🥇 GOLD Passes all 3 (SIMPLE + COMPOSABLE + SECURE)
🥈 SILVER Passes 2 of 3
🥉 BRONZE Passes 1 of 3
SLOP Passes 0 (or fails to parse)

COMPOSABLE needs a cross-file dependency graph. Install GitNexus and topos evaluate will detect it, generate .gitnexus if it's missing or stale, and score COMPOSABLE alongside SIMPLE/SECURE automatically:

pnpm add -g gitnexus  # or: npm install -g gitnexus
topos evaluate src/ -r   # generates/refreshes .gitnexus as needed, then scores COMPOSABLE/GOLD

Pass --no-composable to skip GitNexus entirely and evaluate SIMPLE/SECURE only, or --gitnexus-dir <dir> to point at a .gitnexus build elsewhere. The MCP server's topos_evaluate_file/topos_evaluate_project tools standardize on the same default: they detect and generate/refresh .gitnexus too (pass no_composable: true to opt out), so agent-driven workflows get all three pillars without an extra round trip through topos_generate_depgraph.

Other commands: topos inspect for per-file metrics, topos compare for AST edit distance between two versions, topos coverage for structural test coverage, topos graphify for Graphify knowledge-graph generation and orphan/dead-code detection (advisory, see below), and --preferences simple,composable,secure to tell agents which pillar to protect first when 🥇 GOLD isn't reachable. Full reference: docs.krv.ai/topos/cli.

The refactoring layer

GitNexus, Graphify, and Sighthound each answer one narrow question well. Used standalone, an agent juggles separate tool schemas and no shared sense of "good enough." Topos collapses all of it into one surface — this is what Topos adds on top of the tools it credits above:

  • One MCP tool, topos_refactor, instead of four separate tool schemas — a deliberate wire-size call, not laziness (see docs/decisions/refactor-suite.md).
  • One scored medal agents can optimize toward, instead of four uncorrelated reports.
  • One preference-driven iteration loop (topos_preference_walk) telling an agent which pillar to protect when GOLD isn't reachable under budget.

topos_refactor surfaces ranked, actionable hotspots from four independent structural-analysis engines — advisory, never feeding the scored medal:

  • cycles — CFG cycle-basis extraction, pointing at the loop/branch bodies driving cyclomatic complexity.
  • dependencies — Forman curvature over the MDG (via GitNexus), naming load-bearing import edges (bottlenecks).
  • process — directed Forman-Ricci curvature over GitNexus process graphs, flagging execution-path choke points.
  • graphify — orphan nodes and low-confidence (INFERRED/AMBIGUOUS) edges in a Graphify knowledge graph, flagging likely dead code and fragile relationships. Generate with topos graphify generate or topos_generate_graphify_graph, inspect with topos graphify orphans <file> or topos_refactor(target="graphify").

Sighthound is embedded directly into topos-mcp — a compiled-in Rust dependency, not a subprocess — and supplies supplementary security_findings detail alongside the SECURE verdict: advisory detail, never a second scoring input. See docs/decisions/refactor-suite.md for the full design.

MCP server (for agents)

Give any MCP-compatible agent — Claude Code, Cursor, Gemini CLI, Windsurf — a live feed of Topos verdicts so it can evaluate and iterate on its own output.

claude mcp add --transport stdio topos -- topos mcp

Setup for Cursor, VS Code, Gemini CLI, Codex, and Windsurf, plus troubleshooting and the full MCP tool list: docs.krv.ai/topos/agents.

[!TIP] OpenClaw: openclaw skills install @Krv-Labs/topos
Hermes: hermes skills tap add Krv-Labs/topos then hermes skills install Krv-Labs/topos/topos


How it works

Topos measures code along the three pillars above and maps the result to an 8-element evaluation lattice — the three pillars are pairwise incomparable, and 🥇 GOLD is their intersection.

Evaluation lattice diagram
graph BT
    SLOP["❌ SLOP<br/>No Medal"]
    SIMPLE["🥉 BRONZE<br/>Simple"]
    COMPOSABLE["🥉 BRONZE<br/>Composable"]
    SECURE["🥉 BRONZE<br/>Secure"]
    SC["🥈 SILVER<br/>S ∧ C"]
    SSc["🥈 SILVER<br/>S ∧ Sc"]
    CSc["🥈 SILVER<br/>C ∧ Sc"]
    IDEAL["🥇 GOLD<br/>Quality Code"]

    SLOP --> SIMPLE
    SLOP --> COMPOSABLE
    SLOP --> SECURE
    SIMPLE --> SC
    SIMPLE --> SSc
    COMPOSABLE --> SC
    COMPOSABLE --> CSc
    SECURE --> SSc
    SECURE --> CSc
    SC --> IDEAL
    SSc --> IDEAL
    CSc --> IDEAL

    style SLOP       fill:#f8d7da,stroke:#842029,color:#000
    style SIMPLE     fill:#cd7f32,stroke:#5c3a1e,color:#fff
    style COMPOSABLE fill:#cd7f32,stroke:#5c3a1e,color:#fff
    style SECURE     fill:#cd7f32,stroke:#5c3a1e,color:#fff
    style SC         fill:#c0c0c0,stroke:#4a4a4a,color:#000
    style SSc        fill:#c0c0c0,stroke:#4a4a4a,color:#000
    style CSc        fill:#c0c0c0,stroke:#4a4a4a,color:#000
    style IDEAL      fill:#ffd700,stroke:#856404,color:#000

Set your Preferences (e.g. simple,composable,secure) to tell your coding agent which pillars to prioritize when aiming for GOLD under token and time budgets, and how to relax that goal when GOLD isn't reachable. Details: docs.krv.ai/topos/preferences · docs.krv.ai/topos/measures · docs.krv.ai/topos/concepts.

Distribution

Topos ships four ways — no crates.io, no Homebrew yet:

  • GitHub Releases — the topos CLI binary (macOS/Linux), via install.sh above or a direct release download.
  • PyPItopos-mcp, a thin bin-wheel bundling just the MCP server binary (pip install topos-mcp / uvx topos-mcp), zero Python runtime.
  • VS Code Marketplace — the Topos extension, bundling platform binaries.
  • Docker — a container image for Glama and other MCP-registry hosting.

Crate layout, and how GitNexus/Graphify/Sighthound plug into the Rust workspace: docs.krv.ai/topos/architecture.

Contributing

Topos is used internally at Krv Labs to manage AI agent code output. We welcome bugs, ideas, and contributions.


Full Documentation · Measures & Metrics · Category Theory Concepts · Engineering notes

Built with ❤️ by Krv Labs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

topos_mcp-0.4.0-py3-none-manylinux_2_34_x86_64.whl (16.7 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

topos_mcp-0.4.0-py3-none-manylinux_2_34_aarch64.whl (16.1 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

topos_mcp-0.4.0-py3-none-manylinux_2_28_x86_64.whl (5.4 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

topos_mcp-0.4.0-py3-none-manylinux_2_28_aarch64.whl (5.4 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

topos_mcp-0.4.0-py3-none-macosx_13_0_arm64.whl (10.2 MB view details)

Uploaded Python 3macOS 13.0+ ARM64

topos_mcp-0.4.0-py3-none-macosx_11_0_arm64.whl (5.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file topos_mcp-0.4.0-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.4.0-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5e21ab281e3749ef4fe243d145e7fe75dc57569f104e524db3abef7c5e1a755e
MD5 45a3c8a2d8ac381aeafd6d836634082d
BLAKE2b-256 273039518d96b752fcc642049f5282c3590d84637a203dd686331b253ffc5067

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.4.0-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Krv-Labs/topos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file topos_mcp-0.4.0-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.4.0-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 1ff22f382b95118f1fb9ca5a5d7996a123185c6cce8fbd905c953c671ac9cbe7
MD5 f54a2e8c4c12e7a6c517bccc760f8026
BLAKE2b-256 9eb63d2e27f98137530b1c4d90063b150d408e736fdc1323f6acd269fbb78aaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.4.0-py3-none-manylinux_2_34_aarch64.whl:

Publisher: release.yml on Krv-Labs/topos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file topos_mcp-0.4.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.4.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b108408a39f4956dd652eb71403d5611c43d40cfaa5a060599e8ab6be98f8d9e
MD5 824ad2aa4fee0d889d86a36c3b899bb2
BLAKE2b-256 c2833c21b7689945732dce0ff643cda96123d68e383710bb2dc51f28b72d9a68

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.4.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on Krv-Labs/topos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file topos_mcp-0.4.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.4.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3a04d13d383dcd4ec2eabd18c5fea75536d3ceda68b05189251a062699f59cf5
MD5 521945d71d556e22abf4f5aaa4c53b93
BLAKE2b-256 a0a636fac58cafa85fcc69144d3e534747afd14b85390ff7849af5442675afa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.4.0-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release.yml on Krv-Labs/topos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file topos_mcp-0.4.0-py3-none-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.4.0-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 3d2538da17d8dc9f435fbc4cf249810254ead54e1212ca96539667b4dd3bbb7f
MD5 19120c1dbbc6dcd7ecb0ada33dfed3a1
BLAKE2b-256 c4135b8c9248e5d0dfd1f0615665159d2ecb782a548c332339ffa52fb599158d

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.4.0-py3-none-macosx_13_0_arm64.whl:

Publisher: release.yml on Krv-Labs/topos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file topos_mcp-0.4.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2afad0c9a14c8ba3e7e0f181f992c5f3a42b259fa1ee36253e26ab355d34251b
MD5 392f45fd81eab9d216371f749ab5ea9b
BLAKE2b-256 75d3121c4df0048537f0dbf0af7072cabbb2745f66ed673a2c48e0785cc1c35f

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.4.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on Krv-Labs/topos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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