openapi-mcp enables any OpenAPI 3.x specification to be served as a robust, machine-readable MCP tool server. Validate your API specs, generate MCP tools, and start serving through stdio or HTTP in seconds.
Parse any OpenAPI 3.x YAML/JSON spec and generate MCP tools automatically. Get up and running in seconds.
Unique features designed specifically for AI agents with structured responses, rich schema information, intelligent error handling, and machine-optimized output formats.
API key, Bearer token, Basic auth, and OAuth2 support for all your authentication needs.
Built-in confirmation workflow for dangerous operations (PUT/POST/DELETE) to prevent accidental changes.
Import as a Go module in your projects for seamless integration with your own applications.
Powerful OpenAPI validation and linting with actionable suggestions. Validate for critical issues or lint for comprehensive best practices analysis.
# Clone the repository
git clone https://github.com/jedisct1/openapi-mcp.git
cd openapi-mcp
# Build the binaries
make
# This will create:
# - bin/openapi-mcp (main tool)
# - bin/mcp-client (interactive client)
# Validate your OpenAPI spec for critical issues
bin/openapi-mcp validate examples/fastly-openapi-mcp.yaml
# Comprehensive linting with best practice suggestions
bin/openapi-mcp lint examples/fastly-openapi-mcp.yaml
# Basic usage (stdio mode)
bin/openapi-mcp examples/fastly-openapi-mcp.yaml
# With API key
API_KEY=your_api_key bin/openapi-mcp examples/fastly-openapi-mcp.yaml
# As HTTP server
bin/openapi-mcp --http=:8080 examples/fastly-openapi-mcp.yaml
# Start the client (connects to openapi-mcp via stdio)
bin/mcp-client bin/openapi-mcp examples/fastly-openapi-mcp.yaml
# Client commands
mcp> list # List available tools
mcp> schema <tool-name> # Show tool schema
mcp> call <tool-name> {arg1: value1} # Call a tool with arguments
mcp> describe # Get full API documentation
# Output only admin-tagged operations as JSON
bin/openapi-mcp filter --tag=admin examples/fastly-openapi-mcp.yaml
# Output operations whose description matches 'foo'
bin/openapi-mcp filter --include-desc-regex=foo examples/fastly-openapi-mcp.yaml
# Combine filters
bin/openapi-mcp filter --tag=admin --include-desc-regex=foo examples/fastly-openapi-mcp.yaml
This will output a JSON array of operations matching the filters, including their name, description, tags, and input schema.
openapi-mcp features unique AI optimizations that set it apart from standard API-to-tool converters:
OutputFormat
and
OutputType
fields for consistent parsingdescribe
tool provides complete, machine-readable documentation for all operationsYou can easily integrate openapi-mcp with AI code editors that support MCP tools, such as Roo Code:
{
"fastly": {
"command": "/opt/bin/openapi-mcp",
"args": [
"-api-key",
"YOUR_API_KEY",
"/opt/etc/openapi/fastly-openapi-mcp.yaml"
]
}
}
Simply add this configuration to your editor's MCP tools configuration to provide AI assistants with direct access to the API.
{
"OutputFormat": "structured",
"OutputType": "json",
"type": "api_response",
"data": {
// API-specific response data
},
"metadata": {
"status_code": 200,
"headers": {
// Response headers
}
}
}
openapi-mcp can be imported as a Go module in your projects, enabling you to integrate MCP server capabilities directly into your applications.
# Main library for OpenAPI to MCP conversion
go get github.com/jedisct1/openapi-mcp/pkg/openapi2mcp
# MCP server package for server functionality
go get github.com/jedisct1/openapi-mcp/pkg/mcp/server
# MCP types package for core MCP utilities
go get github.com/jedisct1/openapi-mcp/pkg/mcp/mcp
package main
import (
"log"
"github.com/jedisct1/openapi-mcp/pkg/openapi2mcp"
)
func main() {
// Load OpenAPI spec
doc, err := openapi2mcp.LoadOpenAPISpec("openapi.yaml")
if err != nil {
log.Fatal(err)
}
// Create MCP server
srv := openapi2mcp.NewServer("myapi", doc.Info.Version, doc)
// Serve over HTTP
if err := openapi2mcp.ServeStreamableHTTP(srv, ":8080", "/mcp"); err != nil {
log.Fatal(err)
}
}
import (
"context"
"github.com/jedisct1/openapi-mcp/pkg/mcp/mcp"
"github.com/jedisct1/openapi-mcp/pkg/mcp/server"
"github.com/jedisct1/openapi-mcp/pkg/openapi2mcp"
)
// Create server and add custom tools
srv := server.NewMCPServer("myapi", "1.0")
ops := openapi2mcp.ExtractOpenAPIOperations(doc)
openapi2mcp.RegisterOpenAPITools(srv, ops, doc, nil)
// Add custom tools using MCP package directly
customTool := mcp.NewTool("custom",
mcp.WithDescription("A custom tool"),
mcp.WithString("message", mcp.Required()))
srv.AddTool(customTool, handlerFunc)
See our comprehensive documentation:
Unlock the power of your OpenAPI specifications with openapi-mcp