File size: 2,509 Bytes
85d69fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
"""

Simple test script for Gemini MCP Server API

Run this after starting the server to verify it's working

"""

import requests
import json
import time

# Server configuration
BASE_URL = "http://localhost:8000"
AUTH_TOKEN = "test-token"  # Replace with actual token

def test_endpoint(endpoint, method="GET", data=None):
    """Test a single endpoint"""
    url = f"{BASE_URL}{endpoint}"
    headers = {
        "Content-Type": "application/json",
        "x-mcp-auth": AUTH_TOKEN
    }
    
    try:
        if method == "POST":
            response = requests.post(url, headers=headers, json=data, timeout=30)
        else:
            response = requests.get(url, timeout=10)
            
        print(f"βœ… {method} {endpoint}: {response.status_code}")
        
        if response.status_code == 200:
            result = response.json()
            print(f"   Response: {json.dumps(result, indent=2)[:200]}...")
        else:
            print(f"   Error: {response.text}")
            
        return response.status_code == 200
        
    except requests.exceptions.RequestException as e:
        print(f"❌ {method} {endpoint}: Connection error - {str(e)}")
        return False

def main():
    """Run all tests"""
    print("πŸ§ͺ Testing Gemini MCP Server API...")
    print(f"🌐 Server: {BASE_URL}")
    print("-" * 50)
    
    tests = [
        ("Root endpoint", "/", "GET"),
        ("Health check", "/mcp/health", "GET"),
        ("Version info", "/mcp/version", "GET"),
        ("Capabilities", "/mcp/capabilities", "GET"),
    ]
    
    # Test basic endpoints
    for name, endpoint, method in tests:
        print(f"\nπŸ” Testing {name}...")
        test_endpoint(endpoint, method)
    
    # Test process endpoint
    print(f"\nπŸ” Testing MCP Process...")
    test_data = {
        "query": "Hello, can you help me with my account?",
        "user_id": "test_user_123",
        "priority": "normal",
        "mcp_version": "1.0"
    }
    test_endpoint("/mcp/process", "POST", test_data)
    
    # Test batch endpoint
    print(f"\nπŸ” Testing MCP Batch...")
    batch_data = {
        "queries": ["How do I reset my password?", "What are your business hours?"],
        "user_id": "test_user_123",
        "mcp_version": "1.0"
    }
    test_endpoint("/mcp/batch", "POST", batch_data)
    
    print("\nπŸŽ‰ API testing complete!")

if __name__ == "__main__":
    main()