Skip to content

Added missing stored procedure parameters in describe_entities response.#3425

Open
anushakolan wants to merge 3 commits intomainfrom
dev/anushakolan/describe_entities_missing_sp_params
Open

Added missing stored procedure parameters in describe_entities response.#3425
anushakolan wants to merge 3 commits intomainfrom
dev/anushakolan/describe_entities_missing_sp_params

Conversation

@anushakolan
Copy link
Copy Markdown
Contributor

Why make this change?

Closes #3400.

describe_entities could return stored procedure entities with empty or partial parameters metadata when parameters were not fully listed in config. This caused MCP clients/agents to miss required inputs and fail execute_entity calls.

Additional discussion: #3400 issue thread.

What is this change?

  • Updated DescribeEntitiesTool to include stored procedure parameters from runtime DB metadata.
  • Merged DB metadata with config metadata so config values override matching fields (required, default, description).
  • Preserved fallback behavior: if metadata resolution fails, config-defined parameters are still returned.
  • Added focused MCP tests for:
    • metadata-only parameter discovery
    • config-overrides-DB merge behavior

How was this tested?

  • Integration Tests
  • Unit Tests

Ran:

  • dotnet test src/Service.Tests/Azure.DataApiBuilder.Service.Tests.csproj --filter "FullyQualifiedName~DescribeEntitiesStoredProcedureParametersTests"

Sample Request(s)

MCP request example:

  • describe_entities with full metadata:

    • {"name":"describe_entities","arguments":{}}
  • execute_entity using discovered parameters:

    • {"name":"execute_entity","arguments":{"entity":"GetBook","parameters":{"id":1}}}

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates MCP describe_entities to reliably include complete stored procedure parameter metadata by augmenting/merging config-defined parameters with runtime database metadata, and adds targeted tests to validate the behavior.

Changes:

  • Resolve stored procedure parameter metadata from runtime DB metadata when config parameters are missing/partial.
  • Merge config + DB parameter metadata, preferring config values for overlapping fields.
  • Add MCP unit tests covering metadata-only discovery and config-overrides-DB merging.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Adds metadata resolution for stored procedure entities and merges DB/config parameter metadata in describe_entities output.
src/Service.Tests/Mcp/DescribeEntitiesStoredProcedureParametersTests.cs Adds unit tests validating parameter discovery from DB metadata and config-overrides behavior.

Comment thread src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Outdated
Comment thread src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs
Comment thread src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Outdated
Copy link
Copy Markdown
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to know reasoning behind why the bug happened.

Comment thread src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Outdated
Comment thread src/Azure.DataApiBuilder.Mcp/BuiltInTools/DescribeEntitiesTool.cs Outdated
@RubenCerna2079
Copy link
Copy Markdown
Contributor

Hey just wanted to let you know that it seems this PR is related to a bug that I created for 2.0. Might be a good idea to check it and see if it can be fixed on this PR or as a follow up. #3435

@anushakolan
Copy link
Copy Markdown
Contributor Author

Hey just wanted to let you know that it seems this PR is related to a bug that I created for 2.0. Might be a good idea to check it and see if it can be fixed on this PR or as a follow up. #3435

Thanks for linking these! They share the same root cause: parameter metadata is read only from config, not from runtime DB metadata.

PR #3425 fixes describe_entities (AI agents can now discover parameters).

Bug #3435 needs a follow-up PR to fix DynamicCustomTool.BuildInputSchema() the same way - it currently only reads Entity.Source.Parameters from config, not from IMetadataProviderFactory.

The fix requires passing IServiceProvider through CustomMcpToolFactory to DynamicCustomTool so it can access runtime metadata for schema building.

@anushakolan
Copy link
Copy Markdown
Contributor Author

anushakolan commented Apr 17, 2026

Want to know reasoning behind why the bug happened.

Original implementation only read config (Entity.Source.Parameters), ignoring runtime-discovered parameters from IMetadataProviderFactory. The fix merges both: DB metadata as base, config as overrides. May be @souvikghosh04 can add anything I missed.

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]: describe_entities missing stored procedure parameters

6 participants