MCP servers have two audiences — the protocol and the model — and both need testing.
Protocol-Level Testing
- Use an inspector to connect, list capabilities and call tools by hand.
- Check initialisation and capability negotiation succeed.
- Verify schemas are valid and match what the handler actually accepts.
- Test errors: invalid arguments, missing records, failing back ends.
Unit and Integration Tests
Test handlers directly as ordinary functions, and test the server end-to-end with an SDK client in your test suite.
Logging
For stdio servers, log to stderr — anything else on stdout corrupts the protocol stream. For HTTP servers, use structured request logs.
Model-Level Testing
Connect the server to a host and try realistic requests:
- Does the model choose the right tool?
- Are arguments correct?
- Are results understandable?
Record failures and improve descriptions or tool design.
Common Problems
- Printing debug output to stdout in stdio servers.
- Schemas with missing descriptions or wrong required fields.
- Tools returning huge outputs.
- Timeouts on slow back ends — add progress or limits.
Regression
Keep a set of test requests to rerun after changes.