code_docs
MCP Server
Agent Integration

MCP Server

The Code_ MCP (Model Context Protocol) server lets AI agents — Claude, ChatGPT, custom agents — manage your finances via tool use. Agents can query spend, create projects, freeze cards, and check alerts, all through a standardized protocol.

Overview

The MCP server exposes 10 tools and 2 resources over stdio transport. It's designed for the PRD's vision of agents as first-class financial actors.

ToolDescription
list_projectsList all projects with status and budget
create_projectCreate a project with auto-generated virtual card
get_project_pnlProfit & loss for a specific project
get_spendSpend breakdown by category and provider
get_balanceAccount balance and credit info
list_cardsAll virtual cards with status and spend
freeze_cardFreeze a card to block transactions
unfreeze_cardUnfreeze a card
get_rewardsCode Credits balance and tier breakdown
get_alertsSpend alerts and anomalies

Setup with Claude Code

The MCP server is already configured in the project's .mcp.json. If you're working in the Code_ repo, the tools are available automatically.

To add it to a different project:

Terminal
claude mcp add --scope project codecard -- node /path/to/code_-cli/dist/mcp-server.js

Setup with Claude Desktop

Add to your claude_desktop_config.json:

claude_desktop_config.json
{
  "mcpServers": {
    "codecard": {
      "command": "node",
      "args": ["/path/to/code_-cli/dist/mcp-server.js"]
    }
  }
}

Setup via CLI

Start the MCP server directly from the Code_ CLI:

Terminal
codecard mcp

This starts the stdio transport, ready for any MCP-compatible client to connect.

Tool Reference

list_projects

No parameters. Returns all projects with name, status, and monthly budget.

Example response
Projects (4):
ai-tutor-app (active) — $5,000.00/mo
vibe-cli (active) — $2,000.00/mo
client-dashco (active) — $8,000.00/mo
experiment-rag (active) — $1,000.00/mo

create_project

ParameterTypeRequiredDescription
namestringYesProject name (kebab-case)
budgetnumberNoMonthly budget in dollars (default: 2000)
Example
Tool: create_project
Args: { "name": "my-agent-app", "budget": 5000 }

✓ Project "my-agent-app" created
✓ Card •••• 8421 assigned
✓ Budget: $5,000.00/mo

get_project_pnl

ParameterTypeRequired
projectstringYes — project name

Returns spend, revenue, net, margin, and top providers for the named project.

get_spend

ParameterTypeRequired
projectstringNo — filter by project name

Returns total spend, breakdown by category (AI APIs, Cloud, Dev Tools, Other), and breakdown by provider. Without a project filter, shows all spend across all projects.

get_balance

No parameters. Returns available balance, pending charges, credit limit, and credit utilization.

list_cards

No parameters. Returns all virtual cards with last4, associated project, status, and spend vs. limit.

freeze_card / unfreeze_card

ParameterTypeRequired
card_idstringYes — e.g. card_001

Freeze blocks all transactions. Unfreeze re-enables them. Use freeze when an agent detects a cost anomaly.

get_rewards

No parameters. Returns Code Credits balance (available, pending, lifetime), reward tier rates, and earnings per category.

get_alerts

No parameters. Returns all alert events with severity, title, message, project, and acknowledgment status.

Resources

The MCP server also exposes two resources for bulk data access:

URIDescriptionFormat
codecard://projectsAll projects as structured dataapplication/json
codecard://cardsAll virtual cards as structured dataapplication/json

Agent Usage Patterns

Cost monitoring agent

An agent that periodically checks spend and alerts on anomalies:

Agent prompt
Check my Code_ spend. If any project's daily spend is more than
3x the average, freeze that project's card and tell me about it.

Project setup agent

An agent that creates infrastructure alongside financial tracking:

Agent prompt
I'm starting a new project called "recipe-ai" with a $2000/mo budget.
Create the Code_ project, then set up a Vercel project and Supabase
database for it.

Financial reporting agent

An agent that generates weekly financial summaries:

Agent prompt
Generate a weekly financial report for all my Code_ projects.
Include P&L for each project, total rewards earned, and flag
any projects that are losing money.