Skip to content

[ai-agents] Fix MCP tool field mapping - #8038

Merged
trangevi merged 6 commits into
mainfrom
glharper/fix-ai-agents-mcp-tool-fields
May 7, 2026
Merged

[ai-agents] Fix MCP tool field mapping#8038
trangevi merged 6 commits into
mainfrom
glharper/fix-ai-agents-mcp-tool-fields

Conversation

@glharper

@glharper glharper commented May 4, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #8037

Preserves MCP routing fields when azd ai agent init and toolbox provisioning process MCP tool manifests. Top-level MCP url now maps to the API server_url, connection.name is preserved as the project connection id, and toolbox tools are enriched from the full configured connection set before being sent to the Foundry Toolsets API.

Details

  • Treat kind: foundry MCP connections as the existing remote connection shape instead of introducing a duplicate type.
  • Preserve explicit MCP url during YAML-to-API conversion.
  • Preserve named MCP connections as project_connection_id during YAML-to-API conversion.
  • Enrich toolbox tools from both connections and toolConnections when filling server_url and server_label.
  • Add regression coverage for sample-style MCP manifests and generic toolbox connection enrichment.

Validation

go test ./... -count=1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates MCP YAML-to-API conversion for azd ai agent init so sample-style MCP manifests keep their routing metadata when converted, especially for Foundry-backed connections.

Changes:

  • Add foundry as a recognized connection kind with a typed FoundryConnection parser shape.
  • Map top-level MCP url to API ServerURL and derive ProjectConnectionID from named MCP connections.
  • Add regression coverage for sample-style MCP manifests, including fallback from serverName to the tool name.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml.go Adds the new MCP/connection fields needed to represent sample-style Foundry manifests.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse.go Extends connection parsing to recognize foundry connections.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/map.go Updates MCP tool mapping to preserve server label, server URL, and project connection ID.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/map_test.go Adds a regression test for the new MCP manifest mapping behavior.

Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml.go Outdated
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Review may take a bit longer — reach out to @rajeshkamal5050 or @kristenwomack if you'd like to discuss prioritization.

@glharper

glharper commented May 4, 2026

Copy link
Copy Markdown
Member Author

@copilot apply changes based on the comments in this thread

…ack for ServerURL

Agent-Logs-Url: https://github.com/Azure/azure-dev/sessions/63d4b8ea-3699-4818-a5f8-58a92efac573

Co-authored-by: glharper <64209257+glharper@users.noreply.github.com>

Copilot AI commented May 4, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Done in c1233a7:

  1. McpTool.UrlMcpTool.URL (yaml.go) — follows Go initialism conventions, consistent with ServerURL.
  2. FoundryConnection.Endpoint fallback (map.go) — added endpointFromMcpConnection helper; when ServerURL is still empty after consulting tool.URL and options.serverUrl, it falls back to the FoundryConnection.Endpoint value.
  3. Regression test (map_test.go) — TestConvertYamlToolToApiTool_MCPFoundryConnectionEndpointFallback covers the connection.endpoint-only case.

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, focused fix. The data flow through ExtractToolsDefinitions -> ExtractConnectionDefinition -> convertYamlToolToApiTool is correct, and the precedence (top-level url sets initial value, options["serverUrl"] can override) is the right call.

One inline comment on naming. The bot's Url -> URL point is valid - the rest of the API layer uses ServerURL, BaseURL, etc.

Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/map.go Outdated
@wbreza

wbreza commented May 4, 2026

Copy link
Copy Markdown
Contributor

Re-Review — PR #8038 (commit c1233a7)

Recommendation: Approve

All substantive feedback from the first review has been addressed. The Url to URL naming fix, serverName precedence test, and FoundryConnection endpoint fallback logic all look correct.

Remaining nitpick: Test assertion at ~line 552 should print actual value for consistency.

Ship it. 👍

@glharper glharper changed the title Fix MCP tool field mapping for ai agents [ai-agents] Fix MCP tool field mapping for ai agents May 5, 2026
@glharper glharper changed the title [ai-agents] Fix MCP tool field mapping for ai agents [ai-agents] Fix MCP tool field mapping May 5, 2026

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incremental review of commits since my last look: both findings addressed. Url renamed to URL, and FoundryConnection removed in favor of reusing RemoteConnection (cleaner). The ServerLabel fallback logic moved to runtime enrichment in enrichToolboxFromConnections, which is the right layer for it. No new issues.

Comment thread cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse.go Outdated
@glharper

glharper commented May 6, 2026

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…s-mcp-tool-fields

Co-authored-by: glharper <64209257+glharper@users.noreply.github.com>

Copilot AI commented May 6, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merged origin/main into the branch in 4b31b68. The two modify/delete conflicts (testdata/mcp-tools-agent.yaml and tests/samples/githubMcpAgent/agent.yaml) were resolved by accepting the deletions from main (both removed in #8040). All tests pass.

@trangevi
trangevi enabled auto-merge (squash) May 6, 2026 23:24
@glharper

glharper commented May 7, 2026

Copy link
Copy Markdown
Member Author

/check-enforcer override

@trangevi
trangevi merged commit b43e5a6 into main May 7, 2026
21 of 22 checks passed
Copilot AI added a commit that referenced this pull request May 21, 2026
* Fix MCP tool field mapping

* Fix McpTool.Url field naming and add FoundryConnection.Endpoint fallback for ServerURL

Agent-Logs-Url: https://github.com/Azure/azure-dev/sessions/63d4b8ea-3699-4818-a5f8-58a92efac573

Co-authored-by: glharper <64209257+glharper@users.noreply.github.com>

* Address MCP connection enrichment feedback

* remove ConnectionKindFoundry

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: therealjohn <1501196+therealjohn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ai-agents] MCP tools initialized without server_url or connection id

6 participants