Skip to content

Commit b4acadf

Browse files
JAORMXclaude
andauthored
Add notifications/elicitation/complete to MCP parser (#4157)
The MCP 2025-11-25 spec defines notifications/elicitation/complete as a server-to-client notification sent when an out-of-band URL-mode elicitation completes. This was the only spec method not yet handled by the parser. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0de510d commit b4acadf

2 files changed

Lines changed: 62 additions & 24 deletions

File tree

pkg/mcp/parser.go

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -184,30 +184,31 @@ type methodHandler func(map[string]interface{}) (string, map[string]interface{})
184184

185185
// methodHandlers maps MCP methods to their respective handlers
186186
var methodHandlers = map[string]methodHandler{
187-
"initialize": handleInitializeMethod,
188-
"tools/call": handleNamedResourceMethod,
189-
"prompts/get": handleNamedResourceMethod,
190-
"resources/read": handleResourceReadMethod,
191-
"resources/list": handleListMethod,
192-
"tools/list": handleListMethod,
193-
"prompts/list": handleListMethod,
194-
"progress/update": handleProgressMethod,
195-
"notifications/message": handleNotificationMethod,
196-
"logging/setLevel": handleLoggingMethod,
197-
"completion/complete": handleCompletionMethod,
198-
"elicitation/create": handleElicitationMethod,
199-
"sampling/createMessage": handleSamplingMethod,
200-
"resources/subscribe": handleResourceSubscribeMethod,
201-
"resources/unsubscribe": handleResourceUnsubscribeMethod,
202-
"resources/templates/list": handleListMethod,
203-
"roots/list": handleListMethod,
204-
"notifications/progress": handleProgressNotificationMethod,
205-
"notifications/cancelled": handleCancelledNotificationMethod,
206-
"tasks/list": handleListMethod,
207-
"tasks/get": handleTaskIDMethod,
208-
"tasks/cancel": handleTaskIDMethod,
209-
"tasks/result": handleTaskIDMethod,
210-
"notifications/tasks/status": handleTaskStatusNotificationMethod,
187+
"initialize": handleInitializeMethod,
188+
"tools/call": handleNamedResourceMethod,
189+
"prompts/get": handleNamedResourceMethod,
190+
"resources/read": handleResourceReadMethod,
191+
"resources/list": handleListMethod,
192+
"tools/list": handleListMethod,
193+
"prompts/list": handleListMethod,
194+
"progress/update": handleProgressMethod,
195+
"notifications/message": handleNotificationMethod,
196+
"logging/setLevel": handleLoggingMethod,
197+
"completion/complete": handleCompletionMethod,
198+
"elicitation/create": handleElicitationMethod,
199+
"sampling/createMessage": handleSamplingMethod,
200+
"resources/subscribe": handleResourceSubscribeMethod,
201+
"resources/unsubscribe": handleResourceUnsubscribeMethod,
202+
"resources/templates/list": handleListMethod,
203+
"roots/list": handleListMethod,
204+
"notifications/progress": handleProgressNotificationMethod,
205+
"notifications/cancelled": handleCancelledNotificationMethod,
206+
"tasks/list": handleListMethod,
207+
"tasks/get": handleTaskIDMethod,
208+
"tasks/cancel": handleTaskIDMethod,
209+
"tasks/result": handleTaskIDMethod,
210+
"notifications/tasks/status": handleTaskStatusNotificationMethod,
211+
"notifications/elicitation/complete": handleElicitationCompleteNotificationMethod,
211212
}
212213

213214
// staticResourceIDs maps methods to their static resource IDs
@@ -359,6 +360,16 @@ func handleElicitationMethod(paramsMap map[string]interface{}) (string, map[stri
359360
return "", paramsMap
360361
}
361362

363+
// handleElicitationCompleteNotificationMethod extracts resource ID for elicitation complete notifications.
364+
// This notification is sent by the server when an out-of-band URL-mode elicitation is completed.
365+
// Returns the elicitationId as the resource identifier.
366+
func handleElicitationCompleteNotificationMethod(paramsMap map[string]interface{}) (string, map[string]interface{}) {
367+
if elicitationId, ok := paramsMap["elicitationId"].(string); ok {
368+
return elicitationId, paramsMap
369+
}
370+
return "", paramsMap
371+
}
372+
362373
// handleSamplingMethod extracts resource ID for sampling/createMessage requests.
363374
// Returns the model name from modelPreferences if available, otherwise returns a
364375
// truncated version of the systemPrompt. The 50-character truncation provides a

pkg/mcp/parser_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ func TestParsingMiddleware(t *testing.T) {
174174
expectedID: int64(6),
175175
expectedResID: "debug",
176176
},
177+
{
178+
name: "notifications/elicitation/complete notification",
179+
method: "POST",
180+
path: "/messages",
181+
contentType: "application/json",
182+
body: `{"jsonrpc":"2.0","method":"notifications/elicitation/complete","params":{"elicitationId":"550e8400-e29b-41d4-a716-446655440000"}}`,
183+
expectParsed: true,
184+
expectedMethod: "notifications/elicitation/complete",
185+
expectedID: nil,
186+
expectedResID: "550e8400-e29b-41d4-a716-446655440000",
187+
},
177188
}
178189

179190
for _, tt := range tests {
@@ -770,6 +781,22 @@ func TestExtractResourceAndArguments(t *testing.T) {
770781
expectedResourceID: "page-2",
771782
expectedArguments: nil,
772783
},
784+
{
785+
name: "notifications/elicitation/complete with elicitationId",
786+
method: "notifications/elicitation/complete",
787+
params: `{"elicitationId":"550e8400-e29b-41d4-a716-446655440000"}`,
788+
expectedResourceID: "550e8400-e29b-41d4-a716-446655440000",
789+
expectedArguments: map[string]interface{}{
790+
"elicitationId": "550e8400-e29b-41d4-a716-446655440000",
791+
},
792+
},
793+
{
794+
name: "notifications/elicitation/complete with missing elicitationId",
795+
method: "notifications/elicitation/complete",
796+
params: `{}`,
797+
expectedResourceID: "",
798+
expectedArguments: map[string]interface{}{},
799+
},
773800
}
774801

775802
for _, tt := range tests {

0 commit comments

Comments
 (0)