Commit a77203f
committed
feat(task): route server-originated tasks/* to ClientHandler (SEP-1686)
Tasks are bidirectional per SEP-1686: either party can be the requestor
or the receiver. The ServerHandler side is already wired for client→server
task flow (tools/call augmentation). This patch mirrors the same wiring
on the client side so servers that initiate task-augmented requests
(notably sampling/createMessage and elicitation/create) can follow up
with tasks/get, tasks/list, tasks/result, and tasks/cancel directed at
the client.
Changes, purely additive:
* ServerRequest: add GetTaskInfoRequest | ListTasksRequest |
GetTaskResultRequest | CancelTaskRequest variants. Add a
ServerRequest::method() accessor mirroring ClientRequest::method().
Update the variant_extension! invocation so the existing
GetExtensions / GetMeta impls cover the new variants.
* ClientResult: add ListTasksResult | GetTaskResult |
GetTaskPayloadResult | CancelTaskResult response variants.
GetTaskPayloadResult retains its existing custom Deserialize-fails
behavior, so payload responses are still observed on the wire as
CustomResult (matching the server-side pattern).
* ClientHandler: add list_tasks, get_task_info, get_task_result,
and cancel_task methods with default -32601 Method-not-found impls,
mirroring the server-side signatures. Propagate via the Box/Arc
wrapper macro. Dispatch all four from the handle_request match.
This unblocks clients that want to advertise
capabilities.tasks.requests.sampling.createMessage,
capabilities.tasks.requests.elicitation.create, or the client-side
tasks.list / tasks.cancel capabilities: previously, servers had no
way to reach the client's task methods through the typed request enum,
and such capabilities couldn't be honored end-to-end.
Tests: new test_task_client_receiver.rs exercises a full bidirectional
roundtrip for each of the four methods (server → client RPC →
ClientHandler → response → server), plus a default-impl test that
confirms the unit () client returns -32601 for tasks/get. Existing
message-schema golden files regenerated to include the new ServerRequest
and ClientResult variants; no other tests affected.
Related: #528, #536 (which added the server-side half of SEP-1686).1 parent 020a38b commit a77203f
9 files changed
Lines changed: 1346 additions & 0 deletions
File tree
- crates/rmcp
- src
- handler
- model
- tests
- test_message_schema
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
286 | 291 | | |
287 | 292 | | |
288 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
33 | 49 | | |
34 | 50 | | |
35 | 51 | | |
| |||
191 | 207 | | |
192 | 208 | | |
193 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
194 | 272 | | |
195 | 273 | | |
196 | 274 | | |
| |||
310 | 388 | | |
311 | 389 | | |
312 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
313 | 423 | | |
314 | 424 | | |
315 | 425 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3323 | 3323 | | |
3324 | 3324 | | |
3325 | 3325 | | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
3326 | 3330 | | |
3327 | 3331 | | |
3328 | 3332 | | |
| |||
3341 | 3345 | | |
3342 | 3346 | | |
3343 | 3347 | | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
3344 | 3352 | | |
3345 | 3353 | | |
3346 | 3354 | | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
3347 | 3371 | | |
3348 | 3372 | | |
3349 | 3373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
169 | 173 | | |
170 | 174 | | |
171 | 175 | | |
| |||
0 commit comments