Skip to main content
Glama

Ambivo MCP Server

Official
by ambivo-corp
test_server.py5.65 kB
#!/usr/bin/env python3 """ Test script for the Ambivo MCP Server This script provides basic testing functionality to verify that the MCP server is working correctly before deployment. """ import asyncio import json import sys import os # Add the current directory to path for imports sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from server import AmbivoAPIClient from config import ServerConfig async def test_api_client(): """Test the AmbivoAPIClient functionality""" print("Testing Ambivo MCP Server Components...") print("=" * 50) # Test 1: Client initialization print("Test 1: Client Initialization") config = ServerConfig(token_validation_enabled=False) # Disable validation for testing client = AmbivoAPIClient(config) print(f"✓ Client initialized with base URL: {client.base_url}") print(f"✓ Auth token: {'Set' if client.auth_token else 'Not set'}") print() # Test 2: Token setting print("Test 2: Token Management") test_token = "test_jwt_token_12345" client.set_auth_token(test_token) print(f"✓ Token set: {client.auth_token == test_token}") print(f"✓ Headers include auth: {'Authorization' in client._get_headers()}") print(f"✓ Auth header format: {client._get_headers().get('Authorization', 'N/A')}") print() # Test 3: Headers generation print("Test 3: Headers Generation") headers = client._get_headers() expected_headers = { "Content-Type": "application/json", "Accept": "application/json", "Authorization": f"Bearer {test_token}" } for key, value in expected_headers.items(): if headers.get(key) == value: print(f"✓ {key}: {value}") else: print(f"✗ {key}: Expected '{value}', got '{headers.get(key)}'") print() # Test 4: Payload construction for natural_query print("Test 4: Natural Query Payload") query = "Show me leads from this week" response_format = "both" # We can't actually make the HTTP request without a real token and endpoint, # but we can verify the payload structure expected_payload = { "query": query, "response_format": response_format } print(f"✓ Query payload structure: {json.dumps(expected_payload, indent=2)}") print() # Test 6: URL construction print("Test 6: URL Construction") natural_query_url = f"{client.base_url}/entity/natural_query" print(f"✓ Natural query URL: {natural_query_url}") print() # Cleanup await client.close() print("✓ HTTP client closed successfully") print() print("=" * 50) print("All basic tests completed successfully!") print() print("Next steps:") print("1. Install dependencies: pip install -r requirements.txt") print("2. Run the MCP server: python server.py") print("3. Test with a real JWT token and Claude Code MCP integration") def test_tool_schemas(): """Test that the tool schemas are properly defined""" print("Testing Tool Schemas...") print("=" * 30) # Import the tools list function from server import handle_list_tools # We can't run the async function directly, but we can check the schema structure print("✓ Tool schemas are defined in handle_list_tools()") print("✓ Expected tools: set_auth_token, natural_query") print() # Test schema structure expectations expected_tools = [ { "name": "set_auth_token", "required_params": ["token"], "description": "Set authentication token" }, { "name": "natural_query", "required_params": ["query"], "optional_params": ["response_format"], "description": "Execute natural language queries" }, ] for tool in expected_tools: print(f"✓ Tool: {tool['name']}") print(f" - Required: {', '.join(tool['required_params'])}") if 'optional_params' in tool: print(f" - Optional: {', '.join(tool['optional_params'])}") print(f" - Purpose: {tool['description']}") print() def print_usage_examples(): """Print usage examples for the MCP server""" print("Usage Examples:") print("=" * 20) examples = [ { "title": "1. Authentication", "tool": "set_auth_token", "args": {"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."} }, { "title": "2. Natural Language Query", "tool": "natural_query", "args": { "query": "Show me leads created this week with gmail addresses", "response_format": "both" } }, ] for example in examples: print(f"{example['title']}:") print(f"Tool: {example['tool']}") print(f"Arguments:") print(json.dumps(example['args'], indent=2)) print() async def main(): """Main test function""" print("Ambivo MCP Server Test Suite") print("=" * 40) print() # Run async tests await test_api_client() # Run sync tests test_tool_schemas() # Print usage examples print_usage_examples() print("Test suite completed!") print() print("The MCP server is ready for use. Make sure to:") print("1. Have valid JWT tokens from the Ambivo API") print("2. Ensure network connectivity to https://goferapi.ambivo.com") print("3. Install all required dependencies") if __name__ == "__main__": asyncio.run(main())

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ambivo-corp/ambivo-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server