Skip to content

Conversation

krtkvrm
Copy link
Contributor

@krtkvrm krtkvrm commented Jul 29, 2025

fixes: #13

Implements elicitation functionality from MCP 2025-06-18 specification.

Changes

  • Add ElicitParams and ElicitResult protocol types
  • Add ServerSession.Elicit() method and ClientOptions.ElicitationHandler
  • Schema validation enforces top-level properties only
  • Support for accept/decline/cancel actions with progress tokens

Tests

  • Integration test in TestEndToEnd
  • Schema validation, error handling, and capability declaration tests

@krtkvrm krtkvrm changed the title Feat/issue 13 elicitation support feat/issue 13 elicitation support Jul 29, 2025
@krtkvrm krtkvrm mentioned this pull request Jul 29, 2025
@krtkvrm krtkvrm changed the title feat/issue 13 elicitation support feat/Issue-13: elicitation support Jul 29, 2025
@jba
Copy link
Contributor

jba commented Jul 29, 2025

The PR comment is too wordy. See other PR comments by jba, findleyr and samthanawalla to get the style.

The example is useful but it should be an actual example. See the files named *example*.go in the mcp directory.

Copy link
Contributor

@jba jba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test to mcp_test.go.

@krtkvrm krtkvrm force-pushed the feat/issue-13-elicitation-support branch from 7ce6c7d to 498871c Compare July 31, 2025 14:49
mcp/client.go Outdated
// TODO: wrap or annotate this error? Pick a standard code?
return nil, &jsonrpc2.WireError{Code: CodeUnsupportedMethod, Message: "client does not support elicitation"}
}
return c.opts.ElicitationHandler(ctx, cs, params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good place to check the restriction on the schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, please check if its as expected

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@samthanawalla samthanawalla Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jba Correct me if I'm wrong but I believe we can also check that the ElicitResult.Content matches the Params.RequestSchema before returning.

It would look like this:

r, err := params.RequestedSchema.Resolve(nil)

res, err := c.opts.ElicitationHandler(ctx, cs, params)
err := r.Validate(res.Content)
if err != nil {
panic(elicitationhandler violated the requestedschema)
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems about right. Instead of panicking can the RPC return an error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would pass the error to the server instead of the client but I think it should be a client side error since it originated from the ElicitationHandler. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to surface the error on the client.
I think this is what we do with other handlers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@samthanawalla
Copy link
Contributor

@krtkvrm It would be great to get this in soon if you are able to resolve all the comments, thanks in advance!

@krtkvrm krtkvrm force-pushed the feat/issue-13-elicitation-support branch from ed7c7f2 to 824e0ce Compare August 10, 2025 16:14
@krtkvrm krtkvrm requested review from samthanawalla and jba August 11, 2025 10:01
}

// validateElicitSchema validates that the schema only contains top-level properties without nesting.
func validateElicitSchema(schema *jsonschema.Schema) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I just read the spec and there is more to check. Let's check it all.
https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#supported-schema-types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return &mcp.ElicitResult{
Action: "accept",
Content: map[string]any{
"apiKey": "sk-test123",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't want to use this field as an example since it is prohibited in the spec:

https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#user-interaction-model

Screenshot 2025-08-19 at 9 11 46 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jba
Copy link
Contributor

jba commented Aug 20, 2025

@krtkvrm can you wrap this up by tomorrow, Thursday Aug 20? We would like it to land before our next release, which will probably be Friday.

@samthanawalla
Copy link
Contributor

samthanawalla commented Aug 21, 2025

@krtkvrm Will you be able to complete it today? We want to release this feature soon so I will take it over unless you say otherwise. (And give you credit) Thank you!

@krtkvrm
Copy link
Contributor Author

krtkvrm commented Aug 21, 2025

I'll be pushing changes in next few hours, sorry for delays, I am currently travelling

@findleyr
Copy link
Contributor

Thanks. We're hoping to tag tomorrow, so if it would help you, we'd still be happy to take over. We will of course add a Co-Authored-By line to give you credit.

@samthanawalla
Copy link
Contributor

samthanawalla commented Aug 21, 2025

LGTM once you resolve the conflicts, thanks!

@krtkvrm krtkvrm force-pushed the feat/issue-13-elicitation-support branch from 9e488ed to 87d139d Compare August 21, 2025 20:58
@krtkvrm
Copy link
Contributor Author

krtkvrm commented Aug 21, 2025

@samthanawalla @jba @findleyr thanks for helping with reviews on this PR. again sorry for delays, I was caught up with something personal. Please feel free to take over if the deadline is close and things are pending.

Looking forward to contribute more :)

@findleyr
Copy link
Contributor

Thanks @krtkvrm! Do you think you could look into the staticcheck lint failure? It looks trivial, and is blocking our merging.

@krtkvrm
Copy link
Contributor Author

krtkvrm commented Aug 21, 2025

pushed the fix for lint

@krtkvrm krtkvrm requested a review from jba August 21, 2025 21:05
@samthanawalla samthanawalla merged commit c058c6a into modelcontextprotocol:main Aug 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elicitation support
5 participants