# codecanvas [Health: Active]

**Category:** 🤖 Coding Agents  
**Repository:** https://github.com/donggyun112/codecanvas  
**GitHub Stars:** 2  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/codecanvas

## Description
Python code intelligence for coding agents: call paths, control flow, and change impact.

## Tools
Capabilities this server exposes over MCP:

- **list_entrypoints** — Map where a codebase starts — list its API/HTTP routes, CLI scripts,
    public library exports, and entry-point functions. Reach for this first to
    get the lay of an unfamiliar project: what endpoints exist, which handler
    serves each route, where execution begins.

    For a library, `kind="export"` is its public API surface, taken from each
    distributed package's `__all__` and `[project.scripts]` and resolved to
    where each name is defined. Every export is tagged with its distribution.

    On large projects the result is capped, so narrow it: `filter` is a
    case-insensitive substring matched over method/path/handler/id/tags
    (e.g. "login", "StateGraph", or a package name), and `kind` keeps one kind
    ("api", "script", "export", "function"). When the list is truncated the
    note names every package that has exports, so a symbol you cannot see is
    still one `filter` away. Test-fixture entrypoints (handlers under `tests/`,
    `test_*.py`) are hidden by default; set `include_tests=True` to keep them.
    
- **find_symbols** — Find project functions, methods, and classes by name, qualified name,
    scope, acronym, or docstring meaning. Results explain matched tokens,
    character spans, and likely symbol role. Continue with `next_cursor`;
    choose `search_mode` name, semantic, or hybrid.

    `semantic` is concept-expanded lexical matching over identifier words plus
    docstrings — related wordings reach each other (throttle/limiter,
    parallel/concurrency), but it is not an embedding search, so a query
    sharing no vocabulary with the code will not find it. Every row reports
    `match.coverage`: the fraction of the query's content words the symbol
    accounts for. Ranking multiplies by coverage, so a partial overlap can
    never outrank a full one — raise `min_score` to cut partial hits.
- **project_status** — Inspect the active analysis root, Python file count, disk-cache state,
    and nested Python project roots. Use this when results look polluted or
    incomplete and you may need a narrower `project_path`.
- **who_calls** — Find the callers of a function — who calls it, its upstream usages and
    references, the reverse call graph, and what would break if you change its
    signature. Complements `call_tree`, which walks the opposite direction
    (downstream, what the function reaches).

    `function` accepts a qualified name, bare name, file:line, or a
    scope-skipping suffix like `Class.nested` (an enclosing scope omitted). `depth=1`
    (default) returns direct callers; `depth=N` walks up to N hops of
    transitive callers, tagging each with its `depth` and the `callee` it
    calls on the traced path. Cycles/recursion terminate safely. On heavily
    called functions the result is capped, so `filter` (case-insensitive
    substring over caller/location/callee) narrows it before truncation.
- **what_does** — Get a quick summary of what a function does without reading its source
    — its signature, docstring, side effects (whether it touches the database
    or makes HTTP calls), the exceptions it can raise, and a risk rating. Use
    it to triage an unfamiliar function before deciding whether to dig into
    `function_flow` or the full source. `function` = qualified name, bare name,
    file:line, or a scope-skipping suffix like `Class.nested`.

    `calls` and `effects.direct` cover this function's own call sites, and
    `risk` scores only those. `effects.transitive` names what it reaches
    through callees, each attributed to the callee that carries it via
    `effects.via` — so a thin wrapper scoring risk 0 still shows the database
    write underneath it. Use `call_tree` for the full downstream picture.
- **logic_flow** — Start here to understand an unfamiliar function's logic in one compact
    call. Combines symbol resolution, signature and summary, branch outline,
    guarded outcomes, downstream project calls, effects, and repository-relative
    citation locations. Prefer this over separately calling `find_symbols`,
    `what_does`, `function_flow`, `reaching_conditions`, and `call_tree`; use
    those only when this response is truncated, ambiguous, or needs one focused
    detail. `depth` bounds downstream calls and defaults to two hops.
- **analyze_impact** — Assess the blast radius of a change — given a diff or git ref, list the
    changed functions and which entry points/public surfaces they affect
    (HTTP routes, scripts, or public function fallbacks). Reach for this when
    reviewing a PR or before merging, to see what a set of edits could break
    downstream.

    Pass `diff_text` for an inline diff, or `git_ref` to diff against a ref.
    Entry points whose handler is under a test path are hidden by default
    (consistent with `list_entrypoints`); set `include_tests=True` to keep
    them. Non-Python changed files are reported under `skipped_files`. Prefer
    `affected_entrypoints`; `affected_endpoints` is a legacy compatibility
    alias.
- **function_flow** — Understand how a function works internally without reading the full
    source. `flow` is a structured branch tree with explicit `subject`, `scope`,
    `condition`, and `nested_subjects`; `outline` is a compatibility rendering.
    For exact return/raise guards, use `reaching_conditions`. `function` accepts
    a qualified name, bare name, file:line, or scope-skipping suffix.
- **verify_claim** — Verify a qualified reachability claim before summarizing it.

    Use `<source> reaches <target>`, optionally prefixed with context such as
    `root task-mode`. The result combines static call paths, structured
    `function_flow`, and `reaching_conditions`, returning `true`, `false`, or
    `uncertain` plus a counterexample/qualification. Inferred-only paths never
    receive a true verdict.

    Condition qualifiers on the prefix are evaluated, not ignored:
    `dry-run publish reaches _call_api`, `wake=false deliver reaches _send`,
    and `without OPENAI_API_KEY analyze reaches run_ai` each get checked
    against the guards on every path, and a guard requiring the opposite makes
    the verdict `false` with that guard as the counterexample.
    `applied_qualifiers` lists the conditions actually modelled. A condition no
    guard constrains lands in `unsupported_qualifiers`, caps the verdict at
    `uncertain`, and sets `safe_to_summarize: false` — report it as
    unevaluated rather than answering as if it held. Unknown prefix syntax,
    such as `priority=urgent` or a bare `banana`, is returned as an input error
    with `safe_to_summarize: false`.
    
- **reaching_conditions** — Find out under what conditions a function reaches each of its returns
    and raises — the guard/path conditions (the enclosing if/elif/else,
    except, and loop tests) leading to each outcome. Reach for this when
    hunting a bug in branching logic or asking "why does this hit the error
    path?": it surfaces error-path vs success-path asymmetries (e.g. a success
    response returned from an except handler), plus cyclomatic complexity and
    any unreachable/dead code. `target`: omit for all return/raise; or
    "return" / "raise" / "line:N" to focus. `function` = qualified name,
    bare name, file:line, or a scope-skipping suffix like `Class.nested`.
- **validate_state_schema** — Check a function's state dict/object usage against expected fields.

    Use this when a bug depends on domain state shape rather than call graph
    reachability alone. `state_schema` may be JSON-schema-like
    (`{"properties": {...}, "required": [...]}`) or a simple field mapping.
    The tool reports state reads/writes, dict-shaped returns, schema-extra
    fields, and returns missing required fields. `state_var` must match the
    function parameter that receives the whole state mapping; these tools are
    designed for node-style functions such as `def node(state)`. This is a
    focused repro aid: it turns custom state assumptions into checkable evidence,
    but still does not conclusively prove runtime behavior.
    
- **simulate_state_transition** — Execute focused state-transition repro cases in isolated processes.

    Pass explicit `cases` for exact domain states, or omit them to generate a
    small schema-shaped set from `state_schema`; generated cases do not derive
    branch predicates, so use `function_flow`/`reaching_conditions` plus explicit
    cases when branch coverage matters. Built-in invariants include `no_exception`,
    `return_is_mapping`, `return_has_required_keys`,
    `no_unknown_return_keys`, and `state_preserves_required_keys`. Results
    include return values, state mutations, exceptions, captured output, and
    per-case violations. Exceptions are always reported; include `no_exception`
    when they should fail a case. `timeout_seconds` limits function execution;
    `import_timeout_seconds` separately limits fixture hydration and module setup.
    Cases may use allowlisted `$type` fixtures such as `langchain.AIMessage` and
    `langchain.ToolMessage`. Use `overrides` to replace a dependency at its runtime
    lookup path with one explicit `return_value`, `return_sequence`, or `raise`
    behavior. Override calls and unused overrides are reported per case. This
    executes trusted project code in a separate process, not a security sandbox:
    filesystem, network, subprocess, and import-time side effects remain possible
    and cannot be contained or overridden by this tool.
    `state_var` must match the parameter receiving the whole state mapping.
    Module-level sync and async node-style functions are supported in this MVP.

    The worker runs on the project's virtualenv interpreter when one is found
    (`<project>/.venv` or `venv`, then the same in the parent directory),
    otherwise on this server's interpreter — which under `uvx` cannot import the
    project's dependencies. Set `python_executable` to choose explicitly. Every
    result reports the interpreter used under `worker`; check it first when a
    case fails with an unexpected ImportError.
    
- **call_tree** — Trace everything a function reaches downstream — the forward transitive
    call tree, N hops deep, in one call instead of hopping node-by-node. Reach
    for this to see what a function ends up doing and which side effects it
    triggers transitively. The complement of `who_calls`, which walks the
    opposite direction (upstream, who calls it).

    Each node carries its `depth`, the `via` caller on the traced path, effect
    flags (db/http/raises/stub) with `effect_scope: "direct"` — a node's flags
    are always its own, never its subtree's — and risk. The top-level
    `effects` splits the queried function's own effects (`direct`) from those
    it only reaches through callees (`transitive`, attributed by `via`). Only
    project-internal functions are nodes; library calls show up as the
    parent's effect tags. Cycle-safe
    (dedup by name). Callees resolving into a test path are dropped by default
    (usually a misresolution); set `include_tests=True` to keep them. `filter`
    narrows by substring before the cap. `function` = qualified name, bare
    name, file:line, or a scope-skipping suffix like `Class.nested`.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "codecanvas": {
    "command": "uvx",
    "args": ["codecanvas-mcp"]
  }
}
```

## Documentation

## What codecanvas does

The codecanvas MCP server analyzes Python source locally and exposes structural answers to coding agents through MCP. It is intended for questions that require more than text search, such as how a function branches, which callers reach it, what it calls downstream, or which public surfaces may be affected by a change.

Results can include functions, methods, classes, FastAPI routes, scripts, distributed-library exports, returns, raises, branch guards, downstream effects, and affected entrypoints. The server also reports evidence quality, ambiguous calls, truncation, and whether an answer is safe to summarize as an unconditional claim. This makes static-analysis uncertainty visible rather than presenting every inferred relationship as fact.

## How it works

On the first tool call, provide an absolute `project_path`. The server selects that directory as the analysis root and remembers the last explicitly selected project during the session. `project_status` can show the active root, Python file count, cache state, worker interpreter, and possible nested Python project roots.

The codecanvas MCP server builds project-level structural information and uses it for bounded upstream and downstream traces. `who_calls` follows direct or transitive callers, while `call_tree` follows project-internal callees and attributes direct or transitive effects. `logic_flow`, `function_flow`, and `reaching_conditions` expose branches, outcomes, nesting, guards, returns, raises, complexity, and unreachable code. `verify_claim` combines paths with guards and can return true, false, or uncertain.

Static analysis is not runtime execution. Inferred edges, ambiguity, truncated results, and unsupported qualifiers can limit confidence.

## Setup and configuration

Install `uv` if `uvx` is unavailable, then start the server with:

```toml
[mcp_servers.codecanvas]
command = "uvx"
args = ["codecanvas-mcp"]
```

The repository provides marketplace plugins for Claude Code and Codex. Clients without plugin support can use an equivalent stdio MCP configuration.

## Tools and capabilities

- Discover project state and nested roots with `project_status`.
- Find routes, scripts, exports, and symbols with `list_entrypoints` and `find_symbols`.
- Summarize behavior with `logic_flow` and `what_does`.
- Inspect structured control flow and enclosing guards with `function_flow` and `reaching_conditions`.
- Trace callers, callees, effects, and reachability with `who_calls`, `call_tree`, and `verify_claim`.
- Map diffs or Git references to changed functions and affected surfaces with `analyze_impact`.
- Compare state schemas or run focused state transitions with `validate_state_schema` and `simulate_state_transition`.

The codecanvas MCP server is Python-only and requires Python 3.10 or newer. It complements grep and language-server features rather than replacing exact text search or definition and reference navigation.

## Limitations and notes

Analysis is limited to Python projects. Call resolution may be inferred or ambiguous, and bounded responses may be truncated. Agents should use the returned evidence metadata and `response_guidance` when deciding how strongly to state a conclusion. Pass the intended nested project root explicitly when the automatic candidate list is not sufficient.

_Full upstream README: https://allmcps.com/mcp/codecanvas/readme_

