Skip to content

Comments

feat: Add support for Completions Metadata#589

Open
kentcdodds wants to merge 1 commit intomodelcontextprotocol:mainfrom
kentcdodds:patch-2
Open

feat: Add support for Completions Metadata#589
kentcdodds wants to merge 1 commit intomodelcontextprotocol:mainfrom
kentcdodds:patch-2

Conversation

@kentcdodds
Copy link
Contributor

@kentcdodds kentcdodds commented May 28, 2025

This adds (non-breaking) support for title and description in the completions server response which clients can use to display something different for a value than the value itself.

SEP: #1440

Motivation and Context

@connor4312 demonstrates the need for this in a real world setting today:

Screenshot of a tweet by @connor4312 stating, “I would use this in VS Code 👍 Our current UI for prompt completions:” followed by an image of a dark-themed UI dropdown titled “temperature (1/2)” with a text input labeled “Temperature setting” and options including “Insert as text”, “Run as Command”, and temperature values: 0, 0.5, 0.7, and 1.0. The option “0” is highlighted.

The user experience could be much better if they could provide display values.

Here's another example from a Journaling server I run (screenshot from MCP Inspector):

Dropdown UI from the MCP Inspector Resource Templates tool. The section is labeled “entry” with a subheading “A single entry.” The user is selecting an id from a searchable dropdown input. The list includes values in descending order: 71, 61, 51, 41, 31, 21, 19, down to 1, which is currently selected and indicated with a checkmark.

This is the best they can do. Users have to just know what ID they want. Would be better if I could display the journal entry title and the date in parentheses.

With this setup, the user would naturally type the title rather than the ID and the server could filter based on the title (or any other field) instead of just the ID.

How Has This Been Tested?

No, but it's a common pattern in many libraries with UX experiences like this.

Breaking Changes

I'm not a huge fan of having two ways to do this, but for simple use cases, it's much better to just use an array of strings so there's a good argument to support both an array of value/displayValue objects as well as an array of strings. If we do go this direction, then there is no breaking change here.

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

Additional context

Closes #585

@connor4312
Copy link
Contributor

connor4312 commented May 28, 2025

You'll want to update the spec in schema/draft/schema.ts and then npm r generate:json to update the JSON schema

@kentcdodds
Copy link
Contributor Author

Done. Thanks!

@connor4312
Copy link
Contributor

@SamMorrowDrums also requested this

@SamMorrowDrums
Copy link
Contributor

Yep, for things like GitHub issue numbers, commit shas and pull request numbers, it would be great to give some more user friendly context.

@kentcdodds
Copy link
Contributor Author

Could make sense to change this to title to match the property name for display values of tools, resources, and prompts.

@kentcdodds kentcdodds requested a review from a team September 8, 2025 14:23
Copy link
Contributor Author

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Gonna switch to title

@kentcdodds kentcdodds changed the title add displayValue support to completions add title support to completions Sep 8, 2025
@kentcdodds
Copy link
Contributor Author

I'd still love to get this in front of people.

@kentcdodds
Copy link
Contributor Author

I've opened a proper SEP: #1440

@kentcdodds kentcdodds changed the title add title support to completions feat: Add support for Completions Metadata Sep 8, 2025
@kentcdodds kentcdodds force-pushed the patch-2 branch 2 times, most recently from ee2282a to bec38f0 Compare September 9, 2025 17:50
@dsp-ant
Copy link
Member

dsp-ant commented Nov 24, 2025

@kentcdodds is this still the right implementation or should we close this PR?

@kentcdodds
Copy link
Contributor Author

This PR represents the latest of the proposal to the best of my ability :)

@domdomegg domdomegg requested a review from a team as a code owner November 25, 2025 19:37
@localden
Copy link
Contributor

localden commented Dec 5, 2025

@kentcdodds do you mind resolving the schema conflicts in this PR?

@localden localden added enhancement New feature or request schema Work related to schema changes. labels Dec 5, 2025
@kentcdodds
Copy link
Contributor Author

Done 👍 Thanks!

- Introduced the CompletionValue interface to standardize completion value structure with title, value, and optional description
- Updated CompleteResult interface to reference CompletionValue for its values property
- Enhanced completion documentation to reflect new structure with description field
- Adjusted JSON schema to define CompletionValue and replace inline definitions with references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request schema Work related to schema changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants