objectiveai_sdk/client_objectiveai_mcp/server_request/payload.rs
1use indexmap::IndexMap;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// Tagged union of every JSON-RPC request the API forwards to the
6/// client over the reverse-attach WS. Variant names follow the same
7/// snake_case convention `client_request::Payload` uses; the
8/// `serde(tag = "type")` discriminator pairs with
9/// [`super::super::server_response::Payload`] by name.
10///
11/// Which CLI-hosted MCP server the request targets rides on the
12/// enclosing [`super::Request`] envelope's `mcp_kind` field, not
13/// inside the variant — every variant maps 1:1 to a JSON-RPC method
14/// regardless of which MCP is on the receiving end.
15#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
16#[schemars(rename = "client_objectiveai_mcp.server_request.Payload")]
17#[serde(tag = "type", rename_all = "snake_case")]
18pub enum Payload {
19 /// POST `initialize`. The proxy's `protocolVersion` doesn't ride
20 /// across this hop — the API discards it on the way in and
21 /// substitutes its own `canonical_initialize_result` on the way
22 /// out. The variant carries the plugin arguments the CLI needs at
23 /// dial time (parsed by the API off the URL query string).
24 #[schemars(title = "Initialize")]
25 Initialize(InitializeRequest),
26
27 /// POST `tools/list`.
28 #[schemars(title = "ToolsList")]
29 ToolsList(crate::mcp::tool::ListToolsRequest),
30
31 /// POST `tools/call`.
32 #[schemars(title = "ToolsCall")]
33 ToolsCall(crate::mcp::tool::CallToolRequestParams),
34
35 /// POST `resources/list`.
36 #[schemars(title = "ResourcesList")]
37 ResourcesList(crate::mcp::resource::ListResourcesRequest),
38
39 /// POST `resources/read`.
40 #[schemars(title = "ResourcesRead")]
41 ResourcesRead(crate::mcp::resource::ReadResourceRequestParams),
42
43 /// `DELETE` on the routed MCP URL — the proxy closing the
44 /// session. No body.
45 #[schemars(title = "SessionTerminate")]
46 SessionTerminate,
47}
48
49/// Parameters for [`Payload::Initialize`].
50///
51/// Carries plugin arguments lifted off the inbound URL's query
52/// string (`?key=value&flag` → `{"key": Some("value"), "flag": None}`).
53/// Empty for [`super::super::McpKind::ObjectiveAi`] (the primary
54/// upstream takes no args).
55#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
56#[schemars(rename = "client_objectiveai_mcp.server_request.InitializeRequest")]
57pub struct InitializeRequest {
58 /// Plugin arguments the CLI passes through to
59 /// `<plugin> mcp <mcp_name> begin --<key> [value]`. `None` value
60 /// means presence-only flag (`--key`); `Some(v)` means `--key v`.
61 #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
62 #[schemars(extend("omitempty" = true))]
63 pub args: IndexMap<String, Option<String>>,
64}