add displayValue support to completions #589
Open
+81
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds (non-breaking) support for
displayName
in the completions server response which clients can use to display something different for a value than the value itself.Motivation and Context
@connor4312 demonstrates the need for this in a real world setting today:
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):
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
Checklist
Additional context
Closes #585