MCP Server for Test Case Generation: Connect Claude and Cursor
Let the AI agent you already use ask your API testing tool for tests. Create an agent key with only the permissions it needs, connect a real MCP client, and see the tests it generates appear in your project.
This is lesson 9.17 of Shift-Left API in Depth, the product track of the learning center. Lesson 9.16 let you bring your own model to Shift-Left API's AI features. This lesson turns it around: an AI agent you already use, talking to Shift-Left API. The MCP server is part of Professional, Enterprise and the 15-day trial, and the demo uses a trial.
How does an MCP server for test case generation work?
An MCP server for test case generation lets an AI agent, such as Claude or Cursor, ask your API testing tool for tests. MCP, the Model Context Protocol, is how AI agents call tools. Shift-Left API's server is a package on npm, @totalshiftleft/mcp-server, that your agent starts. It gives any MCP client tools to import a spec, generate tests, explain what is untested, close the gaps and run tests, so you can ask for a test suite from your editor or chat.
What do you need?
- Shift-Left API on Professional, Enterprise or the trial.
- An agent key, which the AI Agents screen creates together with the setup for your client.
- Node.js 20 or newer, on the machine your agent runs on.
- An MCP client: Claude Desktop, Claude Code, Cursor, or any other.
How do you create an agent key with only what an agent needs?
Open the account menu, then Platform settings → Integrations → AI Agents (MCP). Step one creates the key. Give it a name (the video names it after its client), optionally an expiry in days, and decide how much it may do:
- The Read-only agent tick lets the agent inspect and explain, nothing more.
- Allow this agent to run security checks is a separate box, and the video leaves it off. Security checks send crafted requests to a real system.
- The screen lists what the key will be able to do before you create it, and shows the key once.
A key can never do more than the person who created it. Production runs are refused by default, and every action an agent takes is recorded in the audit log against its key.
How do you set up Claude Desktop, Claude Code or Cursor?
Step two gives you the configuration to paste into your client. By default the client runs from npm, fetched by npx when your client starts it. A local checkout option runs it from a copy of the source instead. Pick the operating system your client runs on: on Windows the configuration starts npx through cmd /c. Restart the client afterwards.
What happens when a real MCP client connects?
The video connects a real client, the MCP project's own MCP Inspector, using the configuration the screen produced. It asks the server to list the projects, generates tests for one feature and asks it to explain coverage. Generating answers with 92 tests across six endpoints, saved. Coverage answers with 38 endpoints and 92 active tests: six endpoints with at least one test and 32 with none.
Back in Shift-Left API the tests are already in the project, under the feature's endpoints. They are ordinary tests, ready to edit and run like any others. When you are done with the agent, open Platform settings → Access & Identity → API Keys, check Last used and click Revoke. The key stops working at once.
Can you test an MCP server you built?
MCP Server import works the other way round. In a project, click Import API → MCP Server, enter your server's URL, click Connect and list tools, choose which tools are safe to run, and import them. Each tool becomes a request you can generate test cases for. This import is on the trial and Enterprise. For the testing side, read how to test MCP servers.
Try it yourself
With a trial: open Platform settings → Integrations → AI Agents (MCP), create an agent key, copy the setup for your client and restart the client. Ask it for tests for one of your APIs, or for the sandbox store's spec at https://demo.totalshiftleft.ai/openapi/rest.json once imported. If you build an MCP server, try Import API → MCP Server too.
Recap
- An MCP server for test case generation lets Claude or Cursor ask Shift-Left API for tests.
- Create a scoped agent key, copy the setup for your client, and the package comes from npm.
- As an MCP server for test automation it is built for safety: read-only keys, no production runs by default, an audit trail and a key you can revoke.
- As an MCP server for testing it also works in reverse: import another server's tools and generate test cases for them.
Next, lesson 9.18 covers API discovery: before you test, find the APIs you really have. Start a 15-day trial to follow along.
Try it: With a trial, open Platform settings → Integrations → AI Agents (MCP), create a read-only agent key, copy the setup for your client, restart the client and ask it to list your projects and explain what is untested in one of them.
Frequently asked questions
What is an MCP server for test case generation?+
A small program your AI agent starts so it can call tools in your API testing tool. Shift-Left API's MCP server is a package on npm, @totalshiftleft/mcp-server. It lets Claude, Cursor or any MCP client import a spec, generate tests, explain what is untested, close the gaps and run tests.
Which editions include the MCP server, and what do I need to run it?+
The MCP server is part of Professional, Enterprise and the 15-day trial. You also need an agent key from the AI Agents screen, Node.js 20 or newer on the machine your agent runs on, and an MCP client such as Claude Desktop, Claude Code or Cursor.
Is it safe to give an AI agent a key to my API testing tool?+
The key can never do more than the person who created it. A read-only key can only inspect and explain, running security checks is a separate switch that is off by default, runs against production are refused by default, everything the agent does is recorded in the audit log against its key, and you can revoke the key at any time.
Related lessons
Shift-Left API doesn't ship a model of its own; you bring one. Pick a hosted provider with your own key or a self-hosted model, test the connection, and see which model reviewed your tests.
You can only measure test coverage on the APIs you know about. Switch on Discovery, scan your computer, capture an app's calls and read the inventory, where every row says how sure Discovery is.
Your OpenAPI spec is most of a test plan already. Import it into Shift-Left API, explore what it creates, and generate tests from it with no requirements needed.