Skip to content

Python: Show more authentication methods in Foundry Toolbox MCP#5719

Draft
TaoChenOSU wants to merge 2 commits intomainfrom
feature/add-more-foundry-toolbox-mcp-auth-methods-in-sample
Draft

Python: Show more authentication methods in Foundry Toolbox MCP#5719
TaoChenOSU wants to merge 2 commits intomainfrom
feature/add-more-foundry-toolbox-mcp-auth-methods-in-sample

Conversation

@TaoChenOSU
Copy link
Copy Markdown
Contributor

@TaoChenOSU TaoChenOSU commented May 8, 2026

Motivation and Context

Foundry toolbox supports multiple authentication scenarios for MCPs: https://github.com/microsoft-foundry/foundry-samples/tree/main/samples/python/toolbox/azd#supported-scenarios. Update our sample to show and verify that we support all.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU TaoChenOSU self-assigned this May 8, 2026
Copilot AI review requested due to automatic review settings May 8, 2026 18:45
@TaoChenOSU TaoChenOSU added the samples Issue relates to the samples label May 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 the Foundry-hosted agent samples to demonstrate more Foundry Toolbox/MCP authentication scenarios and to use the newer Toolbox endpoint + request auth plumbing.

Changes:

  • Switched toolbox endpoint construction from /toolsets/... to /toolboxes/... and moved request auth to an httpx.Auth implementation.
  • Updated samples to instantiate MCPStreamableHTTPTool with an httpx.AsyncClient and expose more managed tools (e.g., web_search).
  • Expanded the toolbox sample manifest/README to document and configure multiple MCP authentication methods (no-auth, PAT, OAuth2, agent identity, user Entra token).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
python/samples/04-hosting/foundry-hosted-agents/responses/06_files/main.py Uses httpx.Auth + AsyncClient for toolbox calls and updates toolbox endpoint path.
python/samples/04-hosting/foundry-hosted-agents/responses/06_files/README.md Documents the additional toolbox-provided tools used by the sample.
python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/main.py Aligns toolbox connection/auth approach with httpx and new endpoint path.
python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/agent.manifest.yaml Adds connection definitions + parameters to demonstrate multiple MCP auth methods.
python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/README.md Adds an “Authentication Methods” section describing the supported scenarios.

Comment on lines +79 to +83
http_client = httpx.AsyncClient(
auth=ToolboxAuth(token_provider),
headers={"Foundry-Features": "Toolboxes=V1Preview"},
timeout=120.0,
)
Comment on lines +51 to +55
http_client = httpx.AsyncClient(
auth=ToolboxAuth(token_provider),
headers={"Foundry-Features": "Toolboxes=V1Preview"},
timeout=120.0,
)
@@ -29,19 +28,18 @@ def _resolve_toolbox_endpoint() -> str:
return endpoint
project_endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"].rstrip("/")
toolbox_name = os.environ["TOOLBOX_NAME"]
)

toolbox = MCPStreamableHTTPTool(
name=os.environ.get("TOOLBOX_NAME", "toolbox"),
Comment on lines 29 to +31
project_endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"].rstrip("/")
toolbox_name = os.environ["TOOLBOX_NAME"]
return f"{project_endpoint}/toolsets/{toolbox_name}/mcp?api-version=v1"
return f"{project_endpoint}/toolboxes/{toolbox_name}/mcp?api-version=v1"
Comment on lines +58 to +59
name=os.environ.get("TOOLBOX_NAME", "toolbox"),
url=resolve_toolbox_endpoint(),
- name: github_pat
# `azd ai agent init -m` will prompt for this value when initializing the agent manifest
secret: true
description: GitHub Personal Access Token used to authenticate with the GitHub MCP server (press Enter if OAuth2 is used instead)
Comment on lines +94 to +96
# This MCP tool uses the GitHub MCP server with a PAT for authentication or OAuth2
server_label: github
project_connection_id: github-mcp-pat-conn # use `github-mcp-oauth-conn` for OAuth2 authentication
@github-actions github-actions Bot changed the title Show more authentication methods in Foundry Toolbox MCP Python: Show more authentication methods in Foundry Toolbox MCP May 8, 2026
@moonbox3 moonbox3 added the documentation Improvements or additions to documentation label May 8, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 83% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by TaoChenOSU's agents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python samples Issue relates to the samples

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants