Expose required array in custom MCP tool input schema#3688
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
Copilot
AI
changed the title
[WIP] Fix empty properties in custom tool inputSchema
Expose Jun 26, 2026
required array in custom MCP tool input schema
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?
DynamicCustomTool) build aninputSchemawith typedpropertiesfrom stored procedure metadata, but never emitted a JSON Schemarequiredarray. AI agents had no way to tell which parameters are mandatory and had to fall back to description text ordescribe_entities.What is this change?
DynamicCustomTool.BuildInputSchemaFromDbMetadata: collects parameter names while iterating SP parameters and adds a top-levelrequiredarray when non-empty.DynamicCustomTool.BuildInputSchemaFromConfig(fallback path): same treatment for config-declared parameters.IsParameterRequired(bool? configuredRequired, bool hasDefault)helper centralizes the rule: a parameter is required unless config explicitly marks it optional (required: false) or supplies a default the engine applies when the caller omits it. Consistent with the execution-time default-application logic anddescribe_entitiessemantics.Resulting schema:
How was this tested?
DynamicCustomToolTests: required params listed, params with defaults /required:falseexcluded, zero-param SP omits the array, config-fallback path.DynamicCustomToolMsSqlIntegrationTests: validatesrequiredagainst live DB metadata (GetBook.idrequired;InsertBookdefaulted params excluded; zero-paramGetBooksomits the array).Sample Request(s)
MCP
tools/listresponse for a custom tool overget_book_by_id(@id int):{ "name": "get_book", "description": "Executes the get_book stored procedure", "inputSchema": { "type": "object", "properties": { "id": { "type": "integer", "description": "Parameter id" } }, "required": [ "id" ] } }