turbomcp_openapi/lib.rs
1//! # TurboMCP OpenAPI Provider
2//!
3//! Convert OpenAPI specifications to MCP tools and resources at runtime.
4//!
5//! This crate enables automatic exposure of REST APIs as MCP components:
6//! - GET endpoints become MCP resources
7//! - POST/PUT/DELETE endpoints become MCP tools
8//! - Configurable route mapping patterns
9//!
10//! # Example
11//!
12//! ```rust,ignore
13//! use turbomcp_openapi::{OpenApiProvider, RouteMapping, McpType};
14//!
15//! // Load from URL
16//! let provider = OpenApiProvider::from_url("https://api.example.com/openapi.json")
17//! .await?
18//! .with_base_url("https://api.example.com")
19//! .with_route_mapping(RouteMapping::new()
20//! .map_method("GET", McpType::Resource)
21//! .map_method("POST", McpType::Tool)
22//! .map_pattern(r"/admin/.*", McpType::Tool));
23//!
24//! // Use with TurboMCP server
25//! let handler = provider.into_handler();
26//! ```
27
28#![deny(missing_docs)]
29#![warn(missing_debug_implementations)]
30#![warn(clippy::all)]
31#![allow(clippy::module_name_repetitions)]
32
33mod error;
34mod handler;
35mod mapping;
36mod parser;
37mod provider;
38mod security;
39
40pub use error::{OpenApiError, Result};
41pub use handler::OpenApiHandler;
42pub use mapping::{McpType, RouteMapping, RouteRule};
43pub use parser::parse_spec;
44pub use provider::{ExtractedOperation, ExtractedParameter, OpenApiProvider};
45
46/// Prelude for common imports.
47pub mod prelude {
48 pub use super::{McpType, OpenApiHandler, OpenApiProvider, RouteMapping, RouteRule};
49}