-
Notifications
You must be signed in to change notification settings - Fork 289
Refactor common code shared amongst built in MCP tools #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor common code shared amongst built in MCP tools #2986
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors common code shared among built-in MCP tools by introducing the McpMetadataHelper class and extending McpArgumentParser to centralize metadata resolution, argument parsing, and authorization checks across all MCP tools.
- Introduced
McpMetadataHelper.TryResolveMetadata()to consolidate entity metadata resolution logic - Extended
McpArgumentParserwithTryParseEntity(),TryParseEntityAndData(), andTryParseEntityAndKeys()methods - Refactored all tool classes to use the new helper classes, removing duplicated code
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Azure.DataApiBuilder.Mcp/Utils/McpMetadataHelper.cs | New helper class for resolving entity metadata, data sources, and database objects |
| src/Azure.DataApiBuilder.Mcp/Utils/McpArgumentParser.cs | Extended with new parsing methods for entity, entity+data, and entity+keys argument combinations |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/UpdateRecordTool.cs | Refactored to use shared helpers; removed duplicate parsing and authorization code |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ReadRecordsTool.cs | Refactored to use shared helpers; optimized orderby processing with string.Join |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/ExecuteEntityTool.cs | Refactored to use McpMetadataHelper for metadata resolution |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/DeleteRecordTool.cs | Refactored to use shared helpers; simplified tool metadata method with expression body |
| src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.cs | Refactored to use shared helpers for parsing, metadata resolution, and authorization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
…ithub.com:Azure/data-api-builder into dev/aaronburtle/RefactorCommonCodeBuiltInMCPtools
Co-authored-by: Copilot <[email protected]>
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
The main issue here is the testing. I see you tested against normal test suite, which I assume are all the tests in |
|
Is there any common code in |
|
Weare having around 4 helper class so far |
I think for now we have good separation of responsibilities with these different helper classes. If we find ourselves adding more and more we can think about reorganizing them but for now I think this makes sense. |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
Closes #2932
What is this change?
Add helper class
McpMetadataHelper, extendMcpArgumentParser, and utilizeMcpAuthorizationHelperto factor out common code. We now do the initialization of the metadata, the parsing of arguments, and the authorization checks in these shared helper classes.How was this tested?
Against the normal test suite.
Sample Request(s)
N/A