How can MCP tool failures increase AI costs?
Summary
- MCP tool failures raise AI costs because agents rarely stop when a tool breaks. They retry, guess new arguments and work around the error, and every extra turn sends the growing context back to the model.
- The waste is easy to miss: the task usually still completes, so on an aggregate cost dashboard it looks like ordinary usage growth.
- Cryptic errors are the most expensive. A raw traceback pushes the agent into trial and error, while an error that says what was wrong lets it correct course quickly.
- On Databricks, Unity Gateway logs every MCP request to the
system.ai_gateway.usagetable, and the unified trace table (Beta) captures tool requests and responses in OpenTelemetry format.
How can MCP tool failures increase AI costs?
MCP tool failures increase AI costs because an agent treats a failed tool call as a problem to solve, not a reason to stop. It retries the call, rewrites the arguments, rereads the schema or tries another route, and each of those turns is a full model call that carries the conversation so far. The task often finishes anyway, so the extra tokens show up only as a vague rise in spend. You can't control that cost until you can see which tools fail and what each failure takes to recover from.
Why do tool failures turn into token spend?
An agent's bill is mostly context. Databricks notes that by the time inference runs, the user's request is a small fraction of the input; tool results, code searches and instructions make up the rest. Each failed call adds a turn on top of that context, and a loop of failures adds many.
The patterns that drive the spend:
- Silent retries. The agent resends the same call, or a variant, until something works.
- Guessing on loose signatures. Tool signatures are often under-specified on purpose, partly to save context tokens. The model fills the gap with a reasonable guess, such as a JSON array for "a list of fields", and a server that accepts only one shape crashes.
- Unhelpful errors. A traceback tells the agent nothing about what it did wrong. Databricks found that recovery cost tracks error-message quality closely.
- Fleet-wide repeats. Many agents and sessions call the same tool, so one small server bug becomes a recurring cost.
- Verbose results. Bloated tool output inflates every later turn. Auditing popular tools and cutting their verbosity is one of the token-overhead fixes Databricks describes.
What should you look for in MCP cost controls?
| Capability | Why it matters |
|---|---|
| Per-call logging of MCP requests | Token totals can't tell a failing tool from real growth. You need the tool, status and requester for each call. |
| Session and subagent IDs | Grouping calls by session shows how many turns an agent spent recovering from one error. |
| Request and response capture | The arguments the model sent, and the error it got back, tell you whether to fix the tool or the prompt. |
| Tool selection | Exposing only the tools an agent needs removes calls it shouldn't make. |
| Rate limits | A per-user cap on calls per minute bounds what a looping agent can burn before anyone looks. |
| Policies and audit | Blocking known-bad calls, and recording who or which agent made each call, closes the loop. |
How Databricks approaches MCP tool cost
Unity Gateway governs MCP servers as Unity Catalog securables, so the control plane that routes model traffic also sees tool traffic. Unity Gateway is generally available; Beta features are labeled.
Usage tracking. Every MCP request lands in the system.ai_gateway.usage system table with service_type = 'MCP_SERVICE', the HTTP status_code, the requester and an mcp_metadata struct that records the tool name and JSON-RPC method, such as tools/call. The session_metadata fields carry the client's session and subagent IDs, so you can count failing calls by tool and see how they cluster within sessions.
Unified trace table (Beta). Once a metastore admin enables it, the unified trace table captures requests and responses across Unity Gateway model and MCP services in one Unity Catalog table, in OpenTelemetry format. Filter by trace_id to replay a failed agent run, or use AI functions to analyze common error patterns in LLM and MCP calls. Trace delivery is best-effort, so keep the usage table and audit logs as your system of record.
Controls. Choose which tools a registered MCP exposes: unselected tools don't appear in tools/list, and calls to them are rejected. Set requests-per-minute rate limits per service, user or group; calls over the limit get HTTP 429. Service policies on MCPs (Beta) evaluate a tool call before it runs and can allow it, block it or require approval. Each MCP call is also logged as an mcpCall event in system.access.audit.
Databricks ran this loop on its own agents. Engineers traced MCP calls through Unity Gateway, asked plain-English questions of the trace table to rank the recurring errors, and fixed the small server bugs behind them. The lesson: design tools for how models actually call them. Coerce a list into a string, default an omitted parameter, absorb an unexpected argument.
FAQs
How do I find which MCP tools waste the most spend?
Group MCP calls by tool and status code, then check how many turns sessions take after an error. On Databricks, query system.ai_gateway.usage filtered to MCP_SERVICE rows, or the unified trace table (Beta) for arguments and responses.
Can rate limits stop a runaway agent loop?
They bound it. A per-user limit on an MCP service caps how fast a looping agent can call a tool, after which it gets HTTP 429 responses. It doesn't fix the bug behind the loop.
Should I fix the tool or the prompt?
Usually the tool. Databricks found that most "wrong" calls were reasonable guesses against loose signatures, so tools should accept natural variations and return errors that say what to change.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.