Skip to content

Populate required array in MCP custom tool inputSchema#3686

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-required-params-in-inputschema
Draft

Populate required array in MCP custom tool inputSchema#3686
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-required-params-in-inputschema

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

  • The JSON Schema inputSchema of MCP custom tools omitted the required array, so consumers could not tell which stored procedure parameters were mandatory. Expected required: ["firstName", "lastName"]; actual was unpopulated.

What is this change?

  • DynamicCustomTool now emits a required array in both schema-building paths, treating a parameter as required when it has no default value to fall back on — consistent with the existing OpenApiDocumentor convention.
    • BuildInputSchemaFromDbMetadata: requires params where !HasConfigDefault.
    • BuildInputSchemaFromConfig: requires params where Default is null.
    • The required key 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?

  • Integration Tests
  • Unit Tests

Added coverage in DynamicCustomToolTests for both the config-based and DB-metadata-based paths, verifying non-defaulted params are listed in required and defaulted ones are excluded.

Sample Request(s)

MCP tools/list returns the custom tool with a populated required array:

{
  "name": "get_user",
  "inputSchema": {
    "type": "object",
    "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" } },
    "required": ["firstName", "lastName"]
  }
}

Copilot AI changed the title [WIP] Fix required params not populated in MCP custom tool inputSchema Populate required array in MCP custom tool inputSchema Jun 26, 2026
Copilot AI requested a review from souvikghosh04 June 26, 2026 08:16
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.

2 participants