matt8p
Joined 5 years ago
Joined 5 years ago
I was experimenting with writing writing unit tests for MCP servers. I find unit testing incredibly useful for writing assertions for every MCP primitive: tools, prompts, and resources.
This helps with ensuring that future changes aren't breaking the server's behavior. To do this, I used a simple set up with Jest and MCPClientManager, a custom MCP client I wrote for testing.
Hope you find the article an interesting read!
Matt
Let's say you're testing PayPal MCP. You can write a test case prompt "Create a refund order for order 412". The test will run the prompt and check if the right PayPal tool was called.
The CLI helps with: 1. Test different prompts and observe how LLMs interact with your MCP server. The CLI shows a trace of the conversation. 2. Examine your server's tool name / description quality. See where LLMs are hallucinating using your server. 3. Analyze your MCP server's performance, like token consumption, and performance with different models. 4. Benchmarking your MCP server's performance to catch future regressions.
The nice thing about CLI is that you can run these tests iteratively! Please give it a try, and would really appreciate your feedback.
I've been building MCPJam, an open source LLM chat playground for MCP servers. It's a MCP server testing tool, like Postman for MCP servers. You'll learn a lot about building LLM clients, working with React, Hono, Vercel AI SDK, lots of AI product engineering concepts.
If you're interested in contributing, or checking out the project, here's the GitHub:
https://github.com/MCPJam/inspector
To start, you can take a look at the Issues tab and see if there's anything there that interests you. Easy tasks are labelled "good first issue". Leave a comment in the issue if you're interested in taking it on!
Switching to Next was a mistake for our use case. We didn't consider that our users are starting MCPJam with npx. Our npm package size exploded to 280MB. Next.js was too heavyweight for a locally ran web app. Switching back to Vite + Hono brought our package size to 9MB, much more manageable.
This post isn't to bash Next.js. It's just to remind you that tech stack does matter. We didn't think about the consequence of switching to Next and didn't consider our users' use of npx. If MCPJam was a hosted webapp, it would probably matter less. Remember to think about your stack's tradeoffs before you commit to building!