feat!: align metadata models with draft schema (#993)

This commit is contained in:
Dale Seo 2026-07-15 08:58:46 -04:00 • committed by GitHub
commit 839922d8fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -61,6 +61,60 @@ mod tests {
);
}
/// The three metadata definitions must expose the MCP 2026-07-28 draft
/// vocabulary: `MetaObject` is an open map, `RequestMetaObject` reserves
/// `progressToken` plus the SEP-2575 keys, and `NotificationMetaObject`
/// reserves `io.modelcontextprotocol/subscriptionId`. The keys the draft
/// marks as required stay optional because rmcp generates one schema
/// shared by every supported protocol version; draft-strict validation is
/// a runtime concern (`RequestMetaObject::missing_required_keys`).
#[test]
fn test_metadata_definitions_match_draft_schema() {
let settings = SchemaSettings::draft07();
let schema = settings
.into_generator()
.into_root_schema_for::<ClientJsonRpcMessage>();
let schema = serde_json::to_value(&schema).expect("Failed to serialize schema");
let definitions = &schema["definitions"];
assert_eq!(
definitions["MetaObject"],
serde_json::json!({
"description": "See [specification/draft/basic/index#general-fields] for notes on _meta usage.",
"type": "object",
"additionalProperties": true,
})
);
assert_eq!(
definitions["RequestMetaObject"],
serde_json::json!({
"description": "Metadata reserved by MCP on requests. Extension keys are also allowed.",
"type": "object",
"properties": {
"progressToken": { "$ref": "#/definitions/ProgressToken" },
"io.modelcontextprotocol/protocolVersion": { "type": "string" },
"io.modelcontextprotocol/clientInfo": { "$ref": "#/definitions/Implementation" },
"io.modelcontextprotocol/clientCapabilities": { "$ref": "#/definitions/ClientCapabilities" },
"io.modelcontextprotocol/logLevel": { "$ref": "#/definitions/LoggingLevel" },
},
"additionalProperties": true,
})
);
assert_eq!(
definitions["NotificationMetaObject"],
serde_json::json!({
"description": "Metadata reserved by MCP on notifications. Extension keys are also allowed.",
"type": "object",
"properties": {
"io.modelcontextprotocol/subscriptionId": { "$ref": "#/definitions/NumberOrString" },
},
"additionalProperties": true,
})
);
}
#[test]
fn test_server_json_rpc_message_schema() {
let settings = SchemaSettings::draft07();