# or Using Chocolatey:
choco install speakeasy
```

### 2. Uploading the OpenAPI document

The APItizing Burgers project already has `openapi.yaml` and `openapi.json` OpenAPI documents. If you're building an MCP server from an existing FastAPI project, you might need to generate these files. Take a look at our [tutorial on generating an OpenAPI document with FastAPI](/openapi/frameworks/fastapi#basic-fastapi-setup) for step-by-step instructions.

To start the process, run the following command from the project's root directory:

```bash
speakeasy quickstart
```

You'll be prompted to authenticate with Speakeasy and then enter the path to the OpenAPI document. Enter `./openapi.yaml`.

![OpenAPI document path](/assets/mcp/building-fastapi-server/speakeasy-openapi-path.png)

### 3. Naming the SDK

Name the SDK `mcp-burger-sdk`.

![Choosing the SDK name](/assets/mcp/building-fastapi-server/speakeasy-choosing-sdk-name.png)

### 4. Selecting the output

Speakeasy will ask what you want to generate. Choose **Model Context Protocol (MCP) Server**, and then the sub-option **TypeScript SDK with Server**.

![Choosing the SDK type](/assets/mcp/building-fastapi-server/speakeasy-choosing-sdk-type.png)

Speakeasy will ask you where to save the generated SDK and what to name the npm package. Press **Enter** to use the current directory and the default package name, or modify them.

Speakeasy will generate a TypeScript SDK in the `mcp-burger-sdk-typescript` directory. The MCP server code will be located at `mcp-burger-sdk-typescript/src/mcp-server`, with a built version at `mcp-burger-sdk-typescript/bin/mcp-server.js` (this is the file you'll reference in your Claude Desktop configuration).

### 5. Adding the MCP server to Claude desktop

Now configure the MCP server in the `claude-desktop-config.json` file:

```json
{
  "mcpServers": {
    "McpBurgerSDK": {
      "command": "node",
      "args": [
        "path/to/mcp-burger-sdk-typescript/bin/mcp-server.js",
        "start"
      ]
    }
  }
}
```

Reload Claude Desktop and you should see the server and its available tools.

![Viewing the MCP server](/assets/mcp/building-fastapi-server/mcp-typescript-sdk.png)

You now have a working MCP server generated with Speakeasy.

### More configuration with Speakeasy

With Speakeasy, you can [customize your MCP server](/docs/standalone-mcp/customize-tools) using the `x-speakeasy-mcp` extension in your OpenAPI document.

For example, to disable the generation of a tool for an operation:

```yaml
paths:
  /products:
    post:
      operationId: createProduct
      tags: [products]
      summary: Create a product
      description: API endpoint for creating a product in the CMS
      x-speakeasy-mcp:
        disabled: true
        name: create-product
        scopes: [products, create, ecommerce]
        description: |
          Creates a new product using the provided form. The product name should
          not contain any special characters or harmful words.
```

In this code configuration, `disabled: true` specifies that the tool should be ignored.

You can use `name` to change the name of the MCP tool, or use `scopes` to tag tools, which allows you to run the MCP server with only specific groups of tools.

When you start the MCP server with Speakeasy, you can specify which scopes to include with the `--scope` flag:

```json
{
  "mcpServers": {
    "EcommerceSDK": {
      "command": "npx",
      "args": [
        "-y",
        "--package",
        "e-commerce-sdk",
        "mcp",
        "start",
        "--scope",
        "products"
      ],
      "env": {
        "API_TOKEN": "your-api-token-here"
      }
    }
  }
}
```

If you can't or don't want to modify an OpenAPI document, Speakeasy [overlays](https://www.speakeasy.com/openapi/overlays) provide a way to use the `x-speakeasy-mcp` extension without changing the original file, for example:

```yaml
overlay: 1.0.0
info:
  title: Add MCP scopes
  version: 0.0.0
actions:
  - target: $.paths.*["post","head","query"]
    update: { "x-speakeasy-mcp": { "scopes": ["products"] } }
```

The code above instructs Speakeasy to generate tools for operations with the tag `products` and HTTP operations of types `POST`, `HEAD`, and `QUERY`.

## FastMCP vs Speakeasy: Which tool should you choose?

FastMCP and Speakeasy offer two different paths to building an MCP server from your FastAPI application. The right choice depends on your priorities around development speed, code transparency, and long-term maintenance needs.

### Initial setup and configuration

**FastMCP** gets you running quickly by reusing your existing FastAPI app with minimal configuration. If your routes are typed and documented, FastMCP can expose them as tools with almost no additional work.

**Speakeasy** requires an OpenAPI document and an interactive CLI setup process to generate an MCP server. While this takes more time initially, it generates a clean, extensible SDK with a built-in MCP server that can integrate with Claude and Cursor, or run as a standalone service.

### Visibility of generated code

**FastMCP** takes the opposite approach: You don't see how tools are constructed. FastMCP automatically converts your FastAPI routes into MCP tools, but hides the internal logic, prompt structure, and resource handling. This makes debugging harder as your server grows.

**Speakeasy** generates explicit code for the server and tools in the `mcp-server` directory. You can inspect how each tool is defined, see the input and output mappings, and modify behavior as needed. This helps when you want to understand or extend how the MCP layer works.

### Customization options

**FastMCP** provides basic customization options. You can rename tools, set timeouts, or exclude routes using configuration options, but you're limited to the configuration parameters the library exposes.

**Speakeasy** allows for extensive customization, whether directly in the OpenAPI document or using overlays to define external configuration. You can change tool names, disable endpoints, apply scopes for selective tool groups, and modify descriptions, all without touching application code.

### Long-term maintenance considerations

**FastMCP** tightly couples your MCP server to your FastAPI app. Changes to the application's route structure will automatically update the available MCP tools, which simplifies maintenance for smaller projects but can create complexity as the API evolves.

**Speakeasy** separates the MCP server from application logic using the OpenAPI document, which serves as the single source of truth. Changes to your API require regenerating the MCP server from the updated specification, but the server remains independent of your application's internal structure.

### Distribution methods

**FastMCP** is designed for local development workflows within Claude Desktop. While effective for personal tools and rapid prototyping, it doesn't provide built-in mechanisms for packaging or distributing MCP servers to other environments.

**Speakeasy** generates MCP servers that can be published and distributed as npm packages or used directly with `npx`. This allows you to share tools across teams, deploy to different environments, and distribute to external users.

## Next steps

Having compared FastMCP and Speakeasy for generating MCP servers, here's how to choose the right tool for your project:

- Choose **FastMCP** if you don't have an OpenAPI document or don't plan to deploy and maintain the MCP server in the long term. FastMCP is a quick way to turn your existing routes into tools with minimal complexity, making it useful for exploring the MCP ecosystem or rapid prototyping.
- Choose **Speakeasy** if you have an OpenAPI document, plan to maintain the server over time, or want to share it with others. While Speakeasy requires more initial setup, it gives you more control, visibility, and customization. Speakeasy also works well for prototyping, especially when you want to build something fast while keeping a path open to production.