Browse the blog

Keep credentials out of OpenAPI-generated MCP tools

  • frontmcp
  • mcp
  • security
  • openapi

Maintained guide. How checks work.

When an OpenAPI operation becomes an MCP tool, decide where its API credential will come from. Putting it in tool arguments can expose it to the client and its logs. FrontMCP's OpenAPI adapter can resolve credentials on the server and construct headers for each request. Your API must still enforce which records the caller may access.

This revision replaces the original unsourced incident story and categorical security promises with a concrete review procedure. It does not assert that a particular converter has a vulnerability. The adapter reference owns supported configuration; the security hub explains defaults and application responsibilities.

Where credentials can leak

Consider a hypothetical tool accepting an API token as an argument. If the client records calls, the token can end up in its logs. Server-side resolution keeps it out of the argument schema. If a real integration previously logged tokens, review access to those logs and rotate affected credentials.

The MCP access token and the backing API credential serve different purposes. Reusing one as the other requires the API to accept its issuer, audience and permissions. Do not enable passthrough merely because both use the Bearer header.

Choose a credential source

Use OpenapiAdapter from @frontmcp/adapters, registered under an app's adapters. The OpenAPI lesson includes a spec, a fixture API and runnable checks.

SettingAppropriate useReview before deployment
staticAuthA server-owned credentialPrivileges, rotation and secret storage
authProviderMapperSelect a scheme credential from caller contextTrusted identity, scheme name and missing-credential behavior
securityResolverResolve credentials for a particular callPrecedence over other options and every scheme used
securitySchemesInInputAn explicitly chosen model-supplied credentialExposure in prompts, arguments and logs; avoid for ordinary service credentials
passthroughCallerTokenAn API accepting the same bearer tokens as MCPIssuer, audience, expiry and backing API authorization

Read the exact signatures and precedence before combining sources. A credential supplied by one mechanism can override another.

Keep credentials scoped to one request

Build request headers from authenticated context. Avoid storing the current user's token in a shared mutable object. A global API client can be shared; mutable caller credentials should not be shared across requests.

Fresh headers reduce one class of accidental leakage. They do not establish tenant isolation. Derive tenant identity from trusted context, and have the API check access to each record. A tenant ID in an ordinary tool argument does not prove membership.

Follow the credential, record and result

  1. The client authenticates to MCP.
  2. The server derives identity and tenant from verified context.
  3. The adapter resolves the API credential and sends the permitted operation.
  4. The API checks record access before returning data.
  5. The result reaches the client and potentially its hosted model. Keep secrets out of results too.

Self-hosting the MCP process does not prevent tools from contacting external APIs or returning data to a hosted model. Trace those boundaries for your deployment.

Test with two callers

Use the tenant reporting example for an executable allow/deny pattern. For an OpenAPI integration, also check:

  • A missing or invalid caller credential is refused before a backing API request.
  • Tenant A cannot retrieve Tenant B's record by guessing an ID or changing an argument.
  • Concurrent requests send only their own credentials.
  • Missing or expired API credentials fail without exposing tokens in errors.
  • Logs, traces and widget metadata contain no credentials.

These checks establish the cases they execute; test counts cannot establish exhaustive coverage. Inspect the generated schema and run negative access checks before exposing customer data.

Report a docs issue. Site usage and privacy.