CoolFace
Apppublic

creativesar/taskflow

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
test_mcp_with_openrouter.py59 linesDownload Raw Back to root
1"""2Test MCP tools with OpenRouter API3"""4import asyncio5import os6from dotenv import load_dotenv7 8load_dotenv()9 10async def test_mcp_tools():11    """Test that MCP tools work with OpenRouter"""12    from agent import run_agent13 14    print("[TEST] Testing MCP tools with OpenRouter...")15    print(f"[MODEL] {os.getenv('AI_MODEL')}")16    print()17 18    # Test 1: Add task19    print("[TEST 1] Adding a task...")20    result = await run_agent(21        user_message="Add a task: Test OpenRouter integration",22        conversation_history=[]23    )24 25    if result["error"]:26        print(f"[ERROR] {result['error']}")27        return False28 29    print(f"[RESPONSE] {result['response']}")30    print(f"[TOOLS] {len(result['tool_calls'])} tool(s) called")31    if result['tool_calls']:32        for call in result['tool_calls']:33            print(f"  - {call}")34    print()35 36    # Test 2: List tasks37    print("[TEST 2] Listing tasks...")38    result = await run_agent(39        user_message="Show me my tasks",40        conversation_history=[]41    )42 43    print(f"[RESPONSE] {result['response']}")44    print(f"[TOOLS] {len(result['tool_calls'])} tool(s) called")45    print()46 47    print("[SUCCESS] All tests passed!")48    return True49 50if __name__ == "__main__":51    # Note: This test requires a valid user_id in the database52    # The MCP tools need user_id parameter53    print("[NOTE] This test will fail if user_id is not in database")54    print("[NOTE] Use the actual chat API endpoint for full testing")55    print()56 57    success = asyncio.run(test_mcp_tools())58    exit(0 if success else 1)59