Chapter 7. Testing, Securing, and Sharing Your MCP Server
You’ve built your server. It provides tools, prompts, and resources to client applications. It supports a bevy of client-provided capabilities like sampling, elicitations, and roots, along with utilities to make your life and your users’ lives easier, like logging, notifications, and pagination. What’s next? Your work is not yet done. As with any other software project, you still need to test your server code, evaluate its performance, secure it, and finally share it with the world.
Testing should be familiar to the software engineer. Servers are code, after all, and thus testing them takes the same form as testing any other code: unit testing, integration testing, and end-to-end testing still take the spotlight here. But on top of that, you have additional tools, such as MCP Inspector (which we’ve been using throughout Chapters 4 and 5), which allows you to directly test the functionality of your server, view logs and notifications, and otherwise simulate its use by a fully featured MCP client.
Evaluations are endemic to the world of machine learning. Outside of generative AI, evaluations happen in the context of model training. Within generative AI, evaluations involve anticipating user prompts and evaluating the results of those prompts against expected outcomes, including tool choice, tool execution and results, prompt results, guardrail performance, and more. Some of these evaluations are not relevant to MCP servers, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access