Skip to main content

objectiveai_sdk/mcp/tool/
call.rs

1//! Types for tools/call requests and responses.
2
3use indexmap::IndexMap;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7/// Metadata for a long-running task.
8#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
9#[schemars(rename = "mcp.tool.TaskMetadata")]
10pub struct TaskMetadata {
11    /// Time-to-live for the task, in seconds.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    #[schemars(extend("omitempty" = true))]
14    pub ttl: Option<f64>,
15}
16
17/// Parameters for a `tools/call` request.
18#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
19#[schemars(rename = "mcp.tool.CallToolRequestParams")]
20pub struct CallToolRequestParams {
21    /// The name of the tool to call.
22    pub name: String,
23    /// Arguments to pass to the tool.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    #[schemars(extend("omitempty" = true))]
26    pub arguments: Option<IndexMap<String, serde_json::Value>>,
27    /// Extension metadata.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    #[schemars(extend("omitempty" = true))]
30    pub _meta: Option<IndexMap<String, serde_json::Value>>,
31    /// If specified, the caller is requesting task-augmented execution.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    #[schemars(extend("omitempty" = true))]
34    pub task: Option<TaskMetadata>,
35}
36
37/// The server's response to a `tools/call` request.
38#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
39#[schemars(rename = "mcp.tool.CallToolResult")]
40pub struct CallToolResult {
41    /// Content blocks representing the result of the tool call.
42    #[serde(default)]
43    pub content: Vec<super::ContentBlock>,
44    /// Structured tool output matching the tool's `outputSchema`.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    #[schemars(extend("omitempty" = true))]
47    #[serde(rename = "structuredContent")]
48    pub structured_content: Option<IndexMap<String, serde_json::Value>>,
49    /// Whether the tool call ended in an error.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    #[schemars(extend("omitempty" = true))]
52    #[serde(rename = "isError")]
53    pub is_error: Option<bool>,
54    /// Extension metadata.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[schemars(extend("omitempty" = true))]
57    pub _meta: Option<IndexMap<String, serde_json::Value>>,
58}