Expand description
§TurboMCP OpenAPI Provider
Convert OpenAPI specifications to MCP tools and resources at runtime.
This crate enables automatic exposure of REST APIs as MCP components:
- GET endpoints become MCP resources
- POST/PUT/DELETE endpoints become MCP tools
- Configurable route mapping patterns
§Example
ⓘ
use turbomcp_openapi::{OpenApiProvider, RouteMapping, McpType};
// Load from URL
let provider = OpenApiProvider::from_url("https://api.example.com/openapi.json")
.await?
.with_base_url("https://api.example.com")
.with_route_mapping(RouteMapping::new()
.map_method("GET", McpType::Resource)
.map_method("POST", McpType::Tool)
.map_pattern(r"/admin/.*", McpType::Tool));
// Use with TurboMCP server
let handler = provider.into_handler();Modules§
- prelude
- Prelude for common imports.
Structs§
- Extracted
Operation - An operation extracted from an OpenAPI spec.
- Extracted
Parameter - A parameter extracted from an OpenAPI operation.
- Open
ApiHandler - MCP handler that exposes OpenAPI operations as tools and resources.
- Open
ApiProvider - OpenAPI to MCP provider.
- Route
Mapping - Configuration for mapping OpenAPI operations to MCP components.
- Route
Rule - A single route mapping rule.
Enums§
- McpType
- MCP component type that an OpenAPI operation maps to.
- Open
ApiError - Errors that can occur during OpenAPI operations.
Functions§
- parse_
spec - Parse an OpenAPI specification from a string.
Type Aliases§
- Result
- Result type for OpenAPI operations.