MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / test_mcp_tool_execution

Function test_mcp_tool_execution

tests/test_mcp.py:448–488  ·  view source on GitHub ↗

Test executing an MCP tool if available (memory server).

()

Source from the content-addressed store, hash-verified

446
447@pytest.mark.asyncio
448async 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

Callers 1

mainFunction · 0.85

Calls 3

load_mcp_tools_asyncFunction · 0.90
cleanup_mcp_connectionsFunction · 0.90
executeMethod · 0.45

Tested by

no test coverage detected