objectiveai_sdk/client_objectiveai_mcp/server_response/response.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// One reply the calling client's `McpHandler` produced for a
5/// [`super::super::server_request::Request`]. The typed
6/// [`super::Payload`] variant pairs by name with the request side;
7/// every method-specific result or error rides inside it. `mcp_kind`
8/// echoes the request's so the API can sanity-check the routing
9/// without trusting `id` alone.
10///
11/// Wire shape (envelope is `{id, mcp_kind, type, …variant fields…}`
12/// after the `#[serde(flatten)]` on `payload`):
13///
14/// ```json
15/// {
16/// "id":"…",
17/// "mcp_kind":{"type":"objective_ai"},
18/// "type":"tools_list",
19/// "kind":"ok",
20/// "result":{…}
21/// }
22/// ```
23#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
24#[schemars(rename = "client_objectiveai_mcp.server_response.Response")]
25pub struct Response {
26 /// Matches the `id` of the
27 /// [`super::super::server_request::Request`] this response is for.
28 pub id: String,
29 /// The typed response variant. The MCP-routed variants echo
30 /// `mcp_kind` inside the variant itself (see [`super::Payload`]);
31 /// non-MCP variants don't.
32 #[serde(flatten)]
33 pub payload: super::Payload,
34}
35
36impl Response {
37 /// Which CLI-hosted MCP server this response came from. `Some` for
38 /// the MCP-routed variants; `None` for non-MCP variants. Delegates
39 /// to [`super::Payload::mcp_kind`].
40 pub fn mcp_kind(&self) -> Option<super::super::McpKind> {
41 self.payload.mcp_kind()
42 }
43}