tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > MCP Protocol > MCP Server Testing and Debugging

MCP Server Testing and Debugging

Author: Venkata Sudhakar

Testing MCP servers has two distinct levels. Unit tests call the tool functions directly as plain Python functions - no MCP protocol overhead, no agent, just the business logic. Integration tests spin up the full MCP server and connect an ADK agent to verify the end-to-end call chain. Both are essential: unit tests catch logic bugs fast, integration tests catch protocol issues and tool schema mismatches.

Because FastMCP tool functions are plain Python functions decorated with @mcp.tool(), you can import and call them directly in pytest without starting the server. For integration tests, use MCPToolset.from_server() inside an async test to verify that the agent correctly discovers and calls the tools. The mcp CLI also provides an interactive inspector for manual testing during development.

The below example shows a ShopMax India MCP server with both unit tests and an integration test for the inventory tools.


Write unit tests that call tool functions directly,


It gives the following output,

$ pytest test_shopmax_inventory.py -v

test_shopmax_inventory.py::test_get_stock_existing_product    PASSED
test_shopmax_inventory.py::test_get_stock_out_of_stock        PASSED
test_shopmax_inventory.py::test_get_stock_unknown_product     PASSED
test_shopmax_inventory.py::test_restock_valid                 PASSED
test_shopmax_inventory.py::test_restock_invalid_quantity      PASSED
test_shopmax_inventory.py::test_restock_unknown_product       PASSED
test_shopmax_inventory.py::test_agent_calls_mcp_tool          PASSED

7 passed in 3.42s

For interactive debugging during development, use the MCP inspector CLI: run 'mcp dev shopmax_inventory_server.py' to launch a web UI where you can call individual tools, inspect their schemas, and see raw JSON responses without writing any test code. This is the fastest way to verify a new tool before wiring it to an agent. In CI/CD pipelines, run the unit tests in every pull request and the integration tests in a nightly build - integration tests require a live Python subprocess which makes them slower and more resource-intensive than unit tests.


 
  


  
bl  br