#!/usr/bin/env python3
"""
Verify all 14 tools are available in the jmeter-mcp-server package
"""

import sys
import asyncio

# Set UTF-8 encoding for Windows
if sys.platform == "win32":
    import io
    sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

from autogen_ext.models.openai import AzureOpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
from autogen_agentchat.agents import AssistantAgent

model_client = AzureOpenAIChatCompletionClient(
    model="gpt-4.1-nano",
    api_version="2024-12-01-preview",
    azure_endpoint="https://agent-gallery108.openai.azure.com/",
    api_key="FfMrurWuud7oU0LFBc2hbtHCJsrcASg3DhQWs0i8qk34HZjQP9ojJQQJ99CAACfhMk5XJ3w3AAAAACOGxnqu",
)

async def main():
    """Test the JMeter MCP Server and verify all tools"""
    print("="*70)
    print("JMeter MCP Server v2.0.1 - Tool Verification")
    print("="*70)
    
    python_exe = sys.executable
    print(f"\nUsing Python: {python_exe}")
    
    server_params = StdioServerParams(
        command=python_exe,
        args=["-m", "jmeter_mcp.cli"]
    )
    
    print(f"Server Command: {python_exe} -m jmeter_mcp.cli")
    
    async with McpWorkbench(server_params) as workbench:
        agent = AssistantAgent(
            name="tool_verifier",
            model_client=model_client,
            workbench=workbench,
            system_message="You are verifying JMeter MCP tools. List all available tools.",
        )
        
        print("\n[*] Connecting to MCP server and listing tools...")
        result = await agent.run(task="List all available tools and verify there are at least 14 tools")
        
        print("\n[*] Server Response:")
        print("="*70)
        final_message = result.messages[-1]
        print(final_message.content)
        print("="*70)

if __name__ == "__main__":
    asyncio.run(main())
