Test executing an MCP tool if available (memory server).
()
| 446 | |
| 447 | @pytest.mark.asyncio |
| 448 | async def test_mcp_tool_execution(): |
| 449 | """Test executing an MCP tool if available (memory server).""" |
| 450 | print("\n=== Testing MCP Tool Execution ===") |
| 451 | |
| 452 | try: |
| 453 | tools = await load_mcp_tools_async("mini_agent/config/mcp.json") |
| 454 | |
| 455 | if not tools: |
| 456 | print("⚠️ No MCP tools loaded, skipping execution test") |
| 457 | pytest.skip("No MCP tools available") |
| 458 | return |
| 459 | |
| 460 | # Try to find and test create_entities (from memory server) |
| 461 | create_tool = None |
| 462 | for tool in tools: |
| 463 | if tool.name == "create_entities": |
| 464 | create_tool = tool |
| 465 | break |
| 466 | |
| 467 | if create_tool: |
| 468 | print(f"Testing: {create_tool.name}") |
| 469 | try: |
| 470 | result = await create_tool.execute( |
| 471 | entities=[ |
| 472 | { |
| 473 | "name": "test_entity", |
| 474 | "entityType": "test", |
| 475 | "observations": ["Test observation for pytest"], |
| 476 | } |
| 477 | ] |
| 478 | ) |
| 479 | assert result.success, f"Tool execution should succeed: {result.error}" |
| 480 | print(f"✅ Tool execution successful: {result.content[:100]}") |
| 481 | except Exception as e: |
| 482 | pytest.fail(f"Tool execution failed: {e}") |
| 483 | else: |
| 484 | print("⚠️ create_entities tool not found, skipping execution test") |
| 485 | pytest.skip("create_entities tool not available") |
| 486 | |
| 487 | finally: |
| 488 | await cleanup_mcp_connections() |
| 489 | |
| 490 | |
| 491 | @pytest.mark.asyncio |
no test coverage detected