mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-08-16 05:50:21 +02:00
Refactor stdio implementation to use McpSession class.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user