topos-mcp
The Topos MCP server provides AI agents with structural code quality metrics across three pillars — SIMPLE, COMPOSABLE, and SECURE — to evaluate, compare, inspect, and iteratively improve code quality.
Evaluate Code Quality
Score inline code, individual files, or entire projects/directories with
topos_evaluate_code,topos_evaluate_file, ortopos_evaluate_project. Returns a quality medal (GOLD → SLOP) with per-pillar scores. Supports Python, Rust, JavaScript, TypeScript, and C++.
Inspect Code Details
Use
topos_inspect_codefor per-function breakdowns of cyclomatic complexity, entropy, and the full quality verdict.
Assess Refactors & Changes
topos_assess_improvement— compare a baseline vs. proposed variant inline.topos_assess_worktree_change— compare an in-place edited file against a git baseline (primary refactor loop tool).topos_assess_changeset— assess multi-file changesets, detecting complexity relocation and project-level regressions.topos_begin_refactor/topos_assess_snapshot— snapshot-based workflow for uncommitted/untracked files.
Structural Comparison
Compute AST tree-edit distance between code strings or files with
topos_compare_codeandtopos_compare_files.
Test Coverage Analysis
Measure structural (UAST) and semantic (ECT) test coverage with
topos_calculate_coverage.
Dependency Graph Management
Check status with
topos_depgraph_statusand generate the.gitnexusgraph (required for COMPOSABLE scoring) withtopos_generate_depgraph.
Preference & Lattice Utilities
topos_preference_walk— compute a preference-ordered relaxation walk through the 8-element quality lattice, helping agents gracefully downgrade goals under budget constraints.topos_get_doc— retrieve Markdown documentation on agent contracts, lattice, metrics, preferences, and workflows.
All tools support preference rankings (simple/composable/secure), allow (acknowledge risky calls), verbose (raw metrics), and include_security_findings options.
Why Topos
Coding agents produce working code quickly. The harder question is whether the result is still easy to understand, safe to change, and well-fitted to the rest of the repository. Quality is the new currency.
Topos computes that signal from program structure—not from an LLM review or a style opinion—and returns concrete failure locations and next actions. It is fast enough to sit inside the agent loop: measure, edit, verify, repeat.
Tests check behavior. Topos checks whether the implementation is built to keep changing.
Grounded in category theory, powered by a native-Rust engine.
Related MCP server: mcp-skylos
Under the hood
Topos is a self-contained Rust CLI and MCP server. Analysis runs locally; your source code is not sent to an external model or hosted analysis service.
Component | Role |
Parses six languages and powers the native AST, CFG, CPG, PDG, and UAST representations. | |
Supplies the repository dependency graph scored by COMPOSABLE ( | |
Embedded in the MCP server for supplementary security findings; native CPG probes remain the SECURE scoring source. | |
Optional advisory orphan and fragile-edge detection via |
The result is one agent-facing contract over several structural lenses: one score to optimize, explicit evidence for each failure, and a verification loop that can tell a real improvement from cosmetic churn.
Install and Quick Start
VS Code MCP Extension
Open the Extensions view, search @mcp topos, select Topos, and choose Install. Or view here: Topos: GitHub's MCP Registry.
Then ask agent mode:
Use Topos to find this repository's worst structural problem, make one focused improvement, and verify the result.
See the agent setup guide for tool permissions and troubleshooting.
Other MCP clients [Claude Code]
Run the self-contained MCP server on demand—no persistent Topos or Python installation required:
claude mcp add --transport stdio topos -- uvx topos-mcpSetup for Codex, Gemini CLI, Cursor, Windsurf, Antigravity, and manual JSON lives in the agent setup guide.
Standalone CLI
curl -fsSL https://docs.krv.ai/topos/install.sh | bashPrefer Homebrew?
brew install krv-labs/tap/toposOn Homebrew 6+, that one-liner auto-taps and trusts only this formula. If you brew tap krv-labs/tap first, run brew trust --formula krv-labs/tap/topos before brew install topos.
Then run:
topos evaluate . -rWant GOLD? Runtopos depgraph generate if your agent hasn't already (+ run again after big structural edits), then evaluate with the added CLI flag --gitnexus-dir .gitnexus.
Topos supports Python, Rust, JavaScript, TypeScript, C++, and Go. The CLI defaults to Python; use --language rust|go|javascript|typescript|cpp for another language. See Installation for platform support and alternative install paths.
More ways to use Topos
OpenClaw / ClawHub:
openclaw skills install @Krv-Labs/toposHermes:
hermes skills tap add Krv-Labs/toposthenhermes skills install Krv-Labs/topos/toposMCP Registry name:
io.github.Krv-Labs/toposCLI reference: docs.krv.ai/topos/cli
What Topos checks
Every file gets three independent verdicts:
SIMPLE — avoids unnecessary complexity using AST entropy and control-flow complexity.
COMPOSABLE — stays decoupled from the repository using module-dependency structure and Martin instability.
SECURE — avoids dangerous API reachability and taint paths in the code property graph.
Those verdicts roll up into one memorable quality medal without hiding which pillar failed:
Medal | Criteria |
🥇 GOLD | Passes all 3 |
🥈 SILVER | Passes 2 of 3 |
🥉 BRONZE | Passes 1 of 3 |
❌ SLOP | Passes 0, or fails to parse |
Topos also returns ranked refactor guidance: failing metric locations, control-flow cycles, load-bearing dependency edges, process bottlenecks, and optional Graphify knowledge-graph findings. Advisory findings never silently change the scored medal.
The three pillars are pairwise incomparable and form an eight-element evaluation lattice; GOLD is their intersection.
---
config:
layout: dagre
theme: neutral
---
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:#000Measures · Category-theory foundations
Distribution
Topos ships four ways:
GitHub Releases — the
toposCLI binary (macOS/Linux), viainstall.shor a direct release download.PyPI —
topos-mcp, a thinbin-wheel bundling 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 adapter details: 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.
Bug? Open an issue
Idea? Start a discussion or open a PR
Collaborate? team@krv.ai
Full documentation · Measures and metrics · Engineering notes
Maintenance
Related MCP Servers
- Alicense-qualityDmaintenanceProvides comprehensive code analysis through three MCP servers: static analysis for code quality and security, dependency analysis for package management and vulnerabilities, and complexity analysis for maintainability assessment across multiple programming languages.Last updated1MIT
- AlicenseDqualityAmaintenanceSkylos MCP server exposes static analysis as tools for AI coding agents — scan any Python, TypeScript, or Go codebase for dead code, security vulnerabilities, and quality issues directly from Claude, Cursor, or any MCP-compatible client. Returns findings with file paths, line numbers, and severity so agents can auto-fix issues in context.Last updated12481Apache 2.0
- Alicense-qualityCmaintenanceLive codebase intelligence for AI agents. Import graph PageRank for file importance, git forensics for co-change coupling and fragile code, convention detection across 16 domains, and blast radius analysis.Last updated963Business Source 1.1
- AlicenseAqualityAmaintenanceStructural graph map of any codebase. Scans entities, relationships, and feature flows across 13 languages so LLMs navigate by structure instead of reading everything.Last updated610MIT
Related MCP Connectors
Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
Design-system contract verification, scoring, and review tools for AI agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Krv-Labs/topos'
If you have feedback or need assistance with the MCP directory API, please join our Discord server