Migrating to 1.x #716
alexhancock
announced in
Announcements
Replies: 1 comment
-
|
@alexhancock Updated the migration guide to reflect the last-minute API changes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Upgrading to RMCP 1.x — Migration Guide
TL;DR
Foo { field_a, field_b, .. }Foo::new(required_fields).with_optional(val)#[non_exhaustive]on structs..Default::default()::new()+.with_*()builders#[non_exhaustive]on enums/errorsmatch_ => {}catch-all armCreateMessageResult::with_stop_reasonwith_stop_reason(Option<String>)with_stop_reason(impl Into<String>)LoggingMessageNotificationParam::with_loggerwith_logger(level, logger, data).with_logger(logger)chained after::new()CreateElicitationResult::with_contentwith_content(action, val).with_content(val)chained after::new()CallToolRequestParams::with_taskwith_task(Option<JsonObject>)with_task(JsonObject)1.
ServerInfo/InitializeResultBefore:
After:
Other builders:
.with_server_info(impl),.with_protocol_version(ver).2.
CallToolRequestParamsBefore:
After:
3.
GetPromptRequestParamsBefore:
After:
4.
GetPromptResultBefore:
After:
5.
InitializeRequestParams/ClientInfoBefore:
After:
6.
ImplementationBefore:
After:
7.
CreateMessageResultBefore:
After:
8.
CreateMessageRequestParamsBefore:
After:
9.
Tool(manual construction)Before:
After:
Optional chaining:
.with_title(t),.with_annotations(a),.with_execution(e),.with_icons(i),.with_meta(m),.with_raw_output_schema(s).10.
ToolAnnotationsBefore:
After:
Or use the existing static builder — note
with_titleis a static function, not an instance method:11.
TaskBefore:
After:
12. Other Structs with New Constructors
ReadResourceRequestParams::new(uri)ReadResourceResult::new(contents)SubscribeRequestParams::new(uri)SetLevelRequestParams::new(level)ProgressNotificationParam::new(token, progress)CompleteRequestParams::new(ref, argument).with_context(ctx)CompleteResult::new(completion)Icon::new(src).with_mime_type(m).with_sizes(s)Prompt::new(name, Some(desc), args).with_title(t)or::from_raw(name, Some(desc), args)PromptArgument::new(name).with_description(d).with_required(b)PromptMessage::new(role, content)ModelPreferences::new().with_hints(h).with_cost_priority(f)ModelHint::new(name)CreateElicitationResult::new(action).with_content(val)ListTasksResult::new(tasks)— see warning belowCreateTaskResult::new(task)GetTaskPayloadResult::new(value)JsonRpcRequest::new(id, request)JsonRpcError::new(id, error)RequestContext::new(id, peer)RawEmbeddedResource::new(resource)ConstTitle::new(const_, title)TitledSingleSelectEnumSchema::new(one_of)TitledMultiSelectEnumSchema::new(items).with_min_items(n)...TitledItems::new(any_of)ResourceUpdatedNotificationParam::new(uri)LoggingMessageNotificationParam::new(level, data).with_logger(logger)ElicitationResponseNotificationParam::new(elicitation_id)13.
#[non_exhaustive]Enums & ErrorsSeveral error enums and a few other enums are now
#[non_exhaustive]:RmcpErrorClientInitializeErrorServerInitializeErrorElicitationErrorAuthErrorStreamableHttpErrorStreamableHttpProtocolErrorStreamableHttpPostResponseWorkerQuitReasonSessionQuitReasonLocalSessionWorkerErrorQuitReasonElicitationAction(add_ => {}in match arms)Fix: Add a wildcard arm to any
matchon these types:14. Notification Construction
Notifications now have a
::new(params)constructor instead of struct literals:Before:
After:
Same pattern applies to
CreateElicitationRequest::new(params).15.
ClientCapabilitiesBuilderElicitation capabilities now go through the builder:
Before:
After:
Quick Migration Checklist
::new()+.with_*()..Default::default()on affected types → replace with buildermatchon any newly#[non_exhaustive]enum → add_ => {}armToolAnnotations::with_titlecall sites → it's a static function, notnew().with_title(...)Prompt::newcall sites → it takes 3 args:new(name, description, arguments)ListTasksResultusage →::new(tasks)cannot setnext_cursorortotal(no builders exist yet)cargo buildand follow remaining compiler errors — the compiler is your friend hereGenerated 2026-03-02. Based on rust-sdk PR #715.
Updated 2026-03-03. Based on rust-sdk PR #720.
Beta Was this translation helpful? Give feedback.
All reactions