MCP Server
Plug Shift-Left Studio into AI agents like Claude and Cursor via the Model Context Protocol, exposing tools to analyze endpoints, generate and validate tests, and explain coverage.
Overview
The MCP server (cursor-test-generation) lets external AI agents drive Shift-Left Studio's test-generation pipeline through the Model Context Protocol (MCP). Any MCP-capable client — Claude, Cursor, and others — can call its tools to analyze an endpoint, generate and validate tests, and explain coverage, and can read live coverage/gap/test/schema data as resources. It runs as a separate Node.js process and talks to the client over stdio.
Availability: Professional and Enterprise. This is a setup task performed by an administrator or developer with access to the backend host.
Before you begin
- You need shell access to the backend host and the ability to run
node backend/src/mcp/server.js. - The server connects to your MongoDB database using the same
MONGODB_URIthe backend uses. The MCP process must point at the same database whose endpoints and tests you want the agent to work on. - The server is scoped to exactly one tenant per process (see Step 2). It never falls back to another tenant's data.
- Generated tests are persisted straight into the project, exactly like tests created in the UI.
The 6 tools
The client discovers these tools automatically. Each takes an endpointId (a UUID) and, where noted, an optional projectId.
| Tool | What it does |
|---|---|
| analyze_endpoint | Analyzes an endpoint to produce a TestPlan showing what tests should be generated, including gap analysis, requirement mapping, and edge-case opportunities. Persists nothing. |
| generate_tests | Runs the full TestCompiler pipeline (analyze → generate → validate) and persists the resulting tests. Options: enableAI (default true) and apiType override (REST, SOAP, GraphQL, gRPC). |
| generate_for_gaps | Generates and persists tests that target specific coverage gaps. Optional gapTypes filter, e.g. statusCode, parameter, requestBody, schemaValidation, authDepth, performance. |
| validate_tests | Validates the existing tests for an endpoint — checks assertion types and required fields — and reports auto-fix suggestions, valid/dropped counts, and a valid rate. |
| enrich_test | Uses AI to improve a single test (by testId): enrichmentType of metadata (name/description), values (test data), or all. |
| explain_coverage | Produces a human-readable coverage report for an endpoint with scores, gaps grouped by type, and prioritized recommendations. |
The 4 resources
Resources are read-only. Each URI takes an endpoint UUID:
| Resource URI | What it returns |
|---|---|
coverage://{endpointId} | Live coverage scores and the per-dimension breakdown (status codes, parameters, request body, production-grade). |
gaps://{endpointId} | The current coverage-gap list with types, messages, and metadata. |
tests://{endpointId} | Summaries of existing tests (name, method, severity, purpose, technique, assertion count). |
schema://{endpointId} | The full endpoint schema — parameters, request body, responses, and API-type config. |
Step 1 — Start the MCP server
Run the server alongside the backend:
node backend/src/mcp/server.js
On startup it connects to the tenant's MongoDB database, registers the models and tools, and starts a stdio transport. It writes a line to stderr such as:
[MCP] cursor-test-generation server running (tenant: default)
A failed MongoDB connection is fatal — the server exits rather than run with no data.
Step 2 — Set the tenant scope
Each process serves one tenant:
- Single-tenant deployments — leave the defaults. The server connects to
MONGODB_URIand reportstenant: default. Do not setMCP_TENANT_IDhere; setting it whileMULTI_TENANT_ENABLEDis nottrueis a fatal error. - Multi-tenant deployments — set
MULTI_TENANT_ENABLED=trueand setMCP_TENANT_IDto the subdomain of the tenant this process may see. The primary database connection binds to that tenant's database, so every tool and resource is inherently tenant-isolated. An unknown tenant id is fatal — the server refuses to start.
Run a separate process per tenant if you need to serve more than one.
Step 3 — Connect an MCP client (Claude / Cursor)
Point your MCP client at the running server as a stdio MCP server whose command launches node backend/src/mcp/server.js (with the environment variables from Step 2). In Claude Desktop or Cursor, add it to the MCP servers configuration; the client then lists the six tools and four resources automatically. Ask the agent to, for example, "analyze endpoint <id>" or "generate tests for the coverage gaps on <id>," and it will call the matching tool.
Troubleshooting / Notes
- Server exits immediately — check stderr.
MongoDB connection failedmeans the URI is wrong or the database is unreachable;unknown tenant "…"meansMCP_TENANT_IDdoesn't match a configured tenant;MCP_TENANT_ID=… but MULTI_TENANT_ENABLED is not truemeans you set a tenant id in single-tenant mode. - Agent sees no data — confirm the process is scoped to the right tenant/database and that the endpoint UUIDs you pass exist in that project.
- Credentials — use scoped API keys for anything your automation needs to authenticate to.
- Generated tests land in the project just like tests created in the UI — review and refine them the same way.
Related articles
Related articles
- Administration Settings · Product documentation
- Server Connection · Product documentation
- Proxy Settings · Product documentation
- License Management · Product documentation
- User Management · Product documentation
- Role Permissions · Product documentation
Next steps
- Getting started · Install + connect your spec
- Configuration fundamentals · Stabilize runs
- Initial configuration · Users, licensing, projects
- Release notes · Updates and fixes
Still stuck?
Tell us what you’re trying to accomplish and we’ll point you to the right setup—installation, auth, or CI/CD wiring.