AI coding assistants are pretty good at reading an OpenAPI spec and writing integration tests. The awkward part starts when you actually want them to run those tests against a live server.
Most people end up giving the agent shell access with curl and an .env file full of Bearer tokens or API keys. That works for a quick experiment, but it falls apart fast if you care about security or reliability:
- Your secrets end up in the prompt context. API keys, client secrets, and internal staging URLs get passed around in tool outputs and conversation logs.
- There are no real guardrails. If an agent hallucinates a path or decides to test an admin endpoint, nothing stops it from hitting
DELETEendpoints. - A
200 OKisn't a contract test.curltells you the server responded, not whether the JSON payload actually matches your OpenAPI response schema.
I ran into this while building Open API Portal, so I added a scoped Model Context Protocol (MCP) test runner directly into the portal.

Keeping credentials out of the agent's hands
The main idea is simple: the AI agent should know the API contract, not the credentials or even the raw target URL.
In Open API Portal, you set up a Test Profile and an MCP Test Suite from the UI:
- Auth stays encrypted on the server. Bearer tokens, API keys, and Basic Auth credentials are encrypted at rest (
AES-256-GCM) and injected by the backend when a test runs. The agent never sees the token or thebaseUrl. - Only allowlisted endpoints are visible. You pick which
METHOD + /pathoperations a suite is allowed to touch. Everything else is off-limits. - Scoped MCP tokens. Your IDE or AI client connects to
/mcpusing a revocable bearer token instead of your main account session.
What the agent actually sees
When an agent connects to /mcp, it gets five tools:
-
list_test_profilesto see available environments and attached specs (without URLs or secrets) -
list_mcp_suitesto find test suites configured for a profile -
get_suite_endpointsto read parameters, request bodies, and response schemas for the allowlisted endpoints -
run_test_scenariosto execute multi-step tests on the server and get back pass/fail diagnostics -
get_uncovered_endpointsto check which endpoints in the suite still need test coverage
Chaining steps and checking schemas
Real API flows usually take more than one call. The server injects the profile's encrypted auth automatically on every step, and the agent can use skipAuth: true to verify negative 401 cases or capture values (using JSONPath or headers) to pass into later steps with {{var}}, plus built-in helpers like {{$uuid}} and {{$isoNow}}:
{ "name": "Create and Verify Order", "steps": [ { "name": "Reject Unauthenticated Request", "method": "GET", "path": "/api/v1/orders", "skipAuth": true, "expectedStatus": 401 }, { "name": "Create Order", "method": "POST", "path": "/api/v1/orders", "body": { "reference": "ord_{{$uuid}}", "amount": 49.99 }, "expectedStatus": 201, "capture": { "orderId": "$.id" }, "assertions": [ { "source": "body", "path": "$.status", "op": "eq", "value": "CREATED" }, { "source": "latency", "op": "lt", "value": 1000 } ] }, { "name": "Verify Order Contract", "method": "GET", "path": "/api/v1/orders/{id}", "pathParams": { "id": "{{orderId}}" }, "expectedStatus": 200, "validateSchema": true } ] } Whenever validateSchema is enabled, the runner validates the live JSON response against the OpenAPI schema using Ajv. If a field is missing or comes back with the wrong type, the agent gets the exact schema error and can fix the API code right away.
Every run is also saved as a Test Report inside the portal, so you can open the UI and see the exact status codes, latencies, assertions, and schema checks yourself.
Try it out
If you want to test it locally, the repo includes a built-in mock server so you don't need an external API to play with it:
git clone https://github.com/minuth/open-api-portal.git cd open-api-portal cp example.env .env npm install && npm run dev Source code and setup docs are on GitHub: github.com/minuth/open-api-portal.



