import asyncio
from mcp_use import MCPClient
async def call_tool_example():
config = {
"mcpServers": {
# Your server definitions here
}
}
client = MCPClient(config)
await client.create_all_sessions()
session = client.get_session("filesystem_server")
# Call a tool with arguments
result = await session.call_tool(
name="read_file",
arguments={
"path": "/path/to/file.txt",
"encoding": "utf-8"
}
)
# Handle the result
if result.isError:
print(f"Error: {result.content}")
else:
print(f"File content: {result.content}")
asyncio.run(call_tool_example())