Skip to main content
Glama

MCP Self-Learning Server

test-python-client.py•5.53 kB
#!/usr/bin/env python3 """ Test script for Python Client Library (Claudia Integration) """ import sys import asyncio import json from pathlib import Path # Add lib directory to path sys.path.insert(0, str(Path(__file__).parent / 'lib')) from self_learning_client import SelfLearningClient async def test_python_client(): print("šŸ Testing Python Client Library...\n") # Initialize client client = SelfLearningClient(base_url="http://localhost:8765") try: # Test connection print("1. Testing connection...") connected = await client.connect() print(f" āœ… Connected: {connected}\n") # Test health check print("2. Testing health check...") health = await client.get_health() print(f" āœ… Health: {health['status']}") print(f" šŸ“Š Uptime: {round(health['uptime'] / 1000)}s\n") # Test voice interaction analysis print("3. Testing voice interaction analysis...") user_input = "What is the weather like today?" assistant_output = "Today will be sunny with a high of 75°F" context = { 'intent': 'weather_query', 'confidence': 0.95, 'location': 'test_location', 'time': '2024-08-30T00:00:00Z' } result = await client.analyze_voice_interaction(user_input, assistant_output, context, True) print(f" āœ… Pattern ID: {result['patternId'][:8]}...") print(f" šŸŽÆ Intent: {context['intent']}") print(f" šŸ“Š Confidence: {context['confidence']}\n") # Test conversation improvement print("4. Testing conversation improvement...") conversation = [ {'role': 'user', 'content': 'Hello Claudia'}, {'role': 'assistant', 'content': 'Hello! How can I help you today?'}, {'role': 'user', 'content': 'What time is it?'}, {'role': 'assistant', 'content': 'I don\'t have access to the current time, but I can help you with other information.'} ] improvement = await client.get_conversation_improvement(conversation) print(f" āœ… Suggestions count: {len(improvement.get('suggestions', []))}") if improvement.get('suggestions'): print(f" šŸ’” First suggestion: {improvement['suggestions'][0]['description'][:50]}...") print() # Test intent learning print("5. Testing intent learning...") intent_data = { 'utterance': 'Turn on the living room lights', 'intent': 'smart_home_control', 'entities': [ {'type': 'device', 'value': 'lights'}, {'type': 'location', 'value': 'living room'}, {'type': 'action', 'value': 'turn on'} ], 'success': True } intent_result = await client.learn_intent_pattern(intent_data) print(f" āœ… Intent pattern learned: {intent_result['pattern_id'][:8]}...") print(f" šŸ  Intent: {intent_data['intent']}") print(f" šŸ” Entities: {len(intent_data['entities'])}\n") # Test batch voice analysis print("6. Testing batch voice analysis...") voice_interactions = [ {'intent': 'music_play', 'input': 'Play some jazz music', 'response': 'Playing jazz playlist', 'success': True}, {'intent': 'timer_set', 'input': 'Set a timer for 10 minutes', 'response': 'Timer set for 10 minutes', 'success': True}, {'intent': 'unknown', 'input': 'Blahblah random text', 'response': 'I didn\'t understand that', 'success': False} ] batch_results = await client.batch_analyze_voice(voice_interactions) success_count = sum(1 for r in batch_results if r.get('success')) print(f" āœ… Batch analysis: {success_count}/{len(batch_results)} successful\n") # Test insights print("7. Testing insights...") insights = await client.get_insights() metrics = insights['insights']['metrics'] print(f" āœ… Total interactions: {metrics['totalInteractions']}") print(f" šŸ“Š Learning cycles: {metrics['learningCycles']}") print(f" 🧠 Knowledge items: {insights['insights']['knowledgeItems']}\n") # Test voice session print("8. Testing voice session...") session_id = f"claudia-session-{int(asyncio.get_event_loop().time())}" session_data = { 'session_id': session_id, 'interactions': [ {'intent': 'greeting', 'input': 'Hi Claudia', 'response': 'Hello!', 'success': True}, {'intent': 'weather', 'input': 'Weather today?', 'response': 'Sunny, 72°F', 'success': True} ], 'user_satisfaction': 0.9, 'total_duration': 45.2 } session_result = await client.analyze_voice_session(session_data) print(f" āœ… Session analyzed: {session_result['session_id'][:20]}...") print(f" šŸ‘„ User satisfaction: {session_data['user_satisfaction']}") print(f" ā±ļø Duration: {session_data['total_duration']}s\n") print("āœ… All Python client tests passed!\n") except Exception as error: print(f"āŒ Python client test failed: {error}") sys.exit(1) finally: await client.close() if __name__ == "__main__": asyncio.run(test_python_client())

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/saralegui-solutions/mcp-self-learning-server'

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