Skip to main content
The OpenAPI Adapter automatically converts REST API endpoints defined in an OpenAPI 3.x specification into fully-functional MCP tools. This guide walks you through adding the adapter to your app.
Prerequisites:
  • A FrontMCP project initialized (see Installation)
  • An OpenAPI 3.x specification (URL or local file)
  • Basic understanding of REST APIs

What You’ll Build

By the end of this guide, you’ll have:
  • ✅ An app that automatically generates tools from an OpenAPI spec
  • ✅ Type-safe input validation for all API endpoints
  • ✅ Authentication configured for API requests
  • ✅ Tools that inherit all your app-level plugins and providers
The OpenAPI Adapter is perfect for quickly exposing REST APIs to AI agents without writing custom tool code for each endpoint.

Step 1: Install the Adapter


Step 2: Add Adapter to Your App

Create or update your app to include the OpenAPI adapter:

Step 3: Configure Your Server

Add your app to the FrontMCP server:
src/main.ts

Step 4: Run and Test

1

Start the server

The server will load the OpenAPI spec and generate tools for each operation.
2

Verify tools are loaded

Check the console output for messages like: [INFO] Generated 15 tools from expense-api [INFO] Server listening on http://localhost:3000
3

Test with Inspector

Open the MCP Inspector and you’ll see all generated tools from your API spec!

Understanding Generated Tools

Each OpenAPI operation becomes a tool with:

Tool Naming

Tools are named using the pattern: {adapter-name}:{method}_{path} For example:
  • GET /usersexpense-api:get_users
  • POST /expensesexpense-api:post_expenses
  • GET /expenses/{id}expense-api:get_expenses_id
If your OpenAPI spec includes operationId, that will be used instead of the generated name.

Input Schema

The adapter automatically converts OpenAPI parameters to Zod schemas:
OpenAPI spec
Becomes a tool with this input:

Advanced Configuration

For comprehensive documentation on all configuration options including inputTransforms, toolTransforms, descriptionMode, and the x-frontmcp OpenAPI extension, see the full OpenAPI Adapter documentation.

Filter Operations

Only include specific endpoints:

User-Based Authentication

Use authenticated user context for API requests:

Multi-Tenant Setup

Include tenant ID from user context:

How It Works

1

Load Spec

The adapter fetches and parses the OpenAPI specification from the URL or uses the provided spec object
2

Generate Tools

Each operation in the spec becomes an MCP tool with: - Automatic input schema (path params, query params, headers, body) - Type-safe validation using Zod - Description from the operation summary
3

Register Tools

Generated tools are registered with your app and inherit: - App-level plugins (caching, logging, etc.) - App-level providers - App-level authentication
4

Execute Requests

When a tool is called:
  1. Input is validated against the schema
  2. Headers/body are mapped (if configured)
  3. HTTP request is made to the API
  4. Response is parsed and returned

Common Patterns

Add multiple adapters to one app:
Mix generated and hand-written tools:
Generated tools inherit app plugins:
Note: Requires the optional @frontmcp/plugin-cache package. Install it first:
Now all generated tools can use caching!

Troubleshooting

Possible causes:
  • Invalid OpenAPI spec URL
  • Spec is OpenAPI 2.0 (only 3.x supported)
  • All operations filtered out by filterFn
Solutions:
  • Verify the URL is accessible
  • Convert OpenAPI 2.0 to 3.x using Swagger Editor
  • Check your filter configuration
Possible causes:
  • Missing or invalid API credentials
  • Headers not properly mapped
Solutions:
  • Verify additionalHeaders or headersMapper configuration
  • Check that authInfo.token contains the expected value
  • Test the API directly with curl/Postman first
Possible cause:
  • OpenAPI spec has complex parameter definitions
Solution:

What’s Next?

Full OpenAPI Adapter Docs

Explore all configuration options and advanced features

Authentication Setup

Learn how to configure authentication for your APIs

Plugin System

Add caching, logging, and other features to generated tools

Demo App

See a complete example using the OpenAPI adapter

Complete Example

Here’s a full working example with authentication and caching: