Generate Server
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:
-
Generate a TypeScript SDK:
-
Enable MCP server generation in your
.speakeasy/gen.yaml
: -
Regenerate your SDK with MCP server:
This creates a new src/mcp-server
directory with all the MCP server code and adds installation instructions to your README.
Server configuration
Configure your MCP server 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
Best practices
When building MCP servers with Speakeasy:
- Use clear OpenAPI documentation - Well-documented APIs generate better MCP tools
- Leverage the x-speakeasy-mcp extension - Customize tool names, descriptions, and scopes
- Implement proper error handling - Ensure your API returns meaningful error messages
- Test thoroughly - Verify your MCP server works with different clients
- Version your APIs - Use semantic versioning for your OpenAPI specifications
- Monitor performance - Track usage and performance of your MCP tools
Next steps
Having set up your MCP server with Speakeasy, explore these additional capabilities:
- Customize Tools - Learn how to use the
x-speakeasy-mcp
OpenAPI extension - Custom Resources - Add custom resources to your server
- Custom Prompts - Create reusable prompt templates
- Setting up OAuth - Configure authentication for your server
Last updated on