
Use interactive tools for quick debugging (Postman, MCP Inspector), and automated tests for CI/CD (MCP Tester or language-specific test frameworks).
- Validate tool discovery (
tools/list) and invocation (tools/call) before deploying. - Catch protocol/JSON-RPC issues early.
- Automate checks to prevent regressions in CI/CD.
Important: For any table cells or inline examples containing curly braces or angle brackets we use code formatting so MDX doesn’t try to parse them.
1) Quick manual testing with Postman (STDIO)
Postman supports launching a process and communicating over STDIO. This is ideal for ad-hoc verification of JSON-RPC requests/responses. Steps:- Open Postman → New → MCP request.
- Select transport type: STDIO.
- Set command to
nodeand arguments to the full path of yourserver.js(e.g.,/full/path/to/server.js). - Postman will spawn
node /full/path/to/server.jsand communicate via STDIO. - Use
tools/listto discover tools, andtools/callto invoke them.
add-integers tool:
server.js example that exposes a single tool (add-integers):
a=3 and b=4 and verify the output ("7").
2) Using MCP Inspector (interactive web UI)
MCP Inspector gives a web UI tailored to MCP servers. It’s excellent for exploring tool metadata, trying inputs, and seeing raw JSON-RPC traffic. Quick start:- The inspector prints a local URL and a session token — open that in your browser.
- Configure transport: STDIO, command:
node, arguments:server.js. - You can call
tools/list,tools/call, fill input fields, and view a history of JSON-RPC messages and raw stdin/stdout.
- Transport configuration (STDIO)
- Tool discovery and input fields (e.g.,
add-integers) - JSON-RPC request/response history
- Convenient manual testing similar to Postman but MCP-focused
3) Automated tests with a Node “MCP Tester”
Automated tests are essential for CI. The pattern below spawns your server, writes JSON-RPC messages to STDIN, captures STDOUT, and asserts correct behavior. Example test helper (compact):sendMessageuses a simple polling approach to extract JSON from a mixed stdout buffer. For production, implement a robust framing strategy (newline-delimited JSON, explicit frames, or length-prefix).- Add a proper readiness probe (e.g., wait for a specific log line or implement a
readyJSON-RPC method) rather than fixed sleep timers. - Integrate these tests as part of
npm testor your CI job so failures block merges.
4) Crude but fast: echoing JSON into the server (shell)
For one-off checks you can pipe a JSON-RPC request into the server process:Recommendations and next steps
- Use Postman or MCP Inspector for interactive debugging and rapid exploration.
- Add automated tests (like the MCP Tester example) to CI so regressions are caught early.
- If your server is implemented in other languages (Python, Java, etc.), implement equivalent tests using that language’s test frameworks:
- Python:
pytest,unittest - Java:
JUnit - Node:
mocha,jest
- Python:
- For reliable automation:
- Use a clear STDIO framing protocol (e.g., newline-delimited JSON).
- Add explicit readiness checks before sending requests.
- Capture and assert on both structured JSON-RPC responses and important logs.
Automated tests are essential. Manual checks are helpful for debugging, but CI/CD tests prevent regressions and give confidence when deploying changes.
Links and references
- MCP Inspector (npm)
- Postman
- JSON-RPC 2.0 specification: https://www.jsonrpc.org/specification
- Node child_process.spawn: https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options