Python: Show more authentication methods in Foundry Toolbox MCP#5719
Draft
TaoChenOSU wants to merge 2 commits intomainfrom
Draft
Python: Show more authentication methods in Foundry Toolbox MCP#5719TaoChenOSU wants to merge 2 commits intomainfrom
TaoChenOSU wants to merge 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
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 anhttpx.Authimplementation. - Updated samples to instantiate
MCPStreamableHTTPToolwith anhttpx.AsyncClientand 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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