Documentation

AI agents and MCP

A hosted Model Context Protocol endpoint and a local adapter that let AI QA and coding agents discover, plan, request and release approved test data — bounded, metadata-only tools on the same authorized API.

What it is — and is not

The same nine tools are available two ways:

  • Hosted endpoint https://api.datanivra.com/mcp (MCP Streamable HTTP, stateless JSON responses), for agents that run in hosted products and cannot start a local process;
  • Local adapter datanivra-mcp (pipx install datanivra-mcp), a stdio process an agent host starts on your machine or runner.

Both call the ordinary DataNivra API with the session of whoever uses them (a person's session, or a CI workload session). They are an interface to a policy-constrained service, not a bypass:

  • every request needs that session's bearer token; there is no unauthenticated access and no shared service account;
  • the agent gets exactly the permissions of the session — it cannot approve requests, author or approve profiles, register sources, resolve secrets, run SQL or export data;
  • every decision (approved, waiting for a person, denied) is taken by the server, as for any other caller.

Status: available. The full flow — plan, request, status polling, certification evidence and release — has run through the hosted endpoint on DataNivra's hosted service, signed in with a GitHub Actions workload identity. Examples live in examples/mcp (see examples/mcp/README.md).

Connect to the hosted endpoint

Use any MCP client that supports the Streamable HTTP transport and a custom Authorization header:

{
  "mcpServers": {
    "datanivra": {
      "type": "http",
      "url": "https://api.datanivra.com/mcp",
      "headers": { "Authorization": "Bearer ${DATANIVRA_TOKEN}" }
    }
  }
}

Get the token as a person with datanivra login --url https://api.datanivra.com (approve the code in the console; works with email sign-in), then datanivra token, for example export DATANIVRA_TOKEN="$(datanivra token)" (PowerShell: $env:DATANIVRA_TOKEN = datanivra token). In CI use datanivra login --workload-identity … (a workload session lasts at most 15 minutes). A person's session lasts 15 minutes; run datanivra token again to get a renewed one, up to 12 hours after sign-in. Keep it in the client's environment or secret store, never in a committed file. The endpoint does not offer OAuth sign-in yet.

What the endpoint enforces besides the API's own checks:

  • One message per POST: a request gets one JSON answer; a notification gets 202. There is no event stream and no MCP session id.
  • No browsers: requests with an Origin header are refused (403 ORIGIN_REFUSED).
  • Limits: 1 MiB per message; 30 tool calls per minute per token (burst 10, answered as RATE_LIMITED); 503 BUSY with Retry-After when the endpoint is saturated. Every tool call also counts against the API's normal per-user and per-tenant limits.
  • Errors: 401 AUTHENTICATION_REQUIRED without a bearer token; an expired or unknown token gives the tool error TOKEN_INVALID.

Tools

ToolCalls
list_permitted_profilesGET /v1/test-data/profiles
get_profile_schemathe approved definition of one profile version
validate_test_data_requestlocal manifest validation (no network)
plan_test_data_requestPOST /v1/test-data/plan (no side effects)
request_test_dataPOST /v1/test-data/requests
get_request_statusGET /v1/test-data/requests/{test_data_request_id}
get_certification_evidencecertificate and value-free lease evidence metadata
get_lease_metadataenvironment lease metadata (a target reference, never credentials)
release_test_data_leasePOST /v1/test-data/requests/{test_data_request_id}/release

Security

  • Metadata only, bounded. Tool results carry ids, states, reason codes, counts and digests, with size limits; never rows or credentials. Tokens are never placed in the agent's context.
  • Untrusted input. Tool arguments are validated against the v1 contracts like any manifest; text an agent passes is data, never instructions to the server. A prompt-injected agent can at most ask for what the session's approved profiles allow.
  • Tenant binding. The session determines the tenant; another tenant's ids are indistinguishable from unknown ids.
  • Audit correlation. Every call is an ordinary API call with a correlation id and audit events. The hosted endpoint runs each tool call through the API's full request pipeline, so it is authorized, rate-limited and audited exactly like a REST call with the same token; it never stores tokens.

Example

{
  "tool": "request_test_data",
  "arguments": {
    "request": {
      "profile": { "name": "healthcare-integration", "version": 1 },
      "scenarios": [{ "scenario_code": "HC_ROUTINE_CARE", "count": 500 }],
      "purpose_ref": "QA-1234"
    },
    "idempotency_key": "agent-run-4242-1"
  }
}

Typical answers: DENIED with WORKLOAD_NOT_PERMITTED_BY_PROFILE (the profile does not name the identity), PENDING_HUMAN_APPROVAL with AUTOMATIC_APPROVAL_DISABLED, or AUTO_APPROVED inside an enabled envelope. Check examples/mcp/README.md for the exact argument schema of each tool.

← All documentation