Why use it
- Zero boilerplate — Turn REST APIs into MCP tools without writing glue code
- Type-safe — Automatic Zod schema generation from OpenAPI specs
- Multi-auth support — Built-in support for multiple authentication providers
- Production-ready — Comprehensive security validation and error handling
- Flexible — Filter operations, customize schemas, and inject custom logic
Installation
Quick start
Configuration
Required Options
string
required
Unique identifier for this adapter instance. Used to prefix tool names when multiple adapters are present.
string
required
Base URL for API requests (e.g.,
https://api.example.com/v1).OpenAPIV3.Document | OpenAPIV3_1.Document | object
In-memory OpenAPI specification object. Accepts typed documents or plain objects from JSON imports. Use either
spec or url, not both.string
URL or file path to the OpenAPI specification. Can be a local file path or remote URL. Use either
spec or url, not
both.Optional Configuration
Record<string, string>
Static headers applied to every request. Useful for API keys or static authentication tokens.
(ctx: FrontMcpContext, headers: Headers) => Headers
Function to dynamically set headers based on request context. Access
ctx.authInfo, ctx.sessionId, ctx.traceContext, etc. Headers set here are hidden from MCP clients.(ctx: FrontMcpContext, body: any) => any
Function to transform or augment the request body before sending. Access
ctx.authInfo, ctx.sessionId, etc. Useful for adding tenant IDs or user-specific data.LoadOptions
Options for loading the OpenAPI specification — headers, timeout, validation, and
$ref resolution security. See refResolution for controlling how external $ref pointers are resolved.GenerateOptions
Options for tool generation — filtering, naming, schema depth, format resolution, and more. See Advanced Features and Format Resolution for details.
InputTransformOptions
Hide inputs from the schema and inject values at request time. Supports global, per-tool, and generator-based transforms. See Input Schema Transforms.
ToolTransformOptions
Customize generated tools with annotations, tags, descriptions, and more. Supports global, per-tool, and generator-based transforms. See Tool Transforms.
SchemaTransformOptions
Modify input/output schema definitions at fetch() time. Use
schemaTransforms.input and schemaTransforms.output for global, per-tool, or generator-based transforms.OutputSchemaOptions
Control where and how output schema is exposed:
mode ('definition' | 'description' | 'both'), descriptionFormat ('jsonSchema' | 'summary'), and a custom descriptionFormatter.DataTransformOptions
Transform tool definitions and API response data. Supports
preToolTransforms (schema-level) and postToolTransforms (response-level), each with global, per-tool, and generator forms. See Data Transforms.SpecPollerOptions & { enabled: boolean }
Enable live polling to auto-detect spec changes and rebuild tools at runtime. Requires
url option (not spec). See Polling & Live Updates for full configuration reference.'summaryOnly' | 'descriptionOnly' | 'combined' | 'full'
How to generate tool descriptions from OpenAPI operations. Default:
'summaryOnly'.FrontMcpLogger
Logger instance for adapter diagnostics. When using
OpenapiAdapter.init() within a FrontMCP app, the SDK automatically provides the logger via setLogger(). For standalone usage, you can optionally provide a logger implementing the FrontMcpLogger interface; if omitted, a console-based logger is created automatically.Authentication
The OpenAPI adapter provides multiple authentication strategies with different security risk levels. Choose the approach that best fits your use case.Strategy 1: Static Headers (Medium Risk)
Best for: Server-to-server APIs with static credentials.Strategy 2: Auth Provider Mapper (Low Risk) ⭐ Recommended
Best for: Multi-provider authentication (GitHub, Slack, Google, etc.). This approach maps OpenAPI security scheme names to authentication extractors. Each security scheme can use a different auth provider from the authenticated user context.- Extracts security scheme names from OpenAPI spec (e.g.,
GitHubAuth,SlackAuth) - For each tool, looks up the required security scheme
- Calls the corresponding extractor function to get the token from
ctx.authInfo - Applies the token to the request
Security Risk: LOW — Authentication is resolved from the request context, not exposed to MCP clients.
The
ctx parameter in authProviderMapper, headersMapper, bodyMapper, and securityResolver
callbacks is the FrontMcpContext containing authInfo, sessionId, traceContext, and more. By the time your tool executes,
authentication has been verified and auth fields are populated.Strategy 3: Custom Security Resolver (Low Risk)
Best for: Complex authentication logic or custom security requirements.Security Risk: LOW — Full control over authentication resolution from request context.
Strategy 4: Static Auth (Medium Risk)
Best for: Server-to-server APIs where credentials don’t change per user.Strategy 5: Dynamic Headers & Body Mapping (Low Risk)
Best for: Adding user-specific data (tenant IDs, user IDs) to requests.Security Risk: LOW — User-specific data is injected server-side, hidden from MCP clients.
Default Behavior (Medium Risk)
If no authentication configuration is provided, the adapter usesauthInfo.token for all Bearer auth schemes.
Advanced Features
Filtering Operations
Control which API operations become MCP tools.Input Schema Transformation
Customize the input schema definition for generated tools usingschemaTransforms.input:
Input Schema Transforms
Hide inputs from AI/users and inject values server-side at request time. This is more powerful thanschemaTransforms.input because it provides access to the authentication context.
Security Benefit: Sensitive inputs like tenant IDs and user IDs are injected server-side, never exposed to MCP clients.
Tool Transforms
Customize generated tools with annotations, tags, descriptions, and more.Output Schema Display
Control how output schemas appear in tool definitions via theoutputSchema option:
Custom Schema Formatter
Provide your own formatter (can be async to support LLM-based generation):Data Transforms
Transform tool definitions and API response data viadataTransforms:
Pre-Tool Transforms (Schema Level)
Modify schemas and descriptions before tools are wrapped — applied duringfetch() to McpOpenAPITool definitions:
Post-Tool Transforms (Response Level)
Transform API response data at runtime:Error Handling: Transform failures are logged and the original data is returned, ensuring graceful degradation.
x-frontmcp OpenAPI Extension
Configure tool behavior directly in your OpenAPI spec using thex-frontmcp extension:
openapi.yaml
Description Mode
Control how tool descriptions are generated from OpenAPI operations:Format Resolution
Enrich generated tool schemas with concrete constraints derived from OpenAPIformat values. When enabled, formats like uuid, date-time, email, int32, etc. are expanded into patterns, descriptions, and min/max constraints.
Load Options
Configure how the OpenAPI spec is loaded.$ref Resolution Security
When the adapter dereferences$ref pointers in your OpenAPI spec, it enforces security restrictions by default:
file://protocol is blocked — prevents local file reads (e.g.,$ref: "file:///etc/passwd")- Internal/private IPs are blocked — prevents SSRF to cloud metadata endpoints and internal services
http://andhttps://to public hosts are allowed — external schema references work normally
127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 (cloud metadata), ::1, fd00::/8, and hostnames localhost, metadata.google.internal.
Configure via loadOptions.refResolution:
refResolution Options Reference
Polling & Live Updates
The adapter can automatically detect changes to your OpenAPI spec and rebuild tools at runtime — no server restart required.- Resets its internal generator
- Calls
fetch()to regenerate all tools - Notifies subscribers via
onUpdate()
For complete configuration options (retry, health monitoring, change detection strategies, and best practices), see the Polling & Live Updates guide.
How It Works
Request Processing
- Path Parameters — Interpolated into URL template (e.g.,
/users/{id}→/users/123) - Query Parameters — Validated and appended to URL
- Headers — Merged from
additionalHeaders,headersMapper, and security config - Request Body — Validated and transformed by
bodyMapper(for POST/PUT/PATCH) - Authentication — Applied via selected strategy (auth provider mapper, security resolver, etc.)
Response Processing
- JSON responses — Automatically parsed to objects
- Text responses — Returned as plain text
- Error responses — Thrown as errors with status code and message
Complete Examples
Multi-Provider OAuth Application
Multi-Tenant SaaS Application
Expense Management (From Demo)
Security Best Practices
Use Auth Provider Mapper
For multi-provider authentication, use
authProviderMapper to map each security scheme to the correct auth provider. This provides LOW security risk.Never Hardcode Credentials
Always store credentials in environment variables or secrets manager. Never commit credentials to source control.
Avoid includeSecurityInInput
Setting
generateOptions.includeSecurityInInput: true exposes auth fields to MCP clients (HIGH risk). Only use
for development/testing.Validate User Context
Always validate that
authInfo.user contains the expected fields before extracting tokens. Handle missing tokens gracefully.Security Risk Levels
The adapter automatically validates your security configuration and assigns a risk score:Built-in Security Protections
Beyond authentication, the adapter includes defense-in-depth protections:
Auth Type Routing: Tokens are automatically routed to the correct context field based on security scheme type (Bearer →
jwt, API Key → apiKey, Basic → basic, OAuth2 → oauth2Token).
Troubleshooting
Error: Missing auth provider mappings
Error: Missing auth provider mappings
Cause: Your OpenAPI spec defines security schemes that aren’t mapped in
authProviderMapper.Solution: Add all required security schemes to authProviderMapper:Error: Authentication required but no auth configuration found
Error: Authentication required but no auth configuration found
Cause: The tool requires authentication but no auth configuration was provided.Solution: Choose one of the authentication strategies:
- Add
authProviderMapper(recommended for multi-provider) - Add
securityResolver(for custom logic) - Add
staticAuth(for server-to-server) - Add
additionalHeaders(for static API keys)
Tools not appearing
Tools not appearing
Cause: Tools may be filtered out by
filterFn or excludeOperations.Solution: Check your filter configuration or remove filters to include all operations.TypeScript errors with OpenAPI spec
TypeScript errors with OpenAPI spec
Cause: OpenAPI spec may not be typed correctly.Solution: Cast the spec to
OpenAPIV3.Document:API Reference
OpenapiAdapter.init(options)
Creates a new OpenAPI adapter instance. Parameters:options: OpenApiAdapterOptions— Adapter configuration
@App({ adapters: [...] })
Security Types
Performance Tips
Links & Resources
Demo Application
See the expense management demo app using the OpenAPI adapter
Example OpenAPI Spec
OpenAPI spec used in the demo application
Generator Library
Underlying library for OpenAPI to MCP conversion
Source Code
View the adapter source code