-
Notifications
You must be signed in to change notification settings - Fork 7
Add gateway endpoint to mock tooling server for local agent testing #197
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?
Add gateway endpoint to mock tooling server for local agent testing #197
Conversation
Problem:
- .NET agents expect a platform gateway endpoint at /agents/{agentInstanceId}/mcpServers
- Mock server only provided direct MCP endpoints (/mcp/sse, /agents/servers/{name})
- This caused MCP tool loading failures during local testing with 404 errors
Solution:
- Added /agents/{agentInstanceId}/mcpServers endpoint (lines 208-241)
- Endpoint returns MCP server discovery list matching ToolingManifest.json structure
- Added logging statement for gateway endpoint at startup (line 81)
Testing:
- Verified with local agent + Agent Playground
- Successfully loaded 32 MCP tools (12 Calendar + 20 Mail)
- Agent now correctly schedules meetings using mock calendar tools
Related: Enables Phase 6 local testing workflow
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 a platform gateway endpoint to the mock tooling server to enable local agent testing with MCP server discovery. Previously, .NET agents received 404 errors when trying to discover MCP servers through the expected /agents/{agentInstanceId}/mcpServers endpoint, as the mock server only provided direct MCP endpoints.
Changes:
- Added
/agents/{agentInstanceId}/mcpServersgateway endpoint that returns MCP server discovery information - Included startup logging to indicate gateway endpoint availability
- Response structure matches the platform's ToolingManifest.json format with proper fields (mcpServerName, mcpServerUniqueName, url, scope, audience)
| app.MapGet("/agents/{agentInstanceId}/mcpServers", (string agentInstanceId, ILogger<Program> log) => | ||
| { | ||
| try | ||
| { | ||
| log.LogInformation("Gateway endpoint called for agent instance: {AgentInstanceId}", agentInstanceId); | ||
|
|
||
| // Get the configured server port from the URLs | ||
| var serverUrl = app.Urls.FirstOrDefault() ?? "http://localhost:5309"; | ||
|
|
||
| // Build the MCP server list matching ToolingManifest.json structure | ||
| var mcpServers = mcpServerNames.Select(serverName => new | ||
| { | ||
| mcpServerName = serverName, | ||
| mcpServerUniqueName = serverName, | ||
| url = $"{serverUrl}/agents/servers/{serverName}", | ||
| scope = "offline_access", | ||
| audience = serverUrl | ||
| }).ToArray(); | ||
|
|
||
| log.LogInformation("Returning {Count} MCP servers: {Servers}", | ||
| mcpServers.Length, | ||
| string.Join(", ", mcpServerNames)); | ||
|
|
||
| return Results.Json(new { mcpServers }); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| log.LogError(ex, "Failed to process gateway endpoint request"); | ||
| return Results.Problem(ex.Message, statusCode: 500); | ||
| } | ||
| }); |
Copilot
AI
Jan 27, 2026
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.
The new gateway endpoint lacks test coverage. While this is a development/mock server and other endpoints in this file also lack direct tests, consider adding an integration test to verify the endpoint returns the expected JSON structure with the correct MCP server list. This would help prevent regressions if the endpoint behavior needs to change in the future.
| scope = "offline_access", | ||
| audience = serverUrl |
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.
These two are not used by the SDK and can be safely removed.
Add gateway endpoint to mock tooling server for local agent testing
Problem
/agents/{agentInstanceId}/mcpServersto discover available MCP servers/mcp/sse,/agents/servers/{name})Solution
/agents/{agentInstanceId}/mcpServersgateway endpoint toServer.csToolingManifest.jsonstructure expected by the platformmcpServerName,mcpServerUniqueName,url,scope, andaudiencefor each configured MCP serverChanges
src/Microsoft.Agents.A365.DevTools.MockToolingServer/Server.csTesting
/mcp/sse,/mcp/schema.json,/health)Related
Enables Phase 6 local testing workflow for agent development