# Example 14: AI Backends + MCP Server Integration
# Demonstrates using auto-detected AI backends with MCP servers for agent tool use
print("=== AI + MCP Integration Demo ===")
print("")
# Part 1: Detect AI Backends
print("1. AI Backend Detection:")
let backends = ai_backends()
let selected_backend = ai_detect()
print(" Available backends: " + len(backends))
print(" Auto-selected: " + selected_backend)
print("")
# Part 2: Detect MCP Servers
print("2. MCP Server Detection:")
let mcp_servers = mcp_servers()
print(" Available MCP servers: " + len(mcp_servers))
print("")
# Part 3: Show what's available
print("3. Integration Capabilities:")
print("")
print(" AI Backends: Ready")
print(" MCP Servers: Detection ready")
print(" Common MCP ports: 3001-3005, 8080-8081")
print("")
# Part 4: Usage Examples
print("4. Usage Patterns:")
print("")
print(" A. Simple AI query with auto-detected backend:")
print(" let response = ai(ai_detect(), \"What is 2+2?\")")
print("")
print(" B. Agent with AI backend (no tools):")
print(" let simple_agent = agent(")
print(" \"Answer questions\",")
print(" ai_detect(),")
print(" []")
print(" )")
print("")
print(" C. Agent with AI backend + MCP tools:")
print(" let fs_server = mcp_detect(\"http://localhost:3001\")")
print(" let agent_with_tools = agent(")
print(" \"File analyzer\",")
print(" ai_detect(),")
print(" [")
print(" {tool: \"read_file\", server: fs_server.endpoint},")
print(" {tool: \"list_dir\", server: fs_server.endpoint}")
print(" ]")
print(" )")
print("")
print(" D. Multi-backend agent swarm:")
print(" let agents = [")
print(" {id: \"fast\", model: \"ollama:llama3.2:3b\"},")
print(" {id: \"smart\", model: \"ollama:llama3.1:70b\"},")
print(" {id: \"cloud\", model: \"openai:gpt-4o\"}")
print(" ]")
print("")
# Part 5: Getting Started
print("5. Getting Started:")
print("")
print(" Step 1: Start an MCP server")
print(" python mcp_server.py --port 3001")
print("")
print(" Step 2: Detect it")
print(" let server = mcp_detect(\"http://localhost:3001\")")
print("")
print(" Step 3: Use it with an AI agent")
print(" agent(\"goal\", ai_detect(), server.tools)")
print("")
print("✓ AI + MCP integration ready!")
print("")
print("Next steps:")
print(" - Start MCP servers for tool access")
print(" - Use ai_detect() for automatic backend selection")
print(" - Combine both for powerful AI agents with tools")