# benwelker/callscope architecture

> Architecture diagram of the GitHub repository benwelker/callscope, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benwelker/callscope
- Repository: https://github.com/benwelker/callscope

## Overview

CallScope turns a Python project into a resolved call-graph index, then presents it as a navigable, self-contained HTML map or exposes graph queries through an MCP server. The principal workflow is CLI input → AST collection and resolution → index → HTML/JSON output → interactive function navigation. AI agents can instead query the same analysis through MCP tools. The core analyzer and MCP implementation are excerpted; UI and several MCP tool details are documented in the README, so those edges cite that documentation.

Main entry points: [`callscope_mcp.py`](https://github.com/benwelker/callscope/blob/main/callscope_mcp.py) (Analysis cache), [`callscope.py`](https://github.com/benwelker/callscope/blob/main/callscope.py) (CLI entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Static analysis"]
  node_cli["CLI entry point<br/>[callscope.py]"]
  node_collector["AST collection<br/>[callscope.py]"]
  node_resolver["Call resolution<br/>[callscope.py]"]
  node_project_index["Project index<br/>[callscope.py]"]
end

subgraph group_outputs["Graph outputs"]
  node_html_generator["HTML generation<br/>[callscope.py]"]
  node_json_output["JSON index<br/>[callscope.py]"]
end

subgraph group_human_ui["Interactive map"]
  node_interactive_map["Interactive navigator<br/>[callscope.py]"]
end

subgraph group_agent_api["Agent access"]
  node_mcp_server["MCP server<br/>[callscope_mcp.py]"]
  node_mcp_cache[("Analysis cache<br/>[callscope_mcp.py]")]
  node_graph_queries["Graph query tools<br/>[callscope_mcp.py]"]
  node_mcp_map["Map generation tool<br/>[callscope_mcp.py]"]
end

node_developer(("Developer"))
node_agent(("AI agent"))

node_developer -->|"supplies project"| node_cli
node_cli -->|"scans Python"| node_collector
node_collector -->|"provides call sites"| node_resolver
node_resolver -->|"builds graph"| node_project_index
node_cli -->|"generates map"| node_html_generator
node_project_index -->|"embeds graph"| node_html_generator
node_cli -->|"writes index"| node_json_output
node_html_generator -->|"produces HTML"| node_interactive_map
node_developer -->|"explores calls"| node_interactive_map
node_agent -->|"sends MCP requests"| node_mcp_server
node_mcp_server -->|"loads analysis"| node_mcp_cache
node_mcp_cache -->|"scans project"| node_collector
node_mcp_cache -->|"resolves calls"| node_resolver
node_mcp_cache -->|"caches index"| node_project_index
node_mcp_server -->|"dispatches tools"| node_graph_queries
node_graph_queries -->|"queries index"| node_mcp_cache
node_mcp_server -->|"dispatches tool"| node_mcp_map
node_mcp_map -->|"writes map"| node_html_generator
node_agent -->|"requests graph data"| node_graph_queries

click node_cli "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_collector "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_resolver "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_project_index "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_html_generator "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_json_output "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_interactive_map "https://github.com/benwelker/callscope/blob/main/callscope.py"
click node_mcp_server "https://github.com/benwelker/callscope/blob/main/callscope_mcp.py"
click node_mcp_cache "https://github.com/benwelker/callscope/blob/main/callscope_mcp.py"
click node_graph_queries "https://github.com/benwelker/callscope/blob/main/callscope_mcp.py"
click node_mcp_map "https://github.com/benwelker/callscope/blob/main/callscope_mcp.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_collector,node_resolver,node_project_index toneBlue
class node_html_generator,node_json_output toneAmber
class node_interactive_map toneMint
class node_mcp_server,node_mcp_cache,node_graph_queries,node_mcp_map toneRose
class node_developer,node_agent toneIndigo
```

## Components

### Static analysis

- [CLI entry point](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`
- [AST collection](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`
- [Call resolution](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`
- [Project index](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`

### Graph outputs

- [HTML generation](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`
- [JSON index](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`

### Interactive map

- [Interactive navigator](https://github.com/benwelker/callscope/blob/main/callscope.py): `callscope.py`

### Agent access

- [MCP server](https://github.com/benwelker/callscope/blob/main/callscope_mcp.py): `callscope_mcp.py`
- [Analysis cache](https://github.com/benwelker/callscope/blob/main/callscope_mcp.py): `callscope_mcp.py`
- [Graph query tools](https://github.com/benwelker/callscope/blob/main/callscope_mcp.py): `callscope_mcp.py`
- [Map generation tool](https://github.com/benwelker/callscope/blob/main/callscope_mcp.py): `callscope_mcp.py`

### Other components

- **Developer**
- **AI agent**

## Connections

- Developer → CLI entry point: supplies project (evidence: `README.md`)
- CLI entry point → AST collection: scans Python (evidence: `README.md`)
- AST collection → Call resolution: provides call sites (evidence: `README.md`)
- Call resolution → Project index: builds graph (evidence: `README.md`)
- CLI entry point → HTML generation: generates map (evidence: `README.md`)
- Project index → HTML generation: embeds graph (evidence: `README.md`)
- CLI entry point → JSON index: writes index (evidence: `README.md`)
- HTML generation → Interactive navigator: produces HTML (evidence: `README.md`)
- Developer → Interactive navigator: explores calls (evidence: `README.md`)
- AI agent → MCP server: sends MCP requests (evidence: `README.md`)
- MCP server → Analysis cache: loads analysis (evidence: `callscope_mcp.py`)
- Analysis cache → AST collection: scans project (evidence: `callscope_mcp.py`)
- Analysis cache → Call resolution: resolves calls (evidence: `callscope_mcp.py`)
- Analysis cache → Project index: caches index (evidence: `callscope_mcp.py`)
- MCP server → Graph query tools: dispatches tools (evidence: `callscope_mcp.py`)
- Graph query tools → Analysis cache: queries index (evidence: `README.md`)
- MCP server → Map generation tool: dispatches tool (evidence: `callscope_mcp.py`)
- Map generation tool → HTML generation: writes map (evidence: `README.md`)
- AI agent → Graph query tools: requests graph data (evidence: `README.md`)
