pub struct OpenApiProvider { /* private fields */ }Expand description
OpenAPI to MCP provider.
This provider parses OpenAPI specifications and converts them to MCP tools and resources that can be used with a TurboMCP server.
§Security
The provider includes built-in SSRF protection that blocks requests to:
- Localhost and loopback addresses (127.0.0.0/8, ::1)
- Private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
- Link-local addresses (169.254.0.0/16) including cloud metadata endpoints
- Other reserved ranges
Requests have a default timeout of 30 seconds to prevent slowloris attacks.
Implementations§
Source§impl OpenApiProvider
impl OpenApiProvider
Sourcepub fn from_string(content: &str) -> Result<Self>
pub fn from_string(content: &str) -> Result<Self>
Create a provider from an OpenAPI specification string.
Sourcepub fn with_base_url(self, base_url: &str) -> Result<Self>
pub fn with_base_url(self, base_url: &str) -> Result<Self>
Set the base URL for API calls.
Sourcepub fn with_route_mapping(self, mapping: RouteMapping) -> Self
pub fn with_route_mapping(self, mapping: RouteMapping) -> Self
Set a custom route mapping configuration.
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Set a custom HTTP client.
§Warning
When using a custom client, ensure it has appropriate timeout settings. The default client uses a 30-second timeout.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set a custom request timeout.
This rebuilds the HTTP client with the new timeout. The default timeout is 30 seconds.
Sourcepub fn operations(&self) -> &[ExtractedOperation]
pub fn operations(&self) -> &[ExtractedOperation]
Get all extracted operations.
Sourcepub fn tools(&self) -> impl Iterator<Item = &ExtractedOperation>
pub fn tools(&self) -> impl Iterator<Item = &ExtractedOperation>
Get operations that map to MCP tools.
Sourcepub fn resources(&self) -> impl Iterator<Item = &ExtractedOperation>
pub fn resources(&self) -> impl Iterator<Item = &ExtractedOperation>
Get operations that map to MCP resources.
Sourcepub fn into_handler(self) -> OpenApiHandler
pub fn into_handler(self) -> OpenApiHandler
Convert this provider into an McpHandler.