Description
I have used the MCPStreamableHTTPTool to build a client that connects to snowflake managed MCP server. The connection requests were going into infinite loops. Upon reviewing the code implementation of MCPTool, I realized that the code was written under the assumption that every MCP server implements the "ping" method. However, the snowflake managed MCP server doesn't implement this method.
When I make a call to load_tools, it first checks connection using _ensure_connected that in turn uses ping. When ping fails, it tries to connect again.
if we want to make use of call_tool, we must needs keep the load_tools=True while initializing. If load_tools=True, in connect method, it will try to call load_tools which in turn calls _ensure_connected that uses ping and declares that the connection is invalid and tries to reconnect using the connect method.
The following leads to an infinite loop
connect=>load_tools or load_prompts => _ensure_connected => ping fails => connect
Code Sample
import asyncio
import os
from agent_framework import MCPStreamableHTTPTool
import httpx
headers = {
"Authorization": f"Bearer {os.getenv('SNOWFLAKE_MCP_TOKEN')}",
"Content-Type": "application/json",
}
url = os.getenv("SNOWFLAKE_MCP_URL")
async_client = httpx.AsyncClient(headers=headers, base_url=url)
client = MCPStreamableHTTPTool(
name="snowflake_tool",
description="Tool to execute SQL queries against Snowflake and stream results back.",
url=url,
http_client=async_client,
)
asyncio.run(client.load_tools())
Error Messages / Stack Traces
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:agent_framework._mcp:MCP connection invalid or closed. Reconnecting...
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 200 OK"
INFO:mcp.client.streamable_http:Negotiated protocol version: 2025-11-25
INFO:httpx:HTTP Request: POST https://*************************************************************************** "HTTP/1.1 202 Accepted"
Package Versions
agent-framework-core==1.0.0rc3
Python Version
Python 3.12.10
Additional Context
I feel _ensure_connected can call the ping method. If the response is an MCPError that has "Unsupported method: ping" in its error body, it can be treated as a live connection or some other logic should be implemented here.
Description
I have used the MCPStreamableHTTPTool to build a client that connects to snowflake managed MCP server. The connection requests were going into infinite loops. Upon reviewing the code implementation of MCPTool, I realized that the code was written under the assumption that every MCP server implements the "ping" method. However, the snowflake managed MCP server doesn't implement this method.
When I make a call to load_tools, it first checks connection using _ensure_connected that in turn uses ping. When ping fails, it tries to connect again.
if we want to make use of call_tool, we must needs keep the load_tools=True while initializing. If load_tools=True, in connect method, it will try to call load_tools which in turn calls _ensure_connected that uses ping and declares that the connection is invalid and tries to reconnect using the connect method.
The following leads to an infinite loop
connect=>load_tools or load_prompts => _ensure_connected => ping fails => connect
Code Sample
import asyncio import os from agent_framework import MCPStreamableHTTPTool import httpx headers = { "Authorization": f"Bearer {os.getenv('SNOWFLAKE_MCP_TOKEN')}", "Content-Type": "application/json", } url = os.getenv("SNOWFLAKE_MCP_URL") async_client = httpx.AsyncClient(headers=headers, base_url=url) client = MCPStreamableHTTPTool( name="snowflake_tool", description="Tool to execute SQL queries against Snowflake and stream results back.", url=url, http_client=async_client, ) asyncio.run(client.load_tools())Error Messages / Stack Traces
Package Versions
agent-framework-core==1.0.0rc3
Python Version
Python 3.12.10
Additional Context
I feel _ensure_connected can call the ping method. If the response is an MCPError that has "Unsupported method: ping" in its error body, it can be treated as a live connection or some other logic should be implemented here.