Skip to main content

objectiveai_sdk/client_objectiveai_mcp/server_request/
request.rs

1use indexmap::IndexMap;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// One reverse-attach request the API has shipped to the calling
6/// client. The proxy's HTTP method (`POST` for the five JSON-RPC
7/// methods, `DELETE` for session terminate) is implicit in the
8/// [`super::Payload`] variant; the JSON-RPC `{jsonrpc, id, method,
9/// params}` envelope is unwrapped into the typed variant payload.
10///
11/// Which CLI-hosted MCP server the request targets rides as
12/// `mcp_kind` on the envelope. The API parses this off the inbound
13/// URL path (`/objectiveai` → [`super::super::McpKind::ObjectiveAi`];
14/// `/{owner}/{name}/{version}/{mcp}` → [`super::super::McpKind::Other`])
15/// before forwarding.
16///
17/// Wire shape (envelope is `{id, mcp_kind, headers?, type, …variant
18/// fields…}` after the `#[serde(flatten)]` on `payload`):
19///
20/// ```json
21/// {
22///   "id":"…",
23///   "mcp_kind":{"type":"objective_ai"},
24///   "headers":{"Mcp-Session-Id":"…"},
25///   "type":"tools_list",
26///   "cursor":"…"
27/// }
28/// ```
29#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
30#[schemars(rename = "client_objectiveai_mcp.server_request.Request")]
31pub struct Request {
32    /// Server-minted correlation id. Echoed by the matching
33    /// [`super::super::server_response::Response`].
34    pub id: String,
35    /// Which CLI-hosted MCP server this request targets.
36    pub mcp_kind: super::super::McpKind,
37    /// Verbatim copy of the headers the proxy sent on its HTTP
38    /// request to the API. The CLI conduit reads several custom
39    /// `X-OBJECTIVEAI-*` routing headers + `Mcp-Session-Id` off this
40    /// map; protocol-level headers (Host, Content-Length, …) the API
41    /// already stripped on its way in.
42    #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
43    #[schemars(extend("omitempty" = true))]
44    pub headers: IndexMap<String, String>,
45    /// The typed request variant.
46    #[serde(flatten)]
47    pub payload: super::Payload,
48}