Skip to content
AISpendbook

How it works

MCP server

Read keys, the endpoint, the read-only tools and a JSON-RPC example.

The MCP server lets your own assistant or agent read the same ledger the app shows. It speaks the Model Context Protocol over HTTP at POST https://www.aispendbook.com/api/v1/mcp and offers read-only tools. It is part of the Business plan.

Read keys

  • An admin creates a read key in Settings, under Read keys. The key starts with ark_ and is shown once. Only its hash is stored.
  • A key carries scopes and can have a last day. The MCP endpoint and the daily ledger endpoint (GET https://www.aispendbook.com/api/v1/ledger/daily) need the mcp scope. An ingestion key does not work there, and a read key can't send events. Scopes and expiry are on SSO, MFA, SCIM and keys.
  • The workspace is fixed by the key. No tool takes a workspace argument. A firm-wide key names the client in X-Organization-Id.
  • Revoking a key stops it at once. An expired key is refused. Creating and revoking keys is recorded in the audit log.
  • A read key belongs to the workspace, not to a member. It carries no member limits and answers for the whole workspace, revenue included, unless it is marked “No revenue”. It never sees employee data. The keys a member created are revoked when that member is removed or limited.

Protocol

  • Send one JSON-RPC 2.0 message per request with Authorization: Bearer ark_…. Batches are not supported.
  • Methods: initialize, ping, tools/list and tools/call. A notification is answered with 202 and no body.
  • The server is stateless. There are no sessions and no server-sent streams, and each request gets one JSON response.
  • The protocol version reported by initialize is 2025-06-18.
  • Requests are rate limited per read key and per client IP address.

Tools

ToolReturns
get_spending_summaryTotal AI spend for a date range, with the billed and estimated basis.
get_usage_by_dimensionSpend, share, requests and cost per request broken down by one dimension.
get_customer_unit_economicsPer-customer AI cost per request and per active user, and the revenue share when revenue data exists.
forecast_spendingThe baseline monthly projection, or the month-end figure for this month.
get_budget_statusBudgets with spend to date, month-end forecast, percent used and overrun risk.
get_monthly_actualsActual spend per calendar month, oldest first, with the basis mix, requests, tokens and active users. The current month is flagged as partial.
get_close_statusWhether a month is ready to close: status, spend, billed against accrual, days without a bill, open variances and what blocks closing.
get_changes_since_closeWhat changed in a closed month since it was locked: drift, provider corrections and customers whose allocated spend changed.
get_forecast_accuracyRecorded forecasts scored against actual spend, and a backtest of the method, by months ahead.
get_decision_outcomesRecommendation decisions with projected and measured savings, and frozen scenarios against actual spend.
get_credit_runwayCredit and prepaid balances, projected exhaustion dates, the amount projected to expire unused and the monthly cash step-up.
get_cost_viewsList, effective and cash cost by provider and month, with credits applied, grant balances and commitments.
get_accounting_splitOne month's AI spend by accounting class, with account codes and spend by provider.
get_customer_marginAllocated AI spend, revenue and margin per customer, and where total spend went.
get_outcome_unit_costsCost per accepted outcome for one outcome definition, with token and non-token cost by kind.
get_change_reviewsReviews of proposed model changes: cost delta, quality delta per metric, evidence status and the decision.
evaluate_dealA proposed price against the AI cost of the usage it covers, and the saved deals. It computes only and saves nothing.
get_correction_impactProvider corrections in a date range, and which customers' allocated spend the billed changes touch.
get_subscription_summaryEmployee AI tool seats for one month: fixed subscription cost by tool and department, inactive seats, renewals and overlaps.
get_infrastructure_economicsObserved and modelled cost per deployment, cost per request and per million tokens, idle share, and the same tokens priced on a hosted model.

These are the AI Analyst's read-only tools, run through the same code path, so the figures match the rest of the product. tools/list returns the current set with each tool's input schema. Each result has a text summary in content and the data in structuredContent.

Example

list the tools
curl -sS -X POST "https://www.aispendbook.com/api/v1/mcp" \
  -H "Authorization: Bearer $SPENDBOOK_READ_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
call a tool
curl -sS -X POST "https://www.aispendbook.com/api/v1/mcp" \
  -H "Authorization: Bearer $SPENDBOOK_READ_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {"name": "get_monthly_actuals", "arguments": {"months": 3}}
  }'
response shape
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [{"type": "text", "text": "2026-09: ..."}],
    "structuredContent": {"months": [...]},
    "isError": false
  }
}

A tool that fails returns a result with isError set to true and the reason as text. An unknown tool or method returns a JSON-RPC error.