Skip to content

Expose required array in custom MCP tool input schema#3688

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-custom-tool-input-schema
Draft

Expose required array in custom MCP tool input schema#3688
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-custom-tool-input-schema

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

  • Closes [Bug]: Custom tool inputSchema has empty properties #3399
  • Custom MCP tools (DynamicCustomTool) build an inputSchema with typed properties from stored procedure metadata, but never emitted a JSON Schema required array. AI agents had no way to tell which parameters are mandatory and had to fall back to description text or describe_entities.

What is this change?

  • DynamicCustomTool.BuildInputSchemaFromDbMetadata: collects parameter names while iterating SP parameters and adds a top-level required array 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 and describe_entities semantics.

Resulting schema:

"inputSchema": {
  "type": "object",
  "properties": { "productId": { "type": "integer" } },
  "required": [ "productId" ]
}

How was this tested?

  • Integration Tests
  • Unit Tests

DynamicCustomToolTests: required params listed, params with defaults / required:false excluded, zero-param SP omits the array, config-fallback path. DynamicCustomToolMsSqlIntegrationTests: validates required against live DB metadata (GetBook.id required; InsertBook defaulted params excluded; zero-param GetBooks omits the array).

Sample Request(s)

MCP tools/list response for a custom tool over get_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" ]
  }
}

Copilot AI changed the title [WIP] Fix empty properties in custom tool inputSchema Expose required array in custom MCP tool input schema Jun 26, 2026
Copilot AI requested a review from souvikghosh04 June 26, 2026 08:31
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.

[Bug]: Custom tool inputSchema has empty properties

2 participants