()
| 169 | |
| 170 | |
| 171 | async def main(): |
| 172 | print("\n" + "="*60) |
| 173 | print("MyAgent Demo - Function-based + MCP Tools") |
| 174 | print("="*60) |
| 175 | |
| 176 | # Switch between different configs to test: |
| 177 | # - CONFIG: both local and remote tools |
| 178 | # - CONFIG_NO_LOCAL: only remote MCP tools |
| 179 | # - CONFIG_LOCAL_ONLY: only local function tools |
| 180 | active_config = CONFIG_LOCAL_ONLY # Change this to test different configurations |
| 181 | |
| 182 | try: |
| 183 | # Step 1: Initialize tools from config |
| 184 | print("\n" + "="*60) |
| 185 | print("TOOL INITIALIZATION") |
| 186 | print("="*60) |
| 187 | |
| 188 | tools_config = active_config.get("tools", {}) |
| 189 | |
| 190 | # Initialize local function-based tools if enabled |
| 191 | if tools_config.get("local", True): |
| 192 | print("\n[✓] Loading local function-based tools...") |
| 193 | init_tools() |
| 194 | print(" Local tools initialized successfully") |
| 195 | else: |
| 196 | print("\n[✗] Local tools DISABLED by configuration") |
| 197 | |
| 198 | # Initialize remote MCP tools if configured |
| 199 | remote_servers = tools_config.get("remote", []) |
| 200 | if remote_servers: |
| 201 | print(f"\n[✓] Found {len(remote_servers)} remote MCP server(s) in config:") |
| 202 | for server in remote_servers: |
| 203 | print(f" - {server['id']}: {server['url']}") |
| 204 | await init_mcp_tools(remote_servers=remote_servers) |
| 205 | else: |
| 206 | print("\n[✗] No remote MCP servers configured") |
| 207 | |
| 208 | # Get registry statistics |
| 209 | registry = get_registry() |
| 210 | print("\n" + "="*60) |
| 211 | print("TOOL REGISTRY STATISTICS") |
| 212 | print("="*60) |
| 213 | print(f"Total tools loaded: {registry.total_tool_count()}") |
| 214 | print(f" - Function tools: {len(registry)}") |
| 215 | print(f" - MCP tools: {registry.total_tool_count() - len(registry)}") |
| 216 | print(f"\nRegistered tool names:") |
| 217 | for name in sorted(registry.get_all_names()): |
| 218 | print(f" - {name}") |
| 219 | |
| 220 | # Step 2: Initialize model |
| 221 | print("\n" + "="*60) |
| 222 | print("MODEL & AGENT INITIALIZATION") |
| 223 | print("="*60) |
| 224 | print("\nInitializing model...") |
| 225 | model = OpenAIModel( |
| 226 | api_key=os.getenv("OPENAI_API_KEY"), |
| 227 | model_name="gpt-4o", |
| 228 | temperature=0.7 |
no test coverage detected