Populate required array in MCP custom tool inputSchema#3686
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Copilot
AI
changed the title
[WIP] Fix required params not populated in MCP custom tool inputSchema
Populate Jun 26, 2026
required array in MCP custom tool inputSchema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why make this change?
inputSchemaof MCP custom tools omitted therequiredarray, so consumers could not tell which stored procedure parameters were mandatory. Expectedrequired: ["firstName", "lastName"]; actual was unpopulated.What is this change?
DynamicCustomToolnow emits arequiredarray in both schema-building paths, treating a parameter as required when it has no default value to fall back on — consistent with the existingOpenApiDocumentorconvention.BuildInputSchemaFromDbMetadata: requires params where!HasConfigDefault.BuildInputSchemaFromConfig: requires params whereDefault is null.requiredkey is only added when at least one parameter qualifies, keeping schemas clean for zero-param / fully-defaulted procedures.{ "type": "object", "properties": { "firstName": { "type": "string", "description": "Parameter firstName" }, "lastName": { "type": "string", "description": "Parameter lastName" }, "nickname": { "type": "string", "description": "Parameter nickname (default: guest)" } }, "required": ["firstName", "lastName"] }How was this tested?
Added coverage in
DynamicCustomToolTestsfor both the config-based and DB-metadata-based paths, verifying non-defaulted params are listed inrequiredand defaulted ones are excluded.Sample Request(s)
MCP
tools/listreturns the custom tool with a populatedrequiredarray:{ "name": "get_user", "inputSchema": { "type": "object", "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } }, "required": ["firstName", "lastName"] } }