Skip to content

feat/Issue-13: elicitation support - #188

Merged
samthanawalla merged 12 commits into
modelcontextprotocol:mainfrom
krtkvrm:feat/issue-13-elicitation-support
Aug 22, 2025
Merged

feat/Issue-13: elicitation support#188
samthanawalla merged 12 commits into
modelcontextprotocol:mainfrom
krtkvrm:feat/issue-13-elicitation-support

Conversation

@krtkvrm

@krtkvrm krtkvrm commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

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
Comment thread mcp/client.go
@krtkvrm krtkvrm changed the title feat/issue 13 elicitation support feat/Issue-13: elicitation support Jul 29, 2025
@jba

jba commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

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.

@jba jba left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread .gitignore Outdated
Comment thread mcp/client.go
Comment thread mcp/protocol.go Outdated
Comment thread mcp/protocol.go Outdated
@krtkvrm
krtkvrm force-pushed the feat/issue-13-elicitation-support branch from 7ce6c7d to 498871c Compare July 31, 2025 14:49
Comment thread mcp/protocol.go Outdated
Comment thread mcp/protocol.go
Comment thread .gitignore Outdated
Comment thread mcp/protocol.go
Comment thread mcp/client.go Outdated
Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@samthanawalla samthanawalla Aug 11, 2025

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 jba and samthanawalla August 11, 2025 10:01
Comment thread mcp/client.go
}

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread mcp/elicitation_example_test.go Outdated
return &mcp.ElicitResult{
Action: "accept",
Content: map[string]any{
"apiKey": "sk-test123",

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@jba

jba commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

@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

samthanawalla commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

@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

krtkvrm commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

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

@findleyr

Copy link
Copy Markdown
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

samthanawalla commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

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

krtkvrm commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor

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

@krtkvrm

krtkvrm commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

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
yasomaru pushed a commit to yasomaru/go-sdk that referenced this pull request Aug 28, 2025
fixes: modelcontextprotocol#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
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