#31 AI agents and MCP 6.1 min
Debug an MCP Server with the MCP Inspector
A tool on my MCP server failed with an error a model could do nothing with. The Inspector's command line mode showed me that error exactly as a model would get it.
Predict the problem count
Copy the code folder first. Read server.py and run.py. Without running anything, predict which tool the report will call NO description, and which call will count as opaque. Then add a one-line docstring to refund in server.py and predict the new 'problems' number for server.py. The video's unedited run printed problems: 2 for server.py, so your predicted number is for the edited file (a run with the docstring added printed problems: 1). Afterwards delete the docstring again.
A hint
A problem is a tool with no description, or an error that says nothing but the name of the tool.
Add a product and predict the message
In server_fixed.py add one more entry to STOCK, for example "LOCK-3": 9. Predict the full text of the error that stock_level gives for the SKU NOPE now, including the order of the known SKUs. The code sorts them. The Inspector needs Node and npm, so work this out by reading the code. Note that run.py shows only the first 40 characters of the message, so a real run would cut the list short.
A hint
Look at how the f-string builds the list: ', '.join(sorted(STOCK)).
Why is the bad refund not a problem?
Read the opaque function in run.py. The call refund(order_id=abc, amount=5) is an error on both servers, yet it is not counted as a problem. Write one or two sentences saying why, using the check the function makes.
A hint
The video's run shows the error text starts with a validation message, not just the tool name.
Add a fifth call to the report
In run.py add the call ("stock_level", {"sku": "BELL-2"}) to the tries list. Predict the line it will print for each server and whether the problems count changes. If you have Node 22 and have run npm install as in the video, run python run.py and compare with your prediction.
A hint
BELL-2 is in the STOCK dictionary, so it is a known product.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
Two small made-up tools over standard input and output. Only the Inspector's command line mode was run (Inspector 2.12.0 on Node 22.14.0, which is older than the documentation asks for), not the web page or the terminal interface. The two checks are my own and no language model was used.
Up next in AI agents and MCP
More in AI agents and MCP
- #01 Local AI Agent in Python: No API Key (Ollama)
- #12 Multi-Agent Patterns in Plain Python: Pipeline, Router, Loop
- #22 OpenAI Agents SDK vs LangGraph vs Plain Python
- #23 Agent Memory: What to Keep and What to Forget
- #24 Approval Gates for Risky Agent Actions
- #25 Tool Errors: Retries, Fallbacks and Made-Up Answers
