Skip to content

Python: Fix claw step 3 Foundry Toolbox connection for mcp 2.x - #9597

Draft
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-claw-step03-mcp2
Draft

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-claw-step03-mcp2

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

Since the MCP 2.x migration (#9236), step 3 of the "build your own claw" harness sample cannot connect to a Foundry Toolbox. _connect_foundry_toolbox() unpacks three values from streamable_http_client, but mcp 2.x yields (read, write), so it fails with ValueError: not enough values to unpack (expected 3, got 2) whenever FOUNDRY_TOOLBOX_ENDPOINT is set. Details in #9594.

Description & Review Guide

  • What are the major changes?
    • read, write = await stack.enter_async_context(streamable_http_client(...)).
    • import httpx2 as httpx, and the PEP 723 dependency httpx becomes httpx2. mcp 2.x types http_client as httpx2.AsyncClient, and the declarative invoke_foundry_toolbox_mcp sample already uses this import. httpx2 keeps the Auth / AsyncClient / Timeout API, so _ToolboxAuth is unchanged.
  • What is the impact of these changes? Sample only. Step 3 can open its Foundry Toolbox MCP session again.
  • What do you want reviewers to focus on? Nothing special.

Verified by running the sample's own _connect_foundry_toolbox() against a local mcp 2.3.0 MCPServer over streamable HTTP, with the bearer-token provider stubbed:

result
main ValueError: not enough values to unpack (expected 3, got 2)
this PR session initializes; list_tools() returns the server's tool

Pyright on the file goes from 2 errors to 0. ruff check and ruff format --check pass.

Related Issue

Fixes #9594

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find the breakage, implement the fix, build the local MCP server verification, and draft this description and the linked issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

mcp 2.x's streamable_http_client yields (read, write) instead of
(read, write, get_session_id), so the three-way unpack raised ValueError
whenever FOUNDRY_TOOLBOX_ENDPOINT was set. Also build the client with
httpx2, which is the type mcp 2.x accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 22, 2026 12:54
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 22, 2026

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.

🟢 Approval recommended

The narrow sample-only changes address the reported compatibility failure consistently, with no blocking issues identified.

No open issues 🎉

What changed in this PR

Fixes the step 3 “build your own claw” sample’s Foundry Toolbox connection after the MCP 2.x migration, addressing #9594.

Changes:

  • Updates the inline dependency and HTTP client import to httpx2.
  • Unpacks the two transport streams returned by MCP 2.x, leaving authentication and session lifecycle unchanged.
File Description
python/​samples/​02-agents/​harness/​build_your_own_claw/​claw_step03_scaling_capabilities.py Aligns the HTTP client and transport unpacking with MCP 2.x.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 53f12fe8 Deployed Oct 22, 2026 by 1aifanatic via team_check #7244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Claw step 3 sample fails to connect to Foundry Toolbox with mcp 2.x

2 participants