Expose required array in custom MCP tool input schema#3688
Open
souvikghosh04 with Copilot wants to merge 7 commits into
Open
Expose required array in custom MCP tool input schema#3688souvikghosh04 with Copilot wants to merge 7 commits into
required array in custom MCP tool input schema#3688souvikghosh04 with Copilot wants to merge 7 commits into
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
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances MCP custom tool discoverability by emitting a JSON Schema required array in DynamicCustomTool input schemas, allowing agents/clients to distinguish mandatory parameters from optional/defaulted ones.
Changes:
- Add top-level
requiredarray emission to the DB-metadata schema path (BuildInputSchema) when at least one parameter is required. - Add the same
requiredarray emission to the config-fallback schema path (BuildInputSchemaFromConfig). - Add unit and MSSQL integration tests to validate required/optional/defaulted parameter behavior and the zero-parameter omission case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Azure.DataApiBuilder.Mcp/Core/DynamicCustomTool.cs | Builds MCP tool inputSchema.required based on parameter requirement/default rules for both DB and config-fallback paths. |
| src/Service.Tests/Mcp/DynamicCustomToolTests.cs | Adds unit tests asserting required array inclusion/exclusion and omission for zero-parameter procedures, including config-fallback validation. |
| src/Service.Tests/Mcp/DynamicCustomToolMsSqlIntegrationTests.cs | Adds MSSQL integration coverage validating required against live stored procedure metadata and config defaults. |
Aniruddh25
reviewed
Jul 7, 2026
Aniruddh25
reviewed
Jul 7, 2026
Aniruddh25
requested changes
Jul 7, 2026
Aniruddh25
left a comment
Collaborator
There was a problem hiding this comment.
Needs 1 more test for combination of required and default
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Aniruddh25
approved these changes
Jul 9, 2026
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
This was referenced Jul 10, 2026
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" ] } }