Skip to content

Commit b9d962c

Browse files
author
xiaoyewang
committed
Update protocol schema to 0.11.0 and add session config option request
1 parent 9569a52 commit b9d962c

File tree

5 files changed

+64
-19
lines changed

5 files changed

+64
-19
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tokio = { version = "1.48", features = ["full"] }
1919
tokio-util = { version = "0.7", features = ["compat"] }
2020

2121
# Protocol
22-
agent-client-protocol-schema = "0.10.5"
22+
agent-client-protocol-schema = "0.11.0"
2323

2424
# Serialization
2525
serde = { version = "1.0", features = ["derive"] }

src/sacp/src/mcp_server/builder.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,19 +511,21 @@ trait ErasedMcpTool<Counterpart: Role>: Send + Sync {
511511
/// Create an `rmcp` tool model from our [`McpTool`] trait.
512512
fn make_tool_model<R: Role, M: McpTool<R>>(tool: &M) -> Tool {
513513
{
514-
rmcp::model::Tool::new(
514+
let mut tool_model = rmcp::model::Tool::new(
515515
tool.name(),
516516
tool.description(),
517517
schema_for_type::<M::Input>(),
518518
)
519+
.with_execution(rmcp::model::ToolExecution::new());
520+
519521
// schema_for_output returns Err for non-object types (strings, integers, etc.)
520-
// since MCP structured output requires JSON objects. We use .ok() to set
521-
// output_schema to None for these tools, signaling unstructured output.
522-
.with_raw_output_schema(schema_for_output::<M::Output>().ok())
523-
.with_annotations(None)
524-
.with_icons(None)
525-
.with_meta(None)
526-
.with_execution(Some(rmcp::model::ToolExecution::new()))
522+
// since MCP structured output requires JSON objects. We only set output_schema
523+
// when we have a valid object schema.
524+
if let Ok(schema) = schema_for_output::<M::Output>() {
525+
tool_model = tool_model.with_raw_output_schema(schema);
526+
}
527+
528+
tool_model
527529
}
528530
}
529531

src/sacp/src/schema/agent_to_client/requests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use serde::Serialize;
22

33
use crate::jsonrpc::{JsonRpcMessage, JsonRpcRequest, JsonRpcResponse};
44
use crate::schema::{
5-
CreateTerminalRequest, CreateTerminalResponse, KillTerminalCommandRequest,
6-
KillTerminalCommandResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest,
5+
CreateTerminalRequest, CreateTerminalResponse, KillTerminalRequest,
6+
KillTerminalResponse, ReadTextFileRequest, ReadTextFileResponse, ReleaseTerminalRequest,
77
ReleaseTerminalResponse, RequestPermissionRequest, RequestPermissionResponse,
88
TerminalOutputRequest, TerminalOutputResponse, WaitForTerminalExitRequest,
99
WaitForTerminalExitResponse, WriteTextFileRequest, WriteTextFileResponse,
@@ -301,12 +301,12 @@ impl JsonRpcResponse for WaitForTerminalExitResponse {
301301
}
302302

303303
// ============================================================================
304-
// KillTerminalCommandRequest
304+
// KillTerminalRequest
305305
// ============================================================================
306306

307307
const METHOD_KILL_TERMINAL: &str = "terminal/kill";
308308

309-
impl JsonRpcMessage for KillTerminalCommandRequest {
309+
impl JsonRpcMessage for KillTerminalRequest {
310310
fn matches_method(method: &str) -> bool {
311311
method == METHOD_KILL_TERMINAL
312312
}
@@ -327,11 +327,11 @@ impl JsonRpcMessage for KillTerminalCommandRequest {
327327
}
328328
}
329329

330-
impl JsonRpcRequest for KillTerminalCommandRequest {
331-
type Response = KillTerminalCommandResponse;
330+
impl JsonRpcRequest for KillTerminalRequest {
331+
type Response = KillTerminalResponse;
332332
}
333333

334-
impl JsonRpcResponse for KillTerminalCommandResponse {
334+
impl JsonRpcResponse for KillTerminalResponse {
335335
fn into_json(self, _method: &str) -> Result<serde_json::Value, crate::Error> {
336336
serde_json::to_value(self).map_err(crate::Error::into_internal_error)
337337
}

src/sacp/src/schema/client_to_agent/requests.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::schema::{
22
AuthenticateRequest, AuthenticateResponse, InitializeRequest, InitializeResponse,
33
LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest,
4-
PromptResponse, SetSessionModeRequest, SetSessionModeResponse,
4+
PromptResponse, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse,
5+
SetSessionModeRequest, SetSessionModeResponse,
56
};
67
use serde::Serialize;
78

@@ -15,6 +16,7 @@ const METHOD_SESSION_LOAD: &str = "session/load";
1516
const METHOD_SESSION_NEW: &str = "session/new";
1617
const METHOD_SESSION_PROMPT: &str = "session/prompt";
1718
const METHOD_SESSION_SET_MODE: &str = "session/set_mode";
19+
const METHOD_SESSION_SET_CONFIG_OPTION: &str = "session/set_config_option";
1820

1921
// ============================================================================
2022
// InitializeRequest
@@ -249,3 +251,42 @@ impl JsonRpcResponse for SetSessionModeResponse {
249251
json_cast(&value)
250252
}
251253
}
254+
255+
// ============================================================================
256+
// SetSessionConfigOptionRequest
257+
// ============================================================================
258+
259+
impl JsonRpcMessage for SetSessionConfigOptionRequest {
260+
fn matches_method(method: &str) -> bool {
261+
method == METHOD_SESSION_SET_CONFIG_OPTION
262+
}
263+
264+
fn method(&self) -> &str {
265+
METHOD_SESSION_SET_CONFIG_OPTION
266+
}
267+
268+
fn to_untyped_message(&self) -> Result<crate::UntypedMessage, crate::Error> {
269+
crate::UntypedMessage::new(self.method(), self)
270+
}
271+
272+
fn parse_message(method: &str, params: &impl Serialize) -> Result<Self, crate::Error> {
273+
if !Self::matches_method(method) {
274+
return Err(crate::Error::method_not_found());
275+
}
276+
json_cast(params)
277+
}
278+
}
279+
280+
impl JsonRpcRequest for SetSessionConfigOptionRequest {
281+
type Response = SetSessionConfigOptionResponse;
282+
}
283+
284+
impl JsonRpcResponse for SetSessionConfigOptionResponse {
285+
fn into_json(self, _method: &str) -> Result<serde_json::Value, crate::Error> {
286+
serde_json::to_value(self).map_err(crate::Error::into_internal_error)
287+
}
288+
289+
fn from_value(_method: &str, value: serde_json::Value) -> Result<Self, crate::Error> {
290+
json_cast(&value)
291+
}
292+
}

src/sacp/src/schema/enum_impls.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl JsonRpcMessage for ClientRequest {
3030
ClientRequest::NewSessionRequest(_) => "session/new",
3131
ClientRequest::LoadSessionRequest(_) => "session/load",
3232
ClientRequest::SetSessionModeRequest(_) => "session/set_mode",
33+
ClientRequest::SetSessionConfigOptionRequest(_) => "session/set_config_option",
3334
ClientRequest::PromptRequest(_) => "session/prompt",
3435
ClientRequest::ExtMethodRequest(ext) => &ext.method,
3536
_ => "_unknown",
@@ -47,6 +48,7 @@ impl JsonRpcMessage for ClientRequest {
4748
"session/new" => json_cast(params).map(ClientRequest::NewSessionRequest),
4849
"session/load" => json_cast(params).map(ClientRequest::LoadSessionRequest),
4950
"session/set_mode" => json_cast(params).map(ClientRequest::SetSessionModeRequest),
51+
"session/set_config_option" => json_cast(params).map(ClientRequest::SetSessionConfigOptionRequest),
5052
"session/prompt" => json_cast(params).map(ClientRequest::PromptRequest),
5153
_ => {
5254
// Check for extension methods (prefixed with underscore)
@@ -128,7 +130,7 @@ impl JsonRpcMessage for AgentRequest {
128130
AgentRequest::TerminalOutputRequest(_) => "terminal/output",
129131
AgentRequest::ReleaseTerminalRequest(_) => "terminal/release",
130132
AgentRequest::WaitForTerminalExitRequest(_) => "terminal/wait_for_exit",
131-
AgentRequest::KillTerminalCommandRequest(_) => "terminal/kill",
133+
AgentRequest::KillTerminalRequest(_) => "terminal/kill",
132134
AgentRequest::ExtMethodRequest(ext) => &ext.method,
133135
_ => "_unknown",
134136
}
@@ -151,7 +153,7 @@ impl JsonRpcMessage for AgentRequest {
151153
"terminal/wait_for_exit" => {
152154
json_cast(params).map(AgentRequest::WaitForTerminalExitRequest)
153155
}
154-
"terminal/kill" => json_cast(params).map(AgentRequest::KillTerminalCommandRequest),
156+
"terminal/kill" => json_cast(params).map(AgentRequest::KillTerminalRequest),
155157
_ => {
156158
// Check for extension methods (prefixed with underscore)
157159
if let Some(custom_method) = method.strip_prefix('_') {

0 commit comments

Comments
 (0)