Skip to content

add: elicitation support #535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

QuantGeekDev
Copy link
Contributor

@QuantGeekDev QuantGeekDev commented Jun 19, 2025

Added support for elicitation introduced in the 2025-06-18 specification update. Works across Tools, Resources and Prompts.

This PR depends on #532 for using elicitation from the sdk

Motivation and Context

Adds the ability for users to debug and test the new elicitation feature

How Has This Been Tested?

Here is a video showcasing the functionality and testing

Tested against a demo server I built to test elicitations mcp-elicitations server that implements elicitation in tools, prompts, and resources with the @modelcontextprotocol/sdk@0.1.13
The server is also accessible via this url https://weekly-mink.mcpstudio.io/mcp
You can replicate results by checking out this branch, and connecting the inspector to the hosted server url via streamable-http. Then try to use any of the prompts, tools, or resources. I recommend increasing the request timeout in the inspector configuration

I would appreciate feedback on this - are modals a good way to represent elicitation in the inspector?

Breaking Changes

No, this is a new feature of the protocol that has to be specifically invoked in server code

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed
@QuantGeekDev QuantGeekDev changed the title Feature/elicitations Add Elicitation support Jun 19, 2025
@QuantGeekDev QuantGeekDev changed the title Add Elicitation support add: elicitation support Jun 19, 2025
@oso-jukumari
Copy link

@QuantGeekDev we added your logic to MCPJam/inspector#88 to support elicitation on our client as well. Thank you for helping everyone with your ideas! 🎉

@olaservo
Copy link
Member

Hi @QuantGeekDev - we finally merged in some fixes to the input forms that were pending for a while, but unfortunately that led to some conflicts in this branch. Let me know if you want me to try resolving them, would definitely like to get your PR in soon.

@QuantGeekDev
Copy link
Contributor Author

Hi @QuantGeekDev - we finally merged in some fixes to the input forms that were pending for a while, but unfortunately that led to some conflicts in this branch.z Let me know if you want me to try resolving them, would definitely like to get your PR in soon.

Thanks for the heads up. I will get this fixed up

@QuantGeekDev
Copy link
Contributor Author

@QuantGeekDev we added your logic to MCPJam/inspector#88 to support elicitation on our client as well. Thank you for helping everyone with your ideas! 🎉

That is awesome :) I hope it was useful - I like your inspector

@QuantGeekDev
Copy link
Contributor Author

Hasn't slipped my mind, just been a bit busy. Should be done within next 3 days

@cliffhall
Copy link
Contributor

cliffhall commented Jul 2, 2025

I would appreciate feedback on this - are modals a good way to represent elicitation in the inspector?

The way you've implemented this looks appropriate. As a modal, we're indicating that the user needs to take an action, not merely that they can choose to interact with a new part of the UI or ignore it.

As you get this one's conflicts resolved, I'll take a look at adding elicitations to our Everything server for in-project testing / demonstrating.

Resolved conflicts by adopting the improved form input handling from main: - Standardized JsonSchemaType.required to only accept string arrays (JSON Schema standard) - Adopted enhanced object and array rendering with proper nested support - Improved boolean field rendering (removed extra wrapper div) - Enhanced array handling with add/remove functionality - Simplified required field validation logic This maintains elicitation functionality while benefiting from the form input fixes.
@cliffhall
Copy link
Contributor

cliffhall commented Jul 3, 2025

I would appreciate feedback on this - are modals a good way to represent elicitation in the inspector?

@QuantGeekDev Coming back to this question, and revising my answer. I think that it should be implemented like sampling on a separate tab. The reason being that while your examples are small, some servers might require a larger form than the modal could comfortably handle.

@cliffhall
Copy link
Contributor

cliffhall commented Jul 3, 2025

I now have a PR for an elicitation tool in the everything reference server for testing this functionality.

Copy link
Contributor

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

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

A few requests:

  • Bump SDK version to 1.14.0
  • Replace elicitation reject action with decline (last minute change to spec doc didn't make it in to schema so it was reverted in SDK version 1.14.0)
  • Fix required type in jsonUtils.ts (boolean vs string[] issue was merged last week, your branch is older)
  • Fix use of enumNames which did not make it into the JSON Schema spec and the recommended implementation of labeled enums is with const and oneOf or anyOf, e.g.,
{ "type": "string", "oneOf": [ { "const": "red", "title": "Stop" }, { "const": "amber", "title": "Caution" }, { "const": "green", "title": "Go" } ] }
package.json Outdated
@@ -46,7 +46,7 @@
"@modelcontextprotocol/inspector-cli": "^0.14.3",
"@modelcontextprotocol/inspector-client": "^0.14.3",
"@modelcontextprotocol/inspector-server": "^0.14.3",
"@modelcontextprotocol/sdk": "^1.12.1",
"@modelcontextprotocol/sdk": "^1.13.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"@modelcontextprotocol/sdk": "^1.13.0",
"@modelcontextprotocol/sdk": "^1.14.0",
description?: string;
required?: boolean;
required?: boolean | string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Should only be array of strings. This was previously fixed. The boolean type here appears to be a regression. It isn't present on main right now, so I assume you are working from an older branch, and this is one of the conflicts to be resolved.

Screenshot 2025-07-03 at 3 40 36 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.

Indeed from older branch, moved to string array only

pattern?: string;
format?: string;
enum?: string[];
enumNames?: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

enumNames is not part of the JSONSchema spec. The recommended way to describe enum labels is with oneOf or anyOf.

const schema = {
type: "string" as const,
enum: ["option1", "option2"],
enumNames: ["Option 1", "Option 2"],
Copy link
Contributor

Choose a reason for hiding this comment

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

enumNames is not part of the JSONSchema spec. The recommended way to describe enum labels is with oneOf or anyOf.

role: {
type: "string",
enum: ["admin", "user", "guest"],
enumNames: ["Administrator", "User", "Guest"],
Copy link
Contributor

Choose a reason for hiding this comment

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

enumNames is not part of the JSONSchema spec. The recommended way to describe enum labels is with oneOf or anyOf.

@@ -140,36 +140,144 @@ const DynamicJsonForm = ({
);
}

const isFieldRequired = (fieldPath: string[]): boolean => {
if (typeof schema.required === "boolean") {
Copy link
Contributor

Choose a reason for hiding this comment

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

should only be a string array after fix to jsonUtils.ts.

<option value="">Select an option...</option>
{propSchema.enum.map((option, index) => (
<option key={option} value={option}>
{propSchema.enumNames?.[index] || option}
Copy link
Contributor

Choose a reason for hiding this comment

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

enumNames is not part of the JSONSchema spec. The recommended way to describe enum labels is with oneOf or anyOf.

const schema: JsonSchemaType = {
type: "string",
enum: ["val1", "val2"],
enumNames: ["Label 1", "Label 2"],
Copy link
Contributor

Choose a reason for hiding this comment

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

enumNames is not part of the JSONSchema spec. The recommended way to describe enum labels is with oneOf or anyOf.

country: {
type: "string",
enum: ["US", "UK", "CA"],
enumNames: ["United States", "United Kingdom", "Canada"],
Copy link
Contributor

Choose a reason for hiding this comment

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

enumNames is not part of the JSONSchema spec. The recommended way to describe enum labels is with oneOf or anyOf.

@QuantGeekDev
Copy link
Contributor Author

A few requests:

  • Fix required type in jsonUtils.ts

  • Fix use of enumNames which did not make it into the JSON Schema spec and the recommended use is with const and oneOf or anyOf, e.g.,

{ "type": "string", "oneOf": [ { "const": "red", "title": "Stop" }, { "const": "amber", "title": "Caution" }, { "const": "green", "title": "Go" } ] } 
  • Revert reject action to decline (last minute change to spec doc didn't make it in to schema so it was reverted in SDK version 1.14.0)

Received, will add this too. Out this weekend but adding it on Monday/Tuesday - does that work out?

@cliffhall cliffhall added the waiting on submitter Waiting for the submitter to provide more info label Jul 3, 2025
@cliffhall cliffhall mentioned this pull request Jul 3, 2025
9 tasks
QuantGeekDev and others added 4 commits July 4, 2025 09:42
Co-authored-by: Cliff Hall <cliff@futurescale.com>
Co-authored-by: Cliff Hall <cliff@futurescale.com>
QuantGeekDev and others added 11 commits July 4, 2025 10:54
…enums - Make JsonSchemaType.type optional to support const-only schemas - Add JsonSchemaConst type for schema objects using const values - Update oneOf/anyOf to accept both full schemas and const schemas - Add comprehensive tests for oneOf with const and title patterns This fixes TypeScript compilation errors when using the JSON Schema specification's recommended approach for labeled enums: { "type": "string", "oneOf": [{ "const": "red", "title": "Stop" }] } Replaces deprecated enumNames pattern with spec-compliant implementation.
@cliffhall
Copy link
Contributor

@QuantGeekDev you need to merge main into your branch. package-lock.json is out of date

@QuantGeekDev
Copy link
Contributor Author

QuantGeekDev commented Jul 4, 2025

@cliffhall Updated with the feedback, thanks for taking the time to give it. I think this is ready for UAT. Here's a video showing the new functionality in action
Let me know your thoughts

@QuantGeekDev
Copy link
Contributor Author

Part of me thinks it makes sense to redirect the user back to the tool call after they complete the elicitation @cliffhall, you can see that it's a bit awkward navigating back to the tool response

@cliffhall
Copy link
Contributor

Part of me thinks it makes sense to redirect the user back to the tool call after they complete the elicitation @cliffhall, you can see that it's a bit awkward navigating back to the tool response

Definitely, we should send the user back to the tool tab to view the response.

@olaservo
Copy link
Member

olaservo commented Jul 7, 2025

Btw, there was a different elicitation demo change open for the Everything server here that was just buried in the other server PRs, I think we're going to use this one and close the other one: modelcontextprotocol/servers#2215

@cliffhall
Copy link
Contributor

@QuantGeekDev another thing is, if the user declines elicitation, this current PR is not showing the result after the tool call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting on submitter Waiting for the submitter to provide more info
4 participants