Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/Microsoft.Agents.A365.DevTools.MockToolingServer/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static async Task Start(string[] args)

// Log that MCP is mapped
logger.LogInformation("MCP endpoints mapped: /mcp/sse, /mcp/schema.json");
logger.LogInformation("Gateway endpoint mapped: /agents/{{agentInstanceId}}/mcpServers");

// Optional minimal health endpoint for quick check
app.MapGet("/health", () => Results.Ok(new { status = "ok", mcp = "/mcp", mock = "/mcp-mock" }));
Expand Down Expand Up @@ -205,6 +206,39 @@ public static async Task Start(string[] args)
}
});

// ===================== GATEWAY ENDPOINT =====================
// Platform gateway endpoint that agents use to discover MCP servers
// This endpoint returns the list of available MCP servers for an agent instance
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}"
}).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);
}
});

logger.LogInformation("Starting MCP server... Watch for tool calls in the logs!");

await app.RunAsync();
Expand Down
Loading