With DocStar, debugging a failed MCP tool call takes minutes instead of guesswork: every call an AI assistant makes to your API through your DocStar MCP server is logged with what the assistant sent, the exact request that reached your API and the response it got back. Connect your coding agent to the DocStar MCP, ask it to read those logs, and it explains each failure and drafts the fix in your docs for you to review.
This guide covers why MCP tool calls fail, how to read the error codes, and the agent-first workflow we use to find and fix the cause.
Why MCP tool calls fail
When a person calls your API and gets an error, they read the message and try again. When an AI assistant calls it through an MCP server, the error goes to the assistant, which rephrases it ("that didn't work, sorry") or quietly tries something else. Your user never sees the real reason, and neither do you.
Most failures come from one of four places:
| Where it breaks | What it looks like | Usual cause |
|---|---|---|
| Sign-in |
401, or users asked to sign in again and again |
No signed-in user, a rejected token, or a sign-in setup problem |
| The path or id | 404 |
The assistant built the wrong URL or used an id that doesn't exist |
| The request body |
400 or 422
|
A missing required field, a wrong field name or a wrong type |
| Your API itself |
5xx, timeout, or no answer |
A bug, an outage or an unreachable API |
Notice that three of the four are usually docs problems, not code problems. The assistant called your API exactly the way your docs told it to. If the docs left out a required field or used an old field name, the call fails. That is why the fix for most MCP errors is better docs, and why DocStar keeps the docs, the logs and the fix in one place.
How DocStar shows you what went wrong
Every DocStar docs or API collection gets its own hosted MCP server. For API collections, assistants call your API through a general "call any API" tool, or through endpoint tools you give your most important endpoints. DocStar logs each of those calls.
In the collection's MCP tab, click Logs next to a tool that calls your API. The call-any-API tools share one log, and each endpoint tool has its own. The newest calls come first, and each one shows:
| Part | What it tells you |
|---|---|
| Summary | Whether the call worked, the method and path, when it ran, and a one-line reason when it failed |
| Input from the AI assistant | What the assistant gave the tool |
| Request sent to your API | Method, URL, query params, headers, body, and whether a signed-in user's token was sent |
| Response from your API | Status, time taken, size and the response body, including your API's own error message |
Tokens, API keys and other secret values are masked, calls are kept for two weeks, and you need edit access to the collection to see them. Full details are on the help page Build an MCP Server for Your App.
Reading the status codes
DocStar's help docs give a simple key for the most common errors:
401: your API rejected the token, or the user wasn't signed in.404: the assistant used a wrong path or id.400** or **422: the request body was wrong.
If the log shows the tool failed before it ever called your API, the problem is in the tool's input, not your API. If the call shows a "problem" such as an unreachable API, your API never answered.
Debug MCP errors with your AI agent
Reading logs one by one works for a single failure. For a week of calls, let your coding agent do it. This is the workflow we recommend with DocStar.
Step 1: Connect your agent to DocStar
Add DocStar to Claude Code, Cursor, Codex or another assistant. Use DocStar from your assistant's connector directory if it's listed there, or add it as a custom MCP server with this URL:
https://mcp.docstar.io/mcp
The first time the agent needs your workspace, you sign in to DocStar in your browser. There is no API key to copy, and the agent works only with the collections your account can access. See Connect Your AI Assistant.
Step 2: Give it one prompt
Open the agent in the repo for your API and paste something like this:
Use the DocStar MCP to debug my API's MCP server in the "Orders API" collection. Read the MCP logs for the last week, newest first. Group the failed calls by cause (sign-in, wrong path or id, wrong request body, API error). For each group, compare what the assistant sent with my latest code and my DocStar docs, explain why it failed, and propose the fix: endpoint docs, tool descriptions, the skill or the instructions. Show me every change before you save it, and save doc changes as drafts.
Step 3: What the agent does
The agent reads the log list through the DocStar API (a short summary of each call first, then the full details of the failed ones). For each failure it checks three sources side by side: what the AI assistant sent, what your API answered, and what your docs say. Then it tells you the likely cause, for example:
422** on create order:** the docs example still sendscustomer, but your code now requirescustomer_id. Fix: update the endpoint's body example and field descriptions.404** on get invoice:** assistants keep passing the order number where the invoice id belongs. Fix: say clearly in the endpoint description where the invoice id comes from, and which endpoint to call first.401** on every call since Tuesday:** no user token was sent, or your API refused it. Fix: check your sign-in setup (see below), not the docs.
It asks before changing anything. When you approve, it updates the endpoint docs, rewrites a tool's description or adds a line to the server's instructions, and saves its doc changes as drafts for you to publish.
Step 4: Review and publish
Your job is judgment: is the agent's reading of the error right, does the new wording match how your product works, and should anything stay private. Then publish. Updated docs feed your docs site, your llms.txt, your MCP server and your CLI at the same time, so the next assistant that calls the endpoint reads the fixed version.
Step 5: Check the fix in the logs
Ask the agent to run the same task through your MCP server again, or wait for real traffic, and check the logs. A 200 where the 422 used to be is your proof. For a fuller test plan, see How to Test If AI Agents Can Use Your API Docs.
Where the fix usually lives in DocStar
| Failure | Fix in DocStar |
|---|---|
Wrong body (400/422) |
Endpoint docs: every parameter described, plus a full JSON request body example |
Wrong path or id (404) |
Endpoint description, the server's skill (which endpoint to call first), or a dedicated endpoint tool |
| Wrong tool picked | Tool descriptions, including your own wording for the built-in tools (how to write them) |
| Rules ignored | Additional instructions: short rules assistants get every time they connect, under 2,000 characters |
Sign-in (401) |
Sign-in for API calls in the MCP tab: your OAuth app's details, token validation URL and redirect URIs |
Two sign-in checks catch most 401s. DocStar checks your token validation URL on every MCP request, so that endpoint must return 200 for a valid token. And every redirect URI shown in the MCP tab must be in your OAuth app's allowed callback URLs, or sign-in fails. Entering the OAuth app details is one of the few steps only a person on your team should do.
Get told about failures as they happen
Logs answer "why did it fail?". Failure alerts answer "did anything fail?". Turn them on in the MCP tab under Server settings, Failure alerts, and DocStar tells you when a tool, your token check or your sign-in fails for one of your users. Alerts go to up to 8 webhooks, a Slack channel, or up to 20 email addresses. The same problem is sent at most once every 10 minutes, with a count of repeats, and secret values are hidden. Our post MCP Failure Alerts walks through it.
A good routine: the alert tells you something broke, you paste it to your agent, and the agent reads the matching log entry and drafts the fix.
Keep it current so the same errors don't come back
Many MCP errors start the same way: a developer renames a field or adds a required parameter, and the docs get updated later or never. With DocStar, the same docs feed your docs site, llms.txt, your MCP server and your CLI, so stale docs don't just confuse people. The agent calls your API with the old field and the call fails.
DocStar's GitHub Sync keeps your API docs in your repo (api-docs/ for OpenAPI files), so they change in the same commit and pull request as the code. A docstar.md file and one line in AGENTS.md tell your coding agent to update the endpoint's spec whenever it changes the endpoint, and on push DocStar updates the docs site, MCP tools and CLI. Your agent can set it all up from one prompt:
Set up DocStar GitHub Sync for this repo.
One honest caveat: the agent still has to do the update. If someone changes code without an agent, or the agent skips the docstar.md rule, the docs drift and nothing catches it automatically. That's when the MCP logs and alerts above tell you. More in How to Keep Your API Docs in Sync with Your Code.
Prefer to click?
You can do all of this by hand: open the collection's MCP tab, click Logs next to the tool, open a failed call, compare the request with your endpoint docs, fix the docs in the editor and publish.
Why teams choose DocStar for MCP servers
One source for everything. Docs site, llms.txt, MCP server and CLI come from the same collection, so one fix reaches all of them.
Real logs, safely. Every call your MCP server makes to your API, with secrets masked.
Alerts where you work. Webhooks, Slack or email, without alert floods.
Agent-first. Your coding agent reads the logs, finds the cause and drafts the fix. You review and publish.
No server code. DocStar hosts the MCP server for you, with per-user sign-in for API calls.
FAQ
Where do I find MCP logs in DocStar? In your collection's MCP tab, click Logs next to a tool that calls your API. The call-any-API tools share one log, and each endpoint tool has its own.
How long are MCP logs kept? Two weeks. You need edit access to the collection to see them.
Can my AI agent read the logs for me? Yes. Connected to the DocStar MCP, your agent can read the logs through the DocStar API, explain each failure and propose fixes. It asks before changing anything.
Are tokens or API keys shown in the logs? No. Tokens, API keys and other secret values are masked.
Get started free
Turn your API docs into an MCP server that AI assistants can use, with logs and failure alerts built in. Get started free.
Originally published on the DocStar blog. Try DocStar free: https://docstar.io
Top comments (0)