Skip to content

Auto-populate completion handlers from AllowedValuesAttribute on prompt/resource parameters#1380

Open
Copilot wants to merge 10 commits intomainfrom
copilot/implement-allowed-values-completion
Open

Auto-populate completion handlers from AllowedValuesAttribute on prompt/resource parameters#1380
Copilot wants to merge 10 commits intomainfrom
copilot/implement-allowed-values-completion

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

  • Remove intermediate array in completion value filtering (use direct foreach with StartsWith check)
  • Guard against non-object properties JSON value before enumerating
  • Use is instead of == for JsonValueKind comparison
  • Guard against non-string enum array items using ValueKind is JsonValueKind.String check
  • Update XML docs on McpServerPromptAttribute, McpServerResourceAttribute, McpServerPrompt, and McpServerResource to note that string parameters with AllowedValuesAttribute automatically surface completions
  • Guard AllowedValues test methods with #if NET for net472 compatibility
  • Add AllowedValuesAttribute section with code samples to completions conceptual docs

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 24, 2026 14:46
…ce JSON schemas and provide automatic completions

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…mpt and resource parameters

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…More state

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
@stephentoub stephentoub marked this pull request as ready for review February 24, 2026 15:55
@stephentoub
Copy link
Contributor

@jeffhandley / @mikekistler / @halter73 / @eiriktsarpalis , thoughts on using [AllowedValues] for this?

…d add AllowedValues docs

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
@stephentoub stephentoub added this to the Future Minor Version milestone Feb 25, 2026
@stephentoub
Copy link
Contributor

@copilot there are build failures for net472; the use of AllowedValues needs to be guarded to just #if NET

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 25, 2026

@copilot there are build failures for net472; the use of AllowedValues needs to be guarded to just #if NET

Wrapped all 5 AllowedValues test methods with #if NET / #endif in 90dd295. The AllowedValuesAttribute type isn't available on net472, so those tests are now excluded from that TFM.

halter73
halter73 previously approved these changes Feb 26, 2026
Copy link
Contributor

@halter73 halter73 left a comment

Choose a reason for hiding this comment

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

thoughts on using [AllowedValues] for this?

Sounds great!

@stephentoub
Copy link
Contributor

@copilot there are now some conceptual docs that talk about completion handlers... Please highlight this mechanism for it with a code sample.

…onceptual docs

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot there are now some conceptual docs that talk about completion handlers... Please highlight this mechanism for it with a code sample.

Added a new "Automatic completions with AllowedValuesAttribute" section to docs/concepts/completions/completions.md in 10b4748, with code samples for both prompt and resource template parameters, and a note about combining with custom handlers.

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.

3 participants