Why Did My Agent's Tool Call Fail? Reading the Work-Session Failure Timeline
Your agent says “the tool failed”. Claude Code, Codex and Cursor all do roughly the same thing next: print one line of the error, maybe retry, then work around it or give up. An hour later you want to know three things. What failed first? What was the agent doing just before? And whose problem is it: the arguments your agent sent, the MCP server behind the proxy, or a rule that refused the call?
If the agent reaches its tools through MCPProxy (v0.76.0 or later), the answer is already recorded. MCPProxy groups tool calls into work sessions, each one agent’s run of work, and can open a session at its first failure with the calls that led up to it.
This post walks through one failing run from start to fix. The screenshots and terminal output are real, taken from a local demo instance with throwaway servers: a small tickets server, the reference everything server, a quarantined crm server and a search-api server that points at a dead address.
The 60-second path
- Open the Web UI and go to Activity → Sessions (
http://127.0.0.1:8080/ui/activity?view=sessions). - Switch on Failed only.
- Find your run and press Timeline.
Each row is one run. The middle row is the one we will follow:
support-botis the agent token the run used.~demo-agent (reported)is the client name; the~means the client said so about itself and no known client was matched.run: ticket-triageis a label the caller sent with its requests (more on that below).- 11 calls, 5 failures, 1 blocked. A call that a policy of MCPProxy refused (quarantine, a profile, a rate limit) is a failure too, but it is counted apart as a block, so a flood of refusals cannot bury a real failure.
- The last column is the last failure: a fixed sentence for the kind of failure, its error class, the
server:toolit hit and when. Under it, the time of the first failure.
Pressing Timeline opens the run at its first failure that is still in the log, with up to 20 rows before it and 20 after:
The address of that page names the session: /ui/activity?view=sessions&ws=<session id>. Without anything else it opens at the first failure; add &at=failure:<n>, &at=end or &at=row:<activity id> to open it somewhere else. To share one particular row in a ticket, use the row: form, because failure numbers count only the failures still in the log. Next failure and Previous failure step through those.
What a work session is
For an MCP connection, a work session is one credential, one client and one project (when the client discloses one). It ends after 30 minutes without a call; a connection that is still open and calls again resumes it. A reconnect inside that window does not split it. A new or regenerated token starts a new one, and so does a restart of MCPProxy: a long run that spans a restart shows as two sessions.
REST calls have sessions too. A script that calls POST /api/v1/tools/call gets one per credential and calling surface (rest, cli, webui or tray), split further by run label when it sends one.
Reading the timeline
These are the rows you will meet most. The first three are things the agent did, the last two are context. (Prompt requests get a row of their own kind too.)
| Row | What it is |
|---|---|
server:tool (for example tickets:get_ticket) | A call to an upstream tool. It is the attempt that is recorded: a call that failed before it could be sent has this row too. |
call_tool_read / call_tool_write / retrieve_tools, marked “built-in tool” | The MCPProxy tool the agent actually invoked. An upstream call made through call_tool_read and its siblings is stored as two rows: the upstream call and the built-in call around it. When it fails, the upstream call is the counted failure and the built-in row repeats the error. |
| ”policy decision”, amber, Blocked | MCPProxy refused the call. For a quarantined server or tool, or a profile that does not allow it, that happens before anything is sent upstream. |
| Plug icon, Event or Recovered | An upstream event: connection lost, process exited, token refresh failed, login required, connection restored. It is not a request of the agent. It is what happened to a server the session called, placed by time. |
| Session started / Session ended | The two ends of the run. |
Colour does most of the sorting. Red is a failed call. Amber with “Blocked” is a refusal by MCPProxy (“Rejected” when a concurrency limit or a token’s rate limit refused it). Green is a recovery.
Whose fault is it?
Open a row with the arrow at its end. The details of a failed tool call normally carry an error class and a fault: client, proxy or upstream.
Failure 1 of our run:
proxy_policy, fault client: the arguments did not match the tool's input schema, so the call was never sent.
The agent sent "limit": "10" where the schema wants an integer. MCPProxy validates arguments before dispatch, so the upstream never saw this call. Note what the timeline shows 700 ms later: the same tool, called again, succeeded. The agent read the error and corrected itself. That is a failure you can ignore.
Failure 4 is a different animal:
network, fault upstream, with the reason one level up directly above it: the server's process exited.
The call’s own error says “transport closed”, which tells you little. The row above it says why: the tickets server’s process exited. The arguments ({"week": "2026-W48"}) are valid; this one is not the agent’s doing.
A short guide to the combinations you will see most:
| Row looks like | Error class · fault | Read it as |
|---|---|---|
| Red, “invalid arguments for …” | proxy_policy · client | The agent’s arguments failed schema validation. Not sent. |
| Amber, Blocked | proxy_policy (policy decision) | MCPProxy refused it, typically before sending: a quarantined server or tool, a profile. |
Red, class network (for example “transport closed”) | network · upstream | The connection to the server failed or was not there. A plug-icon event on the same server just before it is the likely cause. |
| Red, duration about as long as your call timeout | timeout · upstream or proxy | A deadline passed: upstream once the call was handed to the server’s connection, proxy if it expired before dispatch. |
Red, class auth | auth · upstream | The server answered 401 or 403, or needs an OAuth login. |
One caution: an upstream event is context, not a verdict. It is placed by time, so an event of one server can sit right above a failed call to another. Check the server name before you blame it.
The whole run, read once
Five failures sounds bad. Read in order, the run has a to-do list of three:
- 17:37:25
tickets:search_tickets, invalid arguments. Self-corrected on the next call. Nothing to do. - 17:37:26
crm:get_ticket, blocked: the server is quarantined. Someone has to review it. - 17:37:27
search-api:web_search, server not connected. No event next to it, because nothing changed during the run: this server never came up. A configuration problem. - 17:37:28
tickets:export_report, process exited. A bug in that tool. - 17:37:29
tickets:get_ticket, server not connected. A casualty of number 4: the call arrived before MCPProxy had the server back. Two seconds later the timeline shows Connection restored, and the next call to the same tool succeeds.
The list row said “5 failures, last: the upstream server could not be reached”. Only the timeline shows that the last failure was a consequence of the fourth.
The same thing from a terminal
Everything above is available over SSH or in CI. List the runs that failed:
mcpproxy activity sessions --failed --since -24h
ID TOKEN CLIENT PROJECT RUN STARTED DURATION CALLS FAILURES LAST FAILURE REASON
ws-8669dbbd34e169b1 ci-agent rest - smoke-test-417 2026-12-01 17:38:09Z 14s (active) 2 1 2026-12-01 17:38:09Z The call's arguments did not match the tool's input schema.
ws-61352ae0ae7ca2c0 support-bot ~demo-agent - ticket-triage 2026-12-01 17:37:21Z 29s (active) 11 5 (1 blocked) 2026-12-01 17:37:29Z The upstream server could not be reached.
ws-7b267e7a53e3aea8 support-bot ~demo-agent - release-notes 2026-12-01 17:36:57Z 20s (active) 2 1 2026-12-01 17:37:17Z The call timed out.
Showing 3 of 3 sessions
Timeline of one session: mcpproxy activity session <id>
Then print every failure of one run with the row before each:
mcpproxy activity session ws-61352ae0ae7ca2c0 --failures --before 1
Failure 1 of 5
# TIME KIND TARGET STATUS DURATION ID DETAIL
7 2026-12-01 17:37:24.273Z internal_call everything:call_tool_read success 53ms 01M8SAXHAKQ9W7VDD6JZDGV67N -
FAIL 8 2026-12-01 17:37:25.027Z call tickets:search_tickets error - 01M8SAXJ13QSKSSJZBHZ7Z4TDA proxy_policy: invalid arguments for tickets:search_tickets: at '/limit': got string, want int...
Failures 2-5 of 5
# TIME KIND TARGET STATUS DURATION ID DETAIL
10 2026-12-01 17:37:25.729Z internal_call tickets:call_tool_read success 49ms 01M8SAXJR6ZENEH00FS4F3AQ6P -
BLOCK 11 2026-12-01 17:37:26.591Z policy_decision crm:get_ticket blocked - 01M8SAXKHZ74VA4SNZ6VKK6C4J Server is quarantined for security review
FAIL 12 2026-12-01 17:37:27.530Z call search-api:web_search error - 01M8SAXMFA1NE58PS7A6BG7N05 network: Server 'search-api' is not connected (state: Error) - use 'upstream_servers' tool to...
13 2026-12-01 17:37:28.932Z UPSTREAM EVENT tickets error - 01M8SAXNV4SY44Y6QSBX9JYEGR process_exited · The upstream server's process exited.
FAIL 14 2026-12-01 17:37:28.994Z call tickets:export_report error 323ms 01M8SAXNX2DGT4776K9V7VXN0P network: tool 'export_report' on server 'tickets' failed: CallTool failed for 'export_report'...
15 2026-12-01 17:37:28.994Z internal_call tickets:call_tool_write error 385ms 01M8SAXNZNQDX91PMX3JHNA4NY tool 'export_report' on server 'tickets' failed: CallTool failed for 'export_report': transpo...
FAIL 16 2026-12-01 17:37:29.252Z call tickets:get_ticket error - 01M8SAXP54ADNK1GNVCYQAPX74 network: Server 'tickets' is not connected (state: Error) - use 'upstream_servers' tool to ch...
(The two header lines of the session are left out here.) FAIL and BLOCK mark the counted row of each failed attempt. Rows that are context for more than one failure are printed once, under a heading that names the failures they belong to.
The flags worth remembering:
| Command | What you get |
|---|---|
mcpproxy activity session <id> | The run at its first failure, 20 rows before and after. |
... --failures --before 5 | Every stored failure, each with the 5 rows before it. |
... --at failure:4 --include-bodies | The fourth failure, with the arguments and responses of the rows on the page. |
... --at end --before 50 | The last row and the 50 before it. |
... --at row:<activity id> | Around one particular row. |
mcpproxy activity show <activity id> --include-response | One call in detail, with its arguments and response. |
In the Web UI, Copy as CLI command under a timeline gives you the command for the page you are looking at.
Name your runs
A session is told apart by credential, client and project. Two scripts that share one token, call the same way (both over REST, say) and run within 30 minutes of each other land in the same session, and their calls interleave in one timeline. There are two ways out.
Give each agent its own token. mcpproxy token create --name ci-agent --profile <profile> and the Sessions list tells them apart by name.
Or send a run label. X-MCPProxy-Run is accepted on MCP over HTTP and on REST tool calls. For an MCP client, add it to the server’s headers (Claude Code’s .mcp.json shown; other clients have an equivalent):
{
"mcpServers": {
"mcpproxy": {
"type": "http",
"url": "http://127.0.0.1:8080/mcp",
"headers": { "X-MCPProxy-Run": "ticket-triage" }
}
}
}
For a script that calls the REST API:
curl -X POST http://127.0.0.1:8080/api/v1/tools/call \
-H "X-API-Key: $TOKEN" \
-H "X-MCPProxy-Run: smoke-test-417" \
-H "Content-Type: application/json" \
-d '{"tool_name":"call_tool_read","arguments":{"name":"tickets:get_ticket","args_json":"{\"id\":\"T-1043\"}"}}'
Then find that run by name:
mcpproxy activity sessions --run smoke-test-417
The rules are short. The label is 1 to 128 printable characters. An invalid value is ignored and never fails the call. It is combined with the credential, so it cannot join two tokens’ work, and it is not forwarded to upstream servers. One credential can open at most 1,000 named sessions a day. The label is stored and shown as sent to everyone who can see the session, so do not put a secret or a signed URL in it.
Gate a CI job on it
With a run label that is unique to the job, “did this agent run hit a tool failure?” is a short script. -o json prints the data object of the REST response:
RUN="nightly-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" # any id unique to this job attempt
# ... run the agent with X-MCPProxy-Run: $RUN ...
sleep 5 # activity rows are written in the background; give the last one a moment
FAILED=$(mcpproxy activity sessions --run "$RUN" --failed -o json)
if [ "$(echo "$FAILED" | jq '.total')" != "0" ]; then
mcpproxy activity session "$(echo "$FAILED" | jq -r '.sessions[0].id')" --failures --before 3
exit 1
fi
When the run has a failed session, the job prints its failures into the log and fails. Add --no-blocked if a session whose only failures are policy blocks should pass. A label that repeats (one per day, say) would also match yesterday’s retry, so make it unique.
Without the CLI, the same two questions over HTTP:
# Sessions with failures
curl -s -H "X-API-Key: $TOKEN" \
"http://127.0.0.1:8080/api/v1/work-sessions?failed=true&run=$RUN"
# One session, positioned at its first failure
curl -s -H "X-API-Key: $TOKEN" \
"http://127.0.0.1:8080/api/v1/work-sessions/ws-61352ae0ae7ca2c0/timeline?at=first_failure&before=5"
The answer is wrapped as {"success": true, "data": {...}}. Each timeline row has an index, a kind (call, internal_call, policy_decision, prompt, other, upstream_event, session_start, session_end) and, except for the two session boundary rows, its activity record; a failed row has failed: true, a block policy_block: true, and the record of a failed upstream call normally carries error_class and fault_domain.
Common patterns, and the fix for each
“The call’s arguments did not match the tool’s input schema.” (proxy_policy, fault client.) The error returned to the agent includes the tool’s input schema and a hint to fix the arguments and retry, so a single occurrence followed by a success is the system working. If the same tool fails this way run after run, open the row, look at what the agent sent, and fix the cause upstream: a tool description that suggests the wrong type, or a prompt that tells the agent to pass something the schema does not accept.
Blocked: “Server is quarantined for security review”. Retrying will not help; by default a quarantined server waits for a human. Look at what it exposes, then approve it:
mcpproxy review show crm # captured tool definitions and scan verdicts
mcpproxy review approve crm
If review show has nothing to show yet, mcpproxy review fetch crm captures the definitions first. By default review approve enables only the read-only tools with a clean scan; --all or --tools covers the rest. The Review page of the Web UI does the same. Other blocks you may see are a profile or token scope that does not include the tool, and a rate limit (shown as “Rejected”).
A failed call with “Process exited” or “Connection lost” just above it, same server. The connection to the server broke mid-run, and the event is the likely cause. The server’s log usually says why:
mcpproxy upstream logs tickets
In the demo it held the server’s last line on stderr, export_report: out of memory building CSV. Calls to that server that arrive before it is back fail fast without being sent; they are consequences, not separate problems.
“The upstream server could not be reached”, and no event near it. Often the server was already down. If a loss was recorded before the run started (since MCPProxy last started, and with no recovery after it), the timeline shows that earlier event, marked as preceding the session. If the server never connected at all, as with search-api here, there is no event to show. Check it directly:
mcpproxy upstream list
mcpproxy upstream logs search-api
mcpproxy doctor
“The call timed out.” Look at the duration of the failed row. If it is as long as call_tool_timeout (2 minutes by default; the demo instance was set to 20 seconds, and the row says 20.0s), that limit is the likely one: either the tool is too slow for it or it hung. Raise call_tool_timeout in mcp_config.json for tools that legitimately take long; otherwise look at the upstream. A much shorter duration points at a different deadline, such as a network timeout, and raising the setting will not help.
“The upstream server needs a login.” That is the reason the Sessions list shows for error class auth when the server is waiting for a login. The timeline often has an upstream event next to the call that says a login is required or a token refresh failed. Log in again:
mcpproxy auth login --server=<name>
What is kept, and who can see it
- Retention. A session stays in the Sessions list for
session_retention_daysafter its last activity (7 by default). Its rows live as long as the activity log keeps them (activity_retention_days, 90 by default). The log also has record and size caps; when one is reached, whole sessions can go before either age limit, the one with the oldest last activity first. The settings are read at start. - Counts stay honest. Calls, failures and blocks are lifetime counts of the session. When retention has removed the start of a session or some of its failures, the timeline says so at the top instead of showing a shorter history as if it were complete (the note about a removed start is shown to administrators).
- Bodies are opt-in. The list and the timeline show the result, the error and the order of calls. Arguments and responses are fetched only when you open a row or pass
--include-bodies. Values flagged as sensitive are returned masked, and under the size cap the bodies of the oldest rows are removed first while the rows themselves stay. - The “reason” is fixed wording. The sentence in the list (“The call timed out.”) comes from a closed set, chosen by the kind of failure. It never contains argument or response text.
- Scope. An administrator sees every session. An agent token sees only its own sessions, and of each only the part that touched servers in its reach.
Reference
- Work sessions and the failure timeline: how sessions are derived, upstream events, retention
- Web UI: Sessions and the failure timeline
- CLI:
activity sessionsandactivity session - REST API: Work sessions
- Agent tokens, for giving each agent its own identity
The next time an agent tells you “the tool failed”, do not ask the agent. Open the session, go to the first failure, and read upward.