Added missing stored procedure parameters in describe_entities response.#3425
Added missing stored procedure parameters in describe_entities response.#3425anushakolan wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
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. |
Aniruddh25
left a comment
There was a problem hiding this comment.
Want to know reasoning behind why the bug happened.
|
|
||
| if (databaseObject is DatabaseStoredProcedure storedProcedure) | ||
| { | ||
| foreach ((string parameterName, ParameterDefinition parameterDefinition) in storedProcedure.StoredProcedureDefinition.Parameters) |
There was a problem hiding this comment.
What was the reason again to have two different data structures? ParameterDefinitionand ParameterMetadata? why couldnt we have used ParameterDefinition for the config parameters?
There was a problem hiding this comment.
ParameterDefinition is runtime metadata discovered from the database. ParameterMetadata is user-specified config overrides. Both exist because DB metadata provides the source of truth for parameters, while config allows users to enrich with descriptions/defaults.
There was a problem hiding this comment.
I understand we need both the objects. My question is - why couldnt we have expanded ParameterDefinition - the same data structure to support user specified config overrides? Why did we introduce a new class ParameterMetadata = also, the name is confusing.
Parameter information from DB metadata is called ParameterDefinition and not ParameterMetadata.
|
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 Bug #3435 needs a follow-up PR to fix The fix requires passing |
Original implementation only read config ( |
I think we are discussing two separate things-
so for point 1- we might not need this PR unless we want to move completely to DB based discoverability to avoid split brain or incosistent behaviour. |
| foreach (ParameterMetadata configParameter in configParameters.Values) | ||
| { | ||
| if (!storedProcedure.StoredProcedureDefinition.Parameters.ContainsKey(configParameter.Name)) | ||
| if (!storedProcedureParameters.ContainsKey(configParameter.Name) && |
There was a problem hiding this comment.
why cant the ContainsKey comparison itself be case insensitive instead of adding another && condition?
There was a problem hiding this comment.
On second thought, all configParameters should be present in the metadata retrieved from the database. In fact, config parameters should be a subset of database parameters.
There might a validation check to ensure this.
|
|
||
| foreach ((string parameterName, ParameterDefinition parameterDefinition) in storedProcedureParameters) | ||
| { | ||
| configParameters.TryGetValue(parameterName, out ParameterMetadata? configParameter); |
There was a problem hiding this comment.
PR description says -
Merged DB metadata with config metadata so config values override matching fields (required, default, description).
However, this is not what is implemented.
With the current implementation, config values will never be added to the result since ALL config parameters should be discoverable in storedProcedureParameters by definition.
But the current check !storedProcedureParameters.ContainsKey(configParameter.Name) tries to identify the missing ones.
Config metadata should only be used to override, which means after reading params from DB metadata, the config values should be used to replace the values from DB.
| Assert.AreEqual(2, parameters.GetArrayLength()); | ||
|
|
||
| JsonElement idParam = parameters.EnumerateArray().Single(p => p.GetProperty("name").GetString() == "id"); | ||
| Assert.IsFalse(idParam.GetProperty("required").GetBoolean(), "DB required metadata should be preferred when config cannot indicate whether 'required' was explicitly set."); |
There was a problem hiding this comment.
The test is titled DescribeEntities_ConfigParameterMetadataOverridesDatabaseParameterMetadata
whereas this assert is doing exactly the opposite - DB is overriding config?
Assert should be Assert.IsTrue
Why make this change?
Closes #3400.
describe_entitiescould return stored procedure entities with empty or partialparametersmetadata when parameters were not fully listed in config. This caused MCP clients/agents to miss required inputs and failexecute_entitycalls.Additional discussion: #3400 issue thread.
What is this change?
DescribeEntitiesToolto include stored procedure parameters from runtime DB metadata.required,default,description).How was this tested?
Ran:
Sample Request(s)
MCP request example:
describe_entitieswith full metadata:{"name":"describe_entities","arguments":{}}execute_entityusing discovered parameters:{"name":"execute_entity","arguments":{"entity":"GetBook","parameters":{"id":1}}}