-
Notifications
You must be signed in to change notification settings - Fork 369
[MCP] Initialize metadata providers in stdio mode #3784
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,16 @@ public static bool RunMcpStdioHost(IHost host) | |
| { | ||
| try | ||
| { | ||
| // Stdio mode never calls host.Run(), so Startup.Configure -- and with it | ||
| // PerformOnConfigChangeAsync, the only caller of IMetadataProviderFactory | ||
| // .InitializeAsync() -- never executes. Without this, entities are known to | ||
| // the tool registry (their names come from config) while no entity ever gets | ||
| // a database object, and every tool call fails with | ||
| // "Database object for entity '<name>' has not been inferred." | ||
| Core.Services.MetadataProviders.IMetadataProviderFactory metadataProviderFactory = | ||
| host.Services.GetRequiredService<Core.Services.MetadataProviders.IMetadataProviderFactory>(); | ||
| metadataProviderFactory.InitializeAsync().GetAwaiter().GetResult(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this inside a try/finally that only disposes the host, so any initialization exception propagates raw out of RunMcpStdioHost (which otherwise returns bool). Consider wrapping it so a metadata-inference failure produces a clear, logged error over the stdio channel rather than an unhandled exception |
||
|
|
||
| Mcp.Core.McpToolRegistry registry = | ||
| host.Services.GetRequiredService<Mcp.Core.McpToolRegistry>(); | ||
| IEnumerable<Mcp.Model.IMcpTool> tools = | ||
|
|
||
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.
nit- just import
using Azure.DataApiBuilder.Core.Services.MetadataProvidersinstead of calling the same multiple times.