-
Notifications
You must be signed in to change notification settings - Fork 288
[MCP] Added support for --mcp-stdio flag to dab start
#2983
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?
Conversation
|
/azp run #Resolved |
|
Azure Pipelines successfully started running 6 pipeline(s). #Resolved |
|
/azp run #Resolved |
|
Azure Pipelines successfully started running 6 pipeline(s). #Resolved |
|
/azp run #Resolved |
|
Azure Pipelines successfully started running 6 pipeline(s). #Resolved |
--mcp-stdio flag to dab start
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 adds Model Context Protocol (MCP) stdio support to Data API Builder, enabling DAB to function as an MCP server with role-based authorization. The implementation ensures MCP sessions can run under a specific DAB authorization role (from dab-config.json) by detecting --mcp-stdio early, configuring I/O streams appropriately, and forcing the Simulator authentication provider for requested roles.
Key changes:
- Service entrypoint detects
--mcp-stdioflag, configures stdin/stdout encodings, redirects non-MCP output to stderr, parses optionalrole:<name>argument, and runs MCP stdio loop instead of HTTP server. - CLI integration adds
--mcp-stdiooption and optional positionalroleargument todab startcommand. - New
McpStdioServerimplementation handles JSON-RPC requests (initialize, listTools, callTool) over stdio with role-based authentication context.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/Startup.cs | Adds MCP stdio mode detection and forces Simulator authentication when running in MCP stdio mode |
| src/Service/Program.cs | Implements MCP stdio mode detection, I/O configuration, role parsing, and server loop instead of HTTP host |
| src/Cli/Exporter.cs | Updates StartOptions constructor calls to include new MCP parameters |
| src/Cli/ConfigGenerator.cs | Adds logic to append MCP stdio switches and role argument when starting engine |
| src/Cli/Commands/StartOptions.cs | Adds McpStdio and McpRole properties with corresponding CLI options |
| src/Azure.DataApiBuilder.Mcp/IMcpStdioServer.cs | Defines interface for MCP stdio server |
| src/Azure.DataApiBuilder.Mcp/Core/McpStdioServer.cs | Implements MCP stdio server with JSON-RPC message handling and role-based authorization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No pipelines are associated with this pull request. #Resolved |
2 similar comments
|
No pipelines are associated with this pull request. #Resolved |
|
No pipelines are associated with this pull request. #Resolved |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
dab-config.json.What is this change?
Service entrypoint
--mcp-stdioearly, configures stdin/stdout encodings, and redirects all non‑MCP output to STDERR to keep STDOUT clean for MCP JSON.role:<name>argument (e.g. role:anonymous, role:authenticated) and injects it into configuration asMCP:Role, defaulting toanonymouswhen omitted.Runtime:Host:Authentication:Provider = "Simulator"via in‑memory configuration so the requested role is always available during MCP sessions.host.Run().CLI Integration
--mcp-stdiotodab startto launch the engine in MCP stdio mode.roleargument (e.g.role:anonymous) captured asStartOptions.McpRole.dab startunchanged.Note
ExecuteEntityToolnow looks for MCP tool inputs under arguments (the standard MCP field) and falls back to the legacy parameters property only if arguments is missing. This aligns our server with how current MCP clients (like VS Code) actually send tool arguments, and preserves backward compatibility for any older clients that still use parameters.How was this tested?
Integration-like manual testing via MCP clients against:
dotnet Azure.DataApiBuilder.Service.dll --mcp-stdio role:authenticated.dab start --mcp-stdio role:authenticated.Manual verification of all MCP tools:
describe_entitiesshows correct entities and effective permissions for the active role.read_records,create_record,update_record,delete_record,execute_entitysucceed when the role has the appropriate permissions.Sample Request(s)
{ "mcpServers": { "dab-with-exe": { "command": "C:\\DAB\\data-api-builder\\out\\publish\\Debug\\net8.0\\win-x64\\dab\\Microsoft.DataApiBuilder.exe", "args": ["start", "--mcp-stdio", "role:authenticated", "--config", "C:\\DAB\\data-api-builder\\dab-config.json"], "env": { "DAB_ENVIRONMENT": "Development" } } }2. MCP server via engine DLL
{ "mcpServers": { "dab": { "command": "dotnet", "args": [ "C:\\DAB\\data-api-builder\\out\\publish\\Debug\\net8.0\\win-x64\\dab\\Azure.DataApiBuilder.Service.dll", "--mcp-stdio", "role:authenticated", "--config", "C:\\DAB\\data-api-builder\\dab-config.json" ], "type": "stdio" } } }