Skip to content

Commit d14b276

Browse files
committed
Add _meta to all types
1 parent d258269 commit d14b276

12 files changed

Lines changed: 987 additions & 7 deletions

File tree

docs/protocol/schema.mdx

Lines changed: 156 additions & 0 deletions
Large diffs are not rendered by default.

rust/agent.rs

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ pub struct InitializeRequest {
132132
/// Capabilities supported by the client.
133133
#[serde(default)]
134134
pub client_capabilities: ClientCapabilities,
135+
/// Extension point for implementations
136+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
137+
pub meta: Option<serde_json::Value>,
135138
}
136139

137140
/// Response from the initialize method.
@@ -154,6 +157,9 @@ pub struct InitializeResponse {
154157
/// Authentication methods supported by the agent.
155158
#[serde(default)]
156159
pub auth_methods: Vec<AuthMethod>,
160+
/// Extension point for implementations
161+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
162+
pub meta: Option<serde_json::Value>,
157163
}
158164

159165
// Authentication
@@ -168,6 +174,9 @@ pub struct AuthenticateRequest {
168174
/// The ID of the authentication method to use.
169175
/// Must be one of the methods advertised in the initialize response.
170176
pub method_id: AuthMethodId,
177+
/// Extension point for implementations
178+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
179+
pub meta: Option<serde_json::Value>,
171180
}
172181

173182
/// Unique identifier for an authentication method.
@@ -185,6 +194,9 @@ pub struct AuthMethod {
185194
pub name: String,
186195
/// Optional description providing more details about this authentication method.
187196
pub description: Option<String>,
197+
/// Extension point for implementations
198+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
199+
pub meta: Option<serde_json::Value>,
188200
}
189201

190202
// New session
@@ -200,6 +212,9 @@ pub struct NewSessionRequest {
200212
pub cwd: PathBuf,
201213
/// List of MCP (Model Context Protocol) servers the agent should connect to.
202214
pub mcp_servers: Vec<McpServer>,
215+
/// Extension point for implementations
216+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
217+
pub meta: Option<serde_json::Value>,
203218
}
204219

205220
/// Response from creating a new session.
@@ -218,6 +233,9 @@ pub struct NewSessionResponse {
218233
/// This field is not part of the spec, and may be removed or changed at any point.
219234
#[serde(default, skip_serializing_if = "Option::is_none")]
220235
pub modes: Option<SessionModeState>,
236+
/// Extension point for implementations
237+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
238+
pub meta: Option<serde_json::Value>,
221239
}
222240

223241
// Load session
@@ -237,6 +255,9 @@ pub struct LoadSessionRequest {
237255
pub cwd: PathBuf,
238256
/// The ID of the session to load.
239257
pub session_id: SessionId,
258+
/// Extension point for implementations
259+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
260+
pub meta: Option<serde_json::Value>,
240261
}
241262

242263
/// Response from loading an existing session.
@@ -248,6 +269,9 @@ pub struct LoadSessionResponse {
248269
/// This field is not part of the spec, and may be removed or changed at any point.
249270
#[serde(default, skip_serializing_if = "Option::is_none")]
250271
pub modes: Option<SessionModeState>,
272+
/// Extension point for implementations
273+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
274+
pub meta: Option<serde_json::Value>,
251275
}
252276

253277
// Session modes
@@ -260,6 +284,9 @@ pub struct LoadSessionResponse {
260284
pub struct SessionModeState {
261285
pub current_mode_id: SessionModeId,
262286
pub available_modes: Vec<SessionMode>,
287+
/// Extension point for implementations
288+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
289+
pub meta: Option<serde_json::Value>,
263290
}
264291

265292
/// **UNSTABLE**
@@ -272,6 +299,9 @@ pub struct SessionMode {
272299
pub name: String,
273300
#[serde(default, skip_serializing_if = "Option::is_none")]
274301
pub description: Option<String>,
302+
/// Extension point for implementations
303+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
304+
pub meta: Option<serde_json::Value>,
275305
}
276306

277307
/// **UNSTABLE**
@@ -296,6 +326,9 @@ impl std::fmt::Display for SessionModeId {
296326
pub struct SetSessionModeRequest {
297327
pub session_id: SessionId,
298328
pub mode_id: SessionModeId,
329+
/// Extension point for implementations
330+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
331+
pub meta: Option<serde_json::Value>,
299332
}
300333

301334
/// **UNSTABLE**
@@ -364,6 +397,9 @@ pub struct EnvVariable {
364397
pub name: String,
365398
/// The value to set for the environment variable.
366399
pub value: String,
400+
/// Extension point for implementations
401+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
402+
pub meta: Option<serde_json::Value>,
367403
}
368404

369405
/// An HTTP header to set when making requests to the MCP server.
@@ -374,6 +410,9 @@ pub struct HttpHeader {
374410
pub name: String,
375411
/// The value to set for the HTTP header.
376412
pub value: String,
413+
/// Extension point for implementations
414+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
415+
pub meta: Option<serde_json::Value>,
377416
}
378417

379418
// Prompt
@@ -403,6 +442,9 @@ pub struct PromptRequest {
403442
/// as it avoids extra round-trips and allows the message to include
404443
/// pieces of context from sources the agent may not have access to.
405444
pub prompt: Vec<ContentBlock>,
445+
/// Extension point for implementations
446+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
447+
pub meta: Option<serde_json::Value>,
406448
}
407449

408450
/// Response from processing a user prompt.
@@ -414,6 +456,9 @@ pub struct PromptRequest {
414456
pub struct PromptResponse {
415457
/// Indicates why the agent stopped processing the turn.
416458
pub stop_reason: StopReason,
459+
/// Extension point for implementations
460+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
461+
pub meta: Option<serde_json::Value>,
417462
}
418463

419464
/// Reasons why an agent stops processing a prompt turn.
@@ -462,6 +507,9 @@ pub struct AgentCapabilities {
462507
/// MCP capabilities supported by the agent.
463508
#[serde(default)]
464509
pub mcp_capabilities: McpCapabilities,
510+
/// Extension point for implementations
511+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
512+
pub meta: Option<serde_json::Value>,
465513
}
466514

467515
/// Prompt capabilities supported by the agent in `session/prompt` requests.
@@ -476,7 +524,7 @@ pub struct AgentCapabilities {
476524
/// the agent can process.
477525
///
478526
/// See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities)
479-
#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
527+
#[derive(Default, Debug, Clone, Serialize, Deserialize, JsonSchema)]
480528
#[serde(rename_all = "camelCase")]
481529
pub struct PromptCapabilities {
482530
/// Agent supports [`ContentBlock::Image`].
@@ -491,10 +539,13 @@ pub struct PromptCapabilities {
491539
/// in prompt requests for pieces of context that are referenced in the message.
492540
#[serde(default)]
493541
pub embedded_context: bool,
542+
/// Extension point for implementations
543+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
544+
pub meta: Option<serde_json::Value>,
494545
}
495546

496547
/// MCP capabilities supported by the agent
497-
#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
548+
#[derive(Default, Debug, Clone, Serialize, Deserialize, JsonSchema)]
498549
#[serde(rename_all = "camelCase")]
499550
pub struct McpCapabilities {
500551
/// Agent supports [`McpServer::Http`].
@@ -503,6 +554,9 @@ pub struct McpCapabilities {
503554
/// Agent supports [`McpServer::Sse`].
504555
#[serde(default)]
505556
pub sse: bool,
557+
/// Extension point for implementations
558+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
559+
pub meta: Option<serde_json::Value>,
506560
}
507561

508562
// Method schema
@@ -617,6 +671,9 @@ pub enum ClientNotification {
617671
pub struct CancelNotification {
618672
/// The ID of the session to cancel operations for.
619673
pub session_id: SessionId,
674+
/// Extension point for implementations
675+
#[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
676+
pub meta: Option<serde_json::Value>,
620677
}
621678

622679
#[cfg(test)]
@@ -633,6 +690,7 @@ mod test_serialization {
633690
env: vec![EnvVariable {
634691
name: "API_KEY".to_string(),
635692
value: "secret123".to_string(),
693+
meta: None,
636694
}],
637695
};
638696

@@ -680,10 +738,12 @@ mod test_serialization {
680738
HttpHeader {
681739
name: "Authorization".to_string(),
682740
value: "Bearer token123".to_string(),
741+
meta: None,
683742
},
684743
HttpHeader {
685744
name: "Content-Type".to_string(),
686745
value: "application/json".to_string(),
746+
meta: None,
687747
},
688748
],
689749
};
@@ -731,6 +791,7 @@ mod test_serialization {
731791
headers: vec![HttpHeader {
732792
name: "X-API-Key".to_string(),
733793
value: "apikey456".to_string(),
794+
meta: None,
734795
}],
735796
};
736797

0 commit comments

Comments
 (0)