Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions fern/products/mcp-generator/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Generate a hosted MCP server from an OpenAPI specification with Fern. Follow the

## Prerequisites

- The [Fern CLI](https://www.npmjs.com/package/fern-api), version 5.191.0 or later.
- The [Fern CLI](https://www.npmjs.com/package/fern-api), version 5.x.0 or later.
- A Fern account, and access to the [Fern dashboard](https://dashboard.buildwithfern.com/). Deploying requires `fern login` on your machine, or a `FERN_TOKEN` environment variable in CI.
- An OpenAPI spec. This guide uses the Swagger Petstore sample.
- A network that allows `*.fernmcp.dev`. If your company blocks it, ask your IT team to add `*.fernmcp.dev` to the allowlist. Agents on that network can't reach the server until they do.

```bash
npm install -g fern-api
fern --version # 5.191.0 or later
fern --version # 5.x.0 or later
fern login
```

Expand All @@ -37,14 +37,10 @@ Replace `<your-org>` in the commands that follow with your organization name.

```bash
mkdir petstore-mcp && cd petstore-mcp
curl -o petstore.json https://petstore3.swagger.io/api/v3/openapi.json

fern init --openapi ./petstore.json --org <your-org>
fern init --openapi https://petstore31.swagger.io/api/v31/openapi.json --org <your-org>
```

This creates a `fern/` folder that contains your spec and a file named `sdk-config.yml`.

The Petstore spec lists its server as the relative path `/api/v3`, and an MCP server needs the full address of the API it calls. The next step sets that address in `sdk-config.yml`.
This creates a `fern/` folder with a file named `sdk-config.yml` that points at the spec URL.
</Step>

<Step title="Ask for an MCP server">
Expand All @@ -54,21 +50,19 @@ Edit `fern/sdk-config.yml` so the file reads:
```yaml title="fern/sdk-config.yml"
schemaVersion: sdk-config/v1
sdkName: api
api:
baseUrl: https://petstore3.swagger.io/api/v3
source:
specs:
- id: api
type: openapi
path: ./openapi.json
url: https://petstore31.swagger.io/api/v31/openapi.json
targets:
- language: mcp
output:
delivery: hosted
slug: petstore
```

`api.baseUrl` is the address the server's tools call, and it takes precedence over the `servers` entry in your spec. If your spec's `servers` entry is already a full address, you can leave `api` out. `slug` names the server and becomes the last part of its URL. It takes 1 to 30 lowercase letters, numbers, and single hyphens, and can't start or end with a hyphen.
The server's tools call the address in the spec's `servers` entry. The Petstore spec lists it as the relative path `/api/v31`, and the CLI resolves a relative path against the spec URL, so the tools call `https://petstore31.swagger.io/api/v31`. For a local spec file with a relative `servers` entry, set the full address in `api.baseUrl`, which takes precedence over `servers`. `slug` names the server and becomes the last part of its URL. It takes 1 to 30 lowercase letters, numbers, and single hyphens, and can't start or end with a hyphen.
</Step>

<Step title="Generate">
Expand Down Expand Up @@ -123,7 +117,7 @@ targets:
delivery: zip
```

A local server needs the full address of your API too, from `api.baseUrl` or the `servers` entry in your spec. A `zip` build accepts a relative path, but every tool call on the local server then fails with `Invalid URL`.
A local server needs the full address of your API too, from `api.baseUrl` or the `servers` entry in your spec.

`fern generate` then downloads `fern/generated/mcp.zip` and deploys nothing. Unzip it and start the server with Node.js:

Expand All @@ -143,7 +137,7 @@ The zip also holds the generated TypeScript project in `project/`. Its `README.m

| You see | Cause and fix |
|---------|---------------|
| `[metadata.baseUrl] Invalid url`, or `Invalid URL` from every tool on a local server | The `servers` entry in your spec is a relative path such as `/api/v1`. Set `api.baseUrl` in `sdk-config.yml` to the full address, for example `https://api.example.com/v1`, or use the full address in `servers`. |
| `has a relative servers URL`, `[metadata.baseUrl] Invalid url`, or `Invalid URL` from every tool on a local server | The `servers` entry in a local spec file is a relative path such as `/api/v1`, or the CLI is older than 5.x.0. Set `api.baseUrl` in `sdk-config.yml` to the full address, for example `https://api.example.com/v1`, or use the full address in `servers`. |
| `Deploying to Fern's hosted MCP platform requires authentication` | The CLI has no Fern credentials. Run `fern login`, or set `FERN_TOKEN` in CI. |
| `Tool name "..." is ... characters` or `contains unsupported characters` | MCP tool names take 1 to 64 letters, digits, `_`, or `-`. [Set `x-fern-mcp-name`](/learn/mcp-generator/get-started/configure#name-and-describe-tools) on the operation, in your spec or an [overlay](/learn/api-definitions/openapi/overlays). The error message includes an overlay entry to copy. |
| `MCP tool filter entries matched no tools` | An entry in `tools` or `toolsets` names no operation. The message lists the available tool names. |
Expand Down
Loading