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:
Run Speakeasy quickstart:
Generate an MCP server:
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
Configure your MCP server to run locally in your MCP client (like Claude Desktop):
For local development:
Advanced configuration
Specify scopes at runtime
When starting the MCP server, you can specify which scopes to include:
This example configuration only mounts tools tagged with the read scope, creating a read-only server.
Specify individual tools
You can further limit the subset of tools mounted on an MCP server by specifying individual tool names:
Distribution methods
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
Distribute to external users
Version and maintain your MCP servers independently