MCPcopy Index your code
hub / github.com/SkyworkAI/DeepResearchAgent / test_direct_tool_invocation

Function test_direct_tool_invocation

tests/test_report_tool.py:26–71  ·  view source on GitHub ↗

Test the report tool directly using tcp.ainvoke

()

Source from the content-addressed store, hash-verified

24
25
26async def test_direct_tool_invocation():
27 """Test the report tool directly using tcp.ainvoke"""
28 print("\n" + "="*60)
29 print("🧪 Test 1: Direct Tool Invocation")
30 print("="*60)
31
32 # Initialize model manager (required for some tools)
33 logger.info("| 🧠 Initializing model manager...")
34 await model_manager.initialize(use_local_proxy=False)
35
36 # Initialize tools
37 logger.info("| 🛠️ Initializing tools...")
38 await tcp.initialize(["report"])
39 logger.info(f"| ✅ Tools initialized: {tcp.list()}")
40
41 # Test query
42 query = "What is the latest news about Apple stock price and market analysis?"
43
44 try:
45 # Invoke the report tool directly
46 result = await tcp.ainvoke("report", {"query": query})
47
48 print(f"\n📋 Query: {query}")
49 print("\n📄 Result:")
50 print("-" * 60)
51 if hasattr(result, 'message'):
52 print(result.message)
53 else:
54 print(result)
55 print("-" * 60)
56
57 if hasattr(result, 'extra') and result.extra:
58 print("\n📁 File Information:")
59 if 'path' in result.extra:
60 print(f" Path: {result.extra['path']}")
61 if 'absolute_path' in result.extra:
62 print(f" Absolute Path: {result.extra['absolute_path']}")
63 if 'html_length' in result.extra:
64 print(f" HTML Length: {result.extra['html_length']} characters")
65
66 print("\n✅ Direct tool invocation test completed!")
67
68 except Exception as e:
69 print(f"\n❌ Error testing report tool: {e}")
70 import traceback
71 traceback.print_exc()
72
73
74async def test_with_custom_output_path():

Callers 1

mainFunction · 0.85

Calls 4

printFunction · 0.85
infoMethod · 0.45
initializeMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected