Skip to main content

Structural code quality metrics for agent-written programs.

Project description

Topos

CI PyPI Python versions License topos MCP server

Structural code quality metrics for agent-written programs.
Docs · Quick Start · MCP Server · Issues

Passing unit tests proves your code works. Topos proves it's built to last. It measures program structure — complexity, coupling, and data-flow risk — not just syntax, so agents get a concrete target to optimize toward on every pass instead of a vague "clean it up."


Quick Start

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

evaluate -r scores every file in src/ 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 (PyPI, source checkout) and the full command tour live at docs.krv.ai/topos/installation.

What you get

Topos checks three independent pillars and awards a Code Quality Medal for how many pass:

  • SIMPLE — avoids unnecessary complexity (AST entropy & CFG cyclomatic complexity)
  • COMPOSABLE — cleanly decoupled from other modules (MDG Martin instability via GitNexus)
  • 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, which the CLI does not build automatically:

npm install -g gitnexus
topos depgraph generate
topos evaluate src/ -r --gitnexus-dir .gitnexus

Other commands: topos inspect for per-file metrics, topos compare for AST edit distance between two versions, topos coverage for structural test coverage, 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.

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.


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.

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 Distribution

topos_mcp-0.3.10.tar.gz (728.3 kB view details)

Uploaded Source

Built Distributions

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

topos_mcp-0.3.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (602.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

topos_mcp-0.3.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (602.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

topos_mcp-0.3.10-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (872.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file topos_mcp-0.3.10.tar.gz.

File metadata

  • Download URL: topos_mcp-0.3.10.tar.gz
  • Upload date:
  • Size: 728.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for topos_mcp-0.3.10.tar.gz
Algorithm Hash digest
SHA256 4807450f7e6baf9795f34df1cb3cc666b55a1004c8eb7cc0ebc72c11b7ab6bff
MD5 6c05047a6d5583c070c73451fe3920d6
BLAKE2b-256 72e63df1dfa2798150dea39d5ee9b8f2fc7ca162905f4fb4a16aba3388dfe1c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.3.10.tar.gz:

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.3.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.3.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01103be91678233594bb2471a0e71170ce39e4cc608545b454f72413d29fff22
MD5 805d6ce90a74b1a9158753228bbec9ce
BLAKE2b-256 4f6141ba525ca119adefa10f3127afc5650f6db9932b05e7343d44d826669475

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.3.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_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.3.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for topos_mcp-0.3.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6aa5643e4c12c9afea9747c9929913764d0c2b8cb5e908d6af3bbf309f5f06e2
MD5 61b13a6e519337afb4c46175961fee62
BLAKE2b-256 d70e6fc53da91c168638618424ad3cf75e1cb0a80e9bebb717094637d45c0f29

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.3.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_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.3.10-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for topos_mcp-0.3.10-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 dec9b6939359ecd760a84ccd727e8327f5c694f7cfbdfa5beb70c87861e7a466
MD5 1d6420800922cd6f654ac49e5d710a27
BLAKE2b-256 e31967e624677ff86b8bc774c8d70c57ba0d3169f787ee89bbe460196fe22c46

See more details on using hashes here.

Provenance

The following attestation bundles were made for topos_mcp-0.3.10-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.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