-
Notifications
You must be signed in to change notification settings - Fork 296
[MCP] Centralize JSON‑RPC error handling, standardize MCP response envelope, and add default anonymous role for stdio mode. #3035
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 |
|
Azure Pipelines successfully started running 6 pipeline(s). |
mcp-stdio mode code changes.
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 is a follow-up to #2983 that improves the MCP stdio server implementation by centralizing JSON-RPC error handling, standardizing response writing, and adding an implicit default role when none is provided.
- Centralized all JSON-RPC error codes into a single
JsonRpcErrorCodesclass - Standardized response handling through shared
WriteResultandWriteErrorhelper methods - Added implicit default role of "anonymous" when
--mcp-stdiois used without a role parameter
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Service/Utilities/McpStdioHelper.cs | Added [NotNullWhen(true)] attribute to enforce non-null role guarantee, implemented implicit default role of "anonymous", and removed unnecessary service scope creation since services are singletons |
| src/Service/Program.cs | Added copyright header (formatting artifact in diff) |
| src/Azure.DataApiBuilder.Mcp/Core/JsonRpcErrorCodes.cs | New file defining centralized JSON-RPC 2.0 error codes for consistent error handling across the MCP server |
| src/Azure.DataApiBuilder.Mcp/Core/McpStdioServer.cs | Replaced hardcoded error codes with constants from JsonRpcErrorCodes, refactored initialize handler to use standardized WriteResult, and updated server name in initialization response |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Aniruddh25
left a comment
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.
Approved, but please fix the title to mention "what" the code changes are. Follow up PR doesnt convey much information unless you look into the changes. The PR titles are seen directly in the Release notes, so they should be more meaningful. For example, in this case, it is refactor to use common JsonRpcErrorCodes
mcp-stdio mode code changes.
Why make this change?
This is a follow up PR for, #2983 to address some of the newer comments.
What is this change?
anonymouswhen no role is provided inmcp-stdiomode.How was this tested?
Tested manually by calling all the CRUD tools and execute tool.
Added an MCP server in VS Code in
C:\DAB\data-api-builder\.vscode\mcp.json"dab-with-exe": { "command": "C:\\DAB\\data-api-builder\\out\\publish\\Debug\\net8.0\\win-x64\\dab\\Microsoft.DataApiBuilder.exe", "args": ["start", "--mcp-stdio", "--config", "C:\\DAB\\data-api-builder\\dab-config.json"], "env": { "DAB_ENVIRONMENT": "Development" } }Authenticatedall tools pass.Anonymous, all tools exceptdescribe-entitiesfail with permission denied error.describe-entitiesfail with permission denied error.