Learn how to build MCP servers from your API specifications using Speakeasy for production-ready servers with extensive customization options.
Getting started with Speakeasy
To build an MCP server using Speakeasy:
Install the Speakeasy CLI:
# Homebrew (macOS)brew install speakeasy-api/tap/speakeasy# Script Installation (macOS and Linux)curl -fsSL https://go.speakeasy.com/cli-install.sh | sh
Run Speakeasy quickstart:
speakeasy quickstart --mcp
Indicate whether you plan to deploy your server on Cloudflare:
Cloudflare is a popular choice for hosting MCP servers. If selected, a Cloudflare Worker config file will be generated with your MCP server code. This will make deploying your server to Cloudflare Worker easy.
This creates a TypeScript-based MCP server in the specified directory ready to be deployed into production.
Example server code
The generated MCP server includes a comprehensive file structure with TypeScript source code:
core.ts
build.mts
cli.ts
console-logger.ts
extensions.ts
mcp-server.ts
prompts.ts
resources.ts
scopes.ts
server.ts
shared.ts
tools.ts
Run your MCP server locally
Local Development Setup
For local development and debugging, you can run your MCP server directly from the generated code:
Once you’ve published your MCP server to npm (following our SDK Publishing Guide), you can test using the npm package format that will be used in production:
Speakeasy generates MCP servers with three primary distribution methods. These methods are not mutually exclusive - most customers use all three approaches to serve different use cases, with npm being the most common starting point:
1. Distribute on npm
Publishing your MCP server as an npm package provides the most flexible distribution method. Follow the SDK publishing guide for detailed instructions on publishing to npm and other package managers.
Benefits:
Universal compatibility: Single command works with all major MCP clients
Easy customization: Users can modify tools, add tools, and extend functionality
Version management: Standard npm versioning and dependency management
Team sharing: Simple distribution across development teams
A manifest.json file with metadata describing your MCP server
All necessary server files packaged for distribution
Tool descriptions and parameters automatically inferred from your OpenAPI specification
Icon and branding assets (if provided)
DXT Customization:
You can customize the generated DXT manifest through the gen.yaml configuration file:
targets: mcp-typescript: dxtManifestOverlay: icon: "https://example.com/my-icon.png" displayName: "My Custom API Tools" description: "Custom description for my MCP server" version: "1.0.0"
Hybrid Distribution Strategy
You can use all three distribution methods simultaneously, giving users flexibility to choose their preferred installation method based on their specific needs and technical requirements.