Spaces:
Sleeping
Sleeping
| # client_example.py | |
| from mcp import ClientSession, StdioServerParameters | |
| import asyncio | |
| async def run(): | |
| # Start your MCP server | |
| server_params = StdioServerParameters( | |
| command="python", | |
| args=["mcp_server.py"] | |
| ) | |
| async with ClientSession(server_params) as session: | |
| await session.initialize() | |
| # Call your context-pilot tool | |
| result = await session.call_tool("context-pilot", { | |
| "msg": "How do I implement authentication in FastAPI?", | |
| "chat_history": [ | |
| {"role": "user", "content": "Tell me about Python web frameworks"}, | |
| {"role": "assistant", "content": "Flask and FastAPI are popular..."} | |
| ] | |
| }) | |
| print(result) | |
| asyncio.run(run()) |