Skip to main content
Glama
README.md
# mcp-footprint

[![mcp-footprint MCP server](https://glama.ai/mcp/servers/a895047059/mcp-footprint/badges/score.svg)](https://glama.ai/mcp/servers/a895047059/mcp-footprint)

Protocol-level **MCP (Model Context Protocol)** context footprint analyzer. Discovers local MCP client configs, probes live JSON-RPC 2.0 servers (`stdio`, Streamable HTTP, Legacy HTTP+SSE) or offline snapshots, counts exact BPE tokens (`cl100k_base` / `o200k_base`), flags schema bloat, duplicate tools, and zombie servers/tools, and generates concrete pruning diffs. Listed on [Glama MCP Servers](https://glama.ai/mcp/servers/a895047059/mcp-footprint) with MCP Inspector snapshot verification.

- **Zero telemetry** — runs 100% locally; never phones home or sends schemas to third parties.
- **Secret-safe by design** — redacts `env`, `headers`, `bearer_token_env_var`, URL credentials, and secret CLI flags before returning or printing any report.
- **Zero prompt retention** — session log correlation reads only numeric tool-call counts (`mcp__<server>__<tool>`), never prompt text or tool arguments.

## Quick Start

```bash
# Audit all local MCP configs (Claude Code, Cursor, VS Code, Claude Desktop, Windsurf, Codex)
npx mcp-footprint

# Audit a static tools/list or multi-server JSON snapshot offline
npx mcp-footprint --static ./snapshot.json

# Generate a concrete pruning diff & enforce a CI token budget
npx mcp-footprint --diff --max-tokens 6000

# Export GitHub PR Markdown, JSON, or a standalone SVG badge
npx mcp-footprint --markdown
npx mcp-footprint --json
npx mcp-footprint --svg-badge --output mcp-footprint.svg
```

## Supported Clients & Formats

| Client | Global Config Paths | Workspace Configs | Format & Root Keys |
|---|---|---|---|
| **Claude Code** | `~/.claude.json` (`mcpServers` & `projects[*].mcpServers`) | `./.mcp.json` | JSON (`mcpServers`) |
| **Cursor** | `~/.cursor/mcp.json`, platform app data `Cursor/mcp.json` | `./.cursor/mcp.json` | JSON/JSONC (`mcpServers`) |
| **VS Code** | User `Code/User/mcp.json`, `Code/User/settings.json` | `./.vscode/mcp.json`, `./.vscode/settings.json` | JSONC (`servers`, `mcpServers`, `mcp.servers`, `inputs`) |
| **Claude Desktop** | Platform app data `Claude/claude_desktop_config.json` | — | JSON (`mcpServers`) |
| **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | `./.windsurf/mcp_config.json` | JSON/JSONC (`mcpServers`) |
| **OpenAI Codex** | `~/.codex/config.toml`, `~/.codex/config.json` | `./.codex/config.toml`, `./.codex/config.json` | TOML (`[mcp_servers.<name>]`) / JSON |

## CLI Options

| Flag | Description |
|---|---|
| `--config <path>` | Explicit config file path(s), repeatable or comma-separated |
| `--static <path>` | Inspect a static JSON snapshot (`tools/list`, JSON-RPC `result`, or `{ servers: ... }`) without spawning processes or network I/O |
| `--no-probe`, `--dry-run` | Discover & validate configs without probing servers |
| `--no-global` | Scan current workspace configs only |
| `--tokenizer <name>` | `cl100k_base` (default) or `o200k_base` |
| `--days <n>` | Session log lookback window in days (default: `30`) |
| `--timeout <ms>` | Per-server live probe timeout in ms (default: `8000`) |
| `--max-tokens <n>` | Exit code `1` if total context footprint exceeds `<n>` |
| `--json` | Emit structured JSON report |
| `--markdown` | Emit GitHub-flavored Markdown report |
| `--diff` | Emit concrete config pruning patch / unified diff |
| `--svg-badge` | Emit standalone SVG badge |
| `--output <path>` | Write output to a file |
| `--mcp` | Start as a lean, read-only stdio MCP server |

## Diagnostic Rules

- **`DESC_BLOAT`** — Tool description exceeds 150 tokens / 600 chars (`warning`) or 400 tokens / 1,600 chars (`error`).
- **`SCHEMA_COMPLEXITY`** — Deeply nested JSON Schema (`depth >= 4`), excessive `anyOf`/`oneOf`/`allOf` unions (`>= 4`), or wide parameter objects (`>= 15` properties).
- **`DUPLICATE_TOOL`** — Exact or normalized tool name collision across multiple active servers.
- **`ZOMBIE_SERVER` / `ZOMBIE_TOOL`** — Active server or tool with 0 observed calls in local Claude Code / Codex session JSONL logs (skipped cleanly when no session logs exist).
- **`BUDGET_EXCEEDED`** — Context footprint exceeds `--max-tokens` (or default 10k/20k thresholds).
- **`CONFIG_PARSE_ERROR` / `PROBE_TIMEOUT` / `PROBE_FAILED` / `AUTH_REQUIRED` / `ENV_VAR_UNRESOLVED`** — Config or transport diagnostics with RFC 6901 `jsonPointer` coordinates.

## GitHub Action (`action.yml`)

```yaml
- uses: nodebudget/mcp-footprint@v0.1.3
  with:
    static-path: .mcp/snapshot.json
    max-tokens: "8000"
    fail-on-error: "true"
    comment-pr: "true"
```

## Programmatic TypeScript / ESM API

```ts
import {
  discoverConfigs,
  analyzeFootprint,
  inspectStaticSnapshot,
  generatePruningDiff,
  generateSvgBadge,
} from "mcp-footprint";

const report = await inspectStaticSnapshot("./snapshot.json", {
  tokenizer: "cl100k_base",
  maxTokens: 8000,
});

const diff = generatePruningDiff(report);
const svg = generateSvgBadge(report);
```

## Read-Only MCP Server Mode (`--mcp`)

`mcp-footprint --mcp` exposes three minimal read-only tools (`inspect_mcp_snapshot`, `analyze_mcp_config`, `diff_mcp_budget`) over stdio JSON-RPC 2.0 (`2025-03-26`).

## Related NodeBudget Resources

- [Interactive MCP Token Overhead Calculator](https://nodebudget.dev/tools/mcp-token-overhead-calculator/) — Estimate monthly JSON schema token burn across attached MCP servers and model LiteLLM + Progressive MCP Gateway savings.
- [LiteLLM + MCP Gateway Token Reduction Guide](https://nodebudget.dev/guides/litellm-mcp-gateway-vps-cut-agent-token-bills/) — Engineering guide for cutting agent schema overhead with self-hosted LiteLLM Proxy and progressive tool loading.
- [NodeBudget Open Coding-Agent & MCP TCO Benchmark Datasets](https://nodebudget.dev/datasets/) — CC BY 4.0 datasets covering MCP schema overhead, coding-agent TCO, and self-hosted AI infrastructure benchmarks.

## License

MIT — see [LICENSE](./LICENSE).