Skip to content

The agent engineering platform.

feat(anthropic): support mcp_toolset in bind_tools (#34284)

ccurme5350967ddc35
diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py
index 15c1563d47..9a5af138f8 100644
--- a/libs/partners/anthropic/langchain_anthropic/chat_models.py
+++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py
@@ -154,6 +154,7 @@ def _is_builtin_tool(tool: Any) -> bool:
"web_search_",
"web_fetch_",
"code_execution_",
+ "mcp_toolset",
"memory_",
"tool_search_",
]
diff --git a/libs/partners/anthropic/tests/cassettes/test_remote_mcp.yaml.gz b/libs/partners/anthropic/tests/cassettes/test_remote_mcp.yaml.gz
index 7bc6b91659..e9cacc8341 100644
Binary files a/libs/partners/anthropic/tests/cassettes/test_remote_mcp.yaml.gz and b/libs/partners/anthropic/tests/cassettes/test_remote_mcp.yaml.gz differ
diff --git a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py
index ee941fa24b..7f0856121e 100644
--- a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py
+++ b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py
@@ -1801,18 +1801,15 @@ def test_remote_mcp(output_version: Literal["v0", "v1"]) -> None:
"type": "url",
"url": "https://mcp.deepwiki.com/mcp",
"name": "deepwiki",
- "tool_configuration": {"enabled": True, "allowed_tools": ["ask_question"]},
"authorization_token": "PLACEHOLDER",
},
]
llm = ChatAnthropic(
model="claude-sonnet-4-5-20250929", # type: ignore[call-arg]
- betas=["mcp-client-2025-04-04"],
mcp_servers=mcp_servers,
- max_tokens=10_000, # type: ignore[call-arg]
output_version=output_version,
- )
+ ).bind_tools([{"type": "mcp_toolset", "mcp_server_name": "deepwiki"}])
input_message = {
"role": "user",