Refactor stdio implementation to use McpSession class.

This commit is contained in:
Hemang
2025-06-04 11:46:35 +02:00
committed by Hemang Sarkar
parent 6849fc7daa
commit e8106776b4
10 changed files with 290 additions and 760 deletions
@@ -1,5 +1,6 @@
"""A MCP client implementation that interacts with MCP server to make tool calls."""
import asyncio
import os
from datetime import timedelta
@@ -48,7 +49,6 @@ class MCPClient:
for key, value in metadata_keys.items():
args.append("--metadata-" + key + "=" + value)
if push_to_explorer:
args.append("--push-explorer")
args.extend(
@@ -133,7 +133,7 @@ async def run(
project_name,
server_script_path,
push_to_explorer,
metadata_keys=metadata_keys
metadata_keys=metadata_keys,
)
listed_tools = await client.session.list_tools()
if tool_name == "tools/list":
@@ -142,4 +142,6 @@ async def run(
else:
return await client.call_tool(tool_name, tool_args)
finally:
if push_to_explorer:
await asyncio.sleep(2)
await client.cleanup()