Why use it
- Zero boilerplate to expose REST APIs as tools
- Runtime validation with Zod (derived from operation params/body)
- Handles path/query/header params, bodies, and JSON parsing
- Simple hooks to inject auth headers or shape the body
Quick start
apps/demo/src/apps/expenses/index.ts.
Options
Requiredname: string— Identifier for this adapter instance; disambiguates tools when multiple adapters are present.baseUrl: string— Base URL for requests (e.g.,process.env.API_BASE_URL).- One of:
url: string— Path or URL to the OpenAPI document (local file or remote).spec: OpenAPIV3.Document— An in-memory OpenAPI document.
additionalHeaders?: Record<string, string>— Static headers applied to every request.headersMapper?: (authInfo: AuthInfo, headers: Headers) => Headers— Map authenticated session data to headers (e.g.,Authorization, tenant IDs).bodyMapper?: (authInfo: AuthInfo, body: any) => any— Transform/augment the request body before sending.inputSchemaMapper?: (inputSchema: any) => any— Transform the generated input schema (hide/fill fields, etc.).- OpenAPI tool generation controls (passed to
openapi-mcp-generator): filterFn?: (op) => booleandefaultInclude?: booleanexcludeOperationIds?: string[]
Authentication examples
Static API key headerFiltering which operations become tools
Only generate tools for specific operations usingfilterFn or exclude by id with excludeOperationIds.
How requests and responses are handled
- Path params are interpolated into the template (e.g.,
/users/{id}) - Query params and headers are taken from validated inputs
- For non-GET/HEAD/OPTIONS methods, a request body is sent when defined
- Responses with
content-type: application/jsonare parsed to objects; otherwise raw text is returned
Tips
- Combine with app-level plugins (logging, caching, metrics) to enhance generated tools.
- You can attach multiple OpenAPI adapters to one app; set unique
namevalues to avoid tool id conflicts. - Use
inputSchemaMapperto hide sensitive fields from the tool interface while still supplying them server-side.
Links
- Demo app:
apps/demo/src/apps/expenses/index.ts - Spec used by the demo: https://frontmcp-test.proxy.beeceptor.com/openapi.json
- Generator library: https://www.npmjs.com/package/openapi-mcp-generator
- Source code:
libs/adapters/src/openapi