-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinteractive_client.py
More file actions
74 lines (58 loc) · 2.13 KB
/
interactive_client.py
File metadata and controls
74 lines (58 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
Interactive MCP Client with OpenAI Integration
Allows you to chat with gpt-5-nano using all MCP server tools
"""
import os
import sys
from mcp_client import MCPOrchestrator
def main():
"""Run interactive chat session"""
print("\n" + "="*70)
print(" MCP Orchestrator - Interactive IT Support Assistant")
print("="*70)
# Get OpenAI API key from environment or prompt
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
print("\n⚠️ No OPENAI_API_KEY found in environment.")
api_key = input("Please enter your OpenAI API key: ").strip()
if not api_key:
print("❌ API key required. Exiting.")
return
# Create and initialize orchestrator
orchestrator = MCPOrchestrator()
try:
# Start all MCP servers
print("\n🚀 Initializing system...\n")
orchestrator.start_servers() # Not async - uses _run_async internally
# Get available tools
orchestrator.get_available_tools() # Not async - uses _run_async internally
# Run interactive mode
orchestrator.interactive_mode(api_key) # Not async - uses _run_async internally
except KeyboardInterrupt:
print("\n\nShutting down...")
except Exception as e:
print(f"\n❌ Error: {e}")
import traceback
traceback.print_exc()
finally:
# Clean up
orchestrator.stop_servers() # Not async - uses _run_async internally
if __name__ == "__main__":
"""
Interactive MCP client with OpenAI gpt-5-nano integration.
Set your OpenAI API key:
export OPENAI_API_KEY="sk-..."
Or the script will prompt you for it.
Example questions to try:
- "What are all the critical priority tickets?"
- "Show me customer CUST-001's information and SLA terms"
- "What's the outstanding balance for TechCorp Industries?"
- "Find KB articles about Windows BSOD issues"
- "Check warranty status for asset AST-SRV-001"
- "Show me all tickets for customer CUST-002 and their invoices"
"""
try:
main()
except KeyboardInterrupt:
print("\nExiting...")
sys.exit(0)