Notes
The server
The server has three tools. Search products and get order only read. Add to cart writes. Each tool calls the ShopRung API with the signed in customer's token, so ShopRung's own rules still apply. The server is written in Python with the official MCP SDK; argument limits such as a query of two to fifty characters are declared in the code and become part of the tool's schema.
search_products(query, limit=5)
read-only, query 2 to 50 chars
get_order(order_id)
read-only, own orders only
add_to_cart(product_id,
quantity=1)
writes, quantity 1 to 10
calls the ShopRung API with the
customer's token No network needed
The SDK's client can connect to the server object directly, in memory, with no process and no network. A pytest fixture opens it, and each test calls list tools or call tool exactly as an agent would. ShopRung itself runs for real, reset before each test, so results come from real data. The whole suite of fourteen tests ran in about two point four seconds.
from mcp import Client
import server
@pytest.fixture
async def client(shoprung):
async with Client(server.mcp)
as c:
yield c
r = await client.call_tool(
"search_products",
{"query": "mug"}) Test the contract
First, the contract the agent sees. The tool names are exact. Every tool and every argument has a description, because the model chooses tools by reading them. The schema carries the limits: query between two and fifty characters, quantity between one and ten, query required. And the hints: both readers are marked read only, add to cart is not, so a client can ask the user before it writes.
names == ["add_to_cart", "get_order", "search_products"] every tool and argument has a description query: minLength 2, maxLength 50 quantity: minimum 1, maximum 10 required == ["query"] read_only_hint: True, True, False for add_to_cart
Test the results
Then the results. Tools return structured content, so assert on fields, not on text: searching mug returns the green and red mugs, and the red one is out of stock. Alice's order two is shipped. For a tool that writes, check the side effect in the real system, not just the reply: after add to cart, the test reads Alice's cart straight from the ShopRung API and finds two green mugs.
search "mug":
["Green Build Mug",
"Red Build Mug"]
Red Build Mug in_stock False
get_order 2 as Alice:
status "SHIPPED"
add_to_cart 4 x 2, then
GET /api/cart directly:
[("Green Build Mug", 2)] Tool errors
Errors matter more than usual, because a model reads them and decides what to do next. Invalid arguments come back as a tool result with is error set, and a readable reason, so the agent can correct itself. Note one surprise: the order id as the text two in digits was quietly accepted as a number, which helps small models that send strings. Out of stock and unknown tools also gave clear messages.
query "m" → is_error:
"String should have at least 2
characters"
quantity 11 → is_error
order_id "two" → is_error
order_id "2" → accepted as 2
Red mug → "Red Build Mug
is out of stock"
unknown tool → "Unknown tool:
nope" A second user
Permissions need a second user. Bob asking for Alice's order got no order with id two, the same message as a missing order, which reveals nothing. Then we turned on ShopRung's order leak bug and ran the same suite: one test failed, because Bob now received Alice's keyboard order through the agent's tool. With case sensitive search on, three tests failed. An MCP server inherits every bug of the API behind it.
normal: is_error, "No order with id 2" with the order-leak bug on: 1 failed, 13 passed is_error=False, status SHIPPED, "1 x Quiet Mechanical Keyboard" with search-case on: 3 failed (search, limit, stdio)
Layers help
One bug did not show. With ShopRung accepting a quantity of eleven, all fourteen tests still passed, because the tool schema rejected eleven before ShopRung was ever called. That is defence in layers working for customers. But it also means the MCP suite cannot see the API bug, so the API keeps its own tests. Know which layer each test really checks.
ShopRung API now accepts 11 MCP suite: 14 passed quantity 11 is rejected by the tool schema (maximum 10) before ShopRung is called so test the API itself too: the MCP limit hides the bug
Failures and transport
Two more. When ShopRung is down, the tool must fail cleanly: a short message the agent can pass on, with no stack trace and no token in it. And one test starts the real server as a process over standard input and output, the way desktop apps run MCP servers, to prove packaging and start up work. In memory tests are fast; keep at least one over the real transport.
BASE_URL = localhost:1 → is_error: "Error executing tool search_products: ShopRung is not reachable right now. Try again later." token not in the message stdio: start server.py as a process, initialize, call search "keyboard" → passed
Snapshot the contract
Finally, snapshot the whole tool list. Descriptions and schemas are effectively prompts: a small wording change can change which tools a model picks. We changed one line, raising the quantity limit to ninety nine and shortening its description. Two tests failed: the limit test and the snapshot, which shows exactly what changed. Any change to the tool list then needs a reviewer, and ideally a rerun of the agent evals.
quantity: le=10 → le=99, "How many, 1 to 10." → "How many." test_input_limits: (1, 99) == (1, 10) FAILED test_tool_list_matches_the _snapshot: FAILED "tool list changed: review it"
WebMCP
WebMCP brings the same idea into the browser. A web page registers tools with a name, a description, an input schema and a function, or marks up a form with a tool name and description, and an agent in the browser calls them instead of clicking around. It is experimental, in a Chrome origin trial during twenty twenty six, so details may change. The tests stay the same: list the tools, call them, check errors and permissions.
in the page:
document.modelContext
.registerTool({ name,
description, inputSchema,
execute })
or a <form toolname="..."
tooldescription="...">
Chrome origin trial in 2026;
the API may still change
same tests: list, call, errors,
a second user Common mistakes
Mistakes. Testing the server only through a chatbot, which is slow and random, when the server can be called directly. Asserting on text instead of structured content. Letting stack traces or secrets into tool errors, which models repeat. Testing with one user. Trusting what a write tool says instead of checking the real system. Never starting the real process. And letting tool schemas change without review.
- testing only through a model
- asserting on text, not structured content
- stack traces or secrets in tool errors
- one user only
- trusting a write tool's reply
- no test over the real transport
- unreviewed schema changes
Say it like this
In the interview: I test it directly, without a model, using the SDK's in memory client in pytest. Contract tests cover tool names, descriptions, schemas and read only hints, plus a snapshot of the whole list. Behaviour tests assert on structured content, check side effects in the real system, cover tool errors, a second user and the backend being down, and one test runs the real server process.
- "Directly, without a model: an in-memory client in pytest.
- Contract tests for names, descriptions, schemas and hints, plus a snapshot. Results as structured content, side effects
- checked in the real system, tool
- errors, a second user, the backend down, and one test over the real transport."