pub struct Server {Show 13 fields
pub openapi_spec: Value,
pub tool_collection: ToolCollection,
pub base_url: Url,
pub default_headers: Option<HeaderMap>,
pub filters: Option<Filters>,
pub authorization_mode: AuthorizationMode,
pub name: Option<String>,
pub version: Option<String>,
pub title: Option<String>,
pub instructions: Option<String>,
pub skip_tool_descriptions: bool,
pub skip_parameter_descriptions: bool,
pub response_transformer: Option<Arc<dyn ResponseTransformer>>,
}Fields§
§openapi_spec: Value§tool_collection: ToolCollection§base_url: Url§default_headers: Option<HeaderMap>§filters: Option<Filters>§name: Option<String>§version: Option<String>§title: Option<String>§instructions: Option<String>§skip_tool_descriptions: bool§skip_parameter_descriptions: bool§response_transformer: Option<Arc<dyn ResponseTransformer>>Global response transformer applied to all tools.
Uses dynamic dispatch (Arc<dyn>) because:
- Transformer runs once per HTTP call (10-1000ms latency)
- Vtable lookup overhead (~1ns) is unmeasurable
- Avoids viral generics throughout Server, Tool, ToolCollection
Implementations§
Source§impl Server
impl Server
Sourcepub fn builder() -> ServerBuilder
pub fn builder() -> ServerBuilder
Create an instance of Server using the builder syntax
Source§impl Server
impl Server
Sourcepub fn new(
openapi_spec: Value,
base_url: Url,
default_headers: Option<HeaderMap>,
filters: Option<Filters>,
skip_tool_descriptions: bool,
skip_parameter_descriptions: bool,
) -> Self
pub fn new( openapi_spec: Value, base_url: Url, default_headers: Option<HeaderMap>, filters: Option<Filters>, skip_tool_descriptions: bool, skip_parameter_descriptions: bool, ) -> Self
Create a new Server instance with required parameters
Sourcepub fn load_openapi_spec(&mut self) -> Result<(), Error>
pub fn load_openapi_spec(&mut self) -> Result<(), Error>
Parse the OpenAPI specification and convert to OpenApiTool instances
§Errors
Returns an error if the spec cannot be parsed or tools cannot be generated
Sourcepub fn set_tool_transformer(
&mut self,
tool_name: &str,
transformer: Arc<dyn ResponseTransformer>,
) -> Result<(), Error>
pub fn set_tool_transformer( &mut self, tool_name: &str, transformer: Arc<dyn ResponseTransformer>, ) -> Result<(), Error>
Set a response transformer for a specific tool, overriding the global one.
The transformer’s transform_schema method is immediately applied to the tool’s
output schema. The transform_response method will be applied to responses
when the tool is called.
§Errors
Returns an error if the tool is not found
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Get the number of loaded tools
Sourcepub fn get_tool_names(&self) -> Vec<String>
pub fn get_tool_names(&self) -> Vec<String>
Get all tool names
Sourcepub fn get_tool_metadata(&self, name: &str) -> Option<&ToolMetadata>
pub fn get_tool_metadata(&self, name: &str) -> Option<&ToolMetadata>
Get tool metadata by name
Set the authorization mode for the server
Get the current authorization mode
Sourcepub fn get_tool_stats(&self) -> String
pub fn get_tool_stats(&self) -> String
Get basic tool statistics