Skip to main content

ferro_api_mcp/
types.rs

1/// Location of an API parameter in the HTTP request.
2#[derive(Debug, Clone, PartialEq)]
3pub enum ParamLocation {
4    Path,
5    Query,
6    Header,
7}
8
9/// A single parameter for an API operation.
10#[derive(Debug, Clone, PartialEq)]
11pub struct ApiParam {
12    pub name: String,
13    pub location: ParamLocation,
14    pub required: bool,
15    pub schema: serde_json::Value,
16    pub description: Option<String>,
17}
18
19/// A parsed API operation ready for MCP tool generation.
20///
21/// Each operation maps to one MCP tool. The `input_schema` field holds
22/// the merged JSON Schema for the tool's input, built by the schema module
23/// from parameters and request body.
24#[derive(Debug, Clone, PartialEq)]
25pub struct ApiOperation {
26    pub tool_name: String,
27    pub method: String,
28    pub path: String,
29    pub description: String,
30    pub parameters: Vec<ApiParam>,
31    pub request_body_schema: Option<serde_json::Value>,
32    pub input_schema: serde_json::Value,
33    pub hint: Option<String>,
34}
35
36impl ApiOperation {
37    /// Creates a new `ApiOperation` with an empty input schema.
38    ///
39    /// The `input_schema` defaults to `{"type": "object", "properties": {}}`
40    /// and will be populated by the schema module during spec parsing.
41    pub fn new(tool_name: String, method: String, path: String, description: String) -> Self {
42        Self {
43            tool_name,
44            method,
45            path,
46            description,
47            parameters: Vec::new(),
48            request_body_schema: None,
49            input_schema: serde_json::json!({"type": "object", "properties": {}}),
50            hint: None,
51        }
52    }
53}