Skip to content

MCP cost attribution #216

@rz1989s

Description

@rz1989s

Parent Epic

#191

Description

Break down costs by MCP (Model Context Protocol) server, showing which integrations are costing the most.

The Vision

We're the only tool that monitors MCP servers. Let's also attribute costs to them:

MCP Server      │ Calls │ Tokens  │ Cost   │ Share
────────────────┼───────┼─────────┼────────┼──────
filesystem      │  234  │  456K   │  $5.67 │  45%
github          │  123  │  234K   │  $3.45 │  28%
sqlite          │   89  │  167K   │  $2.34 │  19%
context7        │   45  │   78K   │  $1.00 │   8%

How It Works

  1. Parse MCP tool calls from JSONL files
  2. Associate token usage with MCP server
  3. Calculate proportional cost

JSONL Entry Example

{
  "type": "assistant",
  "timestamp": "2026-01-22T15:30:00Z",
  "message": {
    "content": [
      {
        "type": "tool_use",
        "name": "mcp__filesystem__read_file",
        "input": {"path": "/etc/hosts"}
      }
    ],
    "usage": {
      "input_tokens": 1234,
      "output_tokens": 567
    }
  }
}

Command

./statusline.sh --mcp-costs

╭──────────────────────────────────────────────────────────────╮
│                 MCP Cost Attribution                          │
│                 This Session                                  │
╰──────────────────────────────────────────────────────────────╯

MCP Server      │ Calls │ Avg Tokens │ Total Cost │ Share
────────────────┼───────┼────────────┼────────────┼──────
filesystem      │  234  │    1,950   │    $5.67   │  45%
github          │  123  │    1,902   │    $3.45   │  28%
sqlite          │   89  │    1,876   │    $2.34   │  19%
context7        │   45  │    1,733   │    $1.00   │   8%
────────────────┴───────┴────────────┴────────────┴──────
TOTAL           │  491  │    1,865   │   $12.46   │ 100%

Most Expensive: filesystem (45% of costs)
Recommendation: Consider caching filesystem reads to reduce costs

Statusline Integration

MCP: fs(234) gh(123) sql(89) c7(45) │ Top: filesystem $5.67

Why This Matters

  • Unique to our tool (we have MCP monitoring)
  • Helps optimize MCP usage
  • Identifies expensive integrations
  • No competitor tracks this

Acceptance Criteria

  • Parse MCP calls from JSONL
  • Attribute costs to MCP servers
  • MCP costs report command
  • Integration with statusline
  • Optimization recommendations
  • Tests added

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmoatUnique differentiating featurepriority:mediumMedium priority item

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions