Skip to main content
Glama
aiforhumans

Local Utilities MCP Server

by aiforhumans
test.py3.9 kB
#!/usr/bin/env python3 """ Simple test script for the local-utils MCP server. This script verifies that the server can be imported successfully. """ import sys import os # Add the current directory to the path so we can import our server sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) def test_server(): """Test that the MCP server can be imported.""" print("🧪 Testing Local Utilities MCP Server\n") try: # Import the server from server import mcp print("✅ Server imported successfully!") print(f" Server name: {mcp.name}") # Test individual function logic (without FastMCP wrapper) print("\n🔧 Testing core function logic:") # Temperature conversion logic def convert_temp_logic(value: float, unit: str) -> str: if unit == "C": return f"{(value * 9/5) + 32:.2f} °F" if unit == "F": return f"{(value - 32) * 5/9:.2f} °C" raise ValueError("unit must be C or F") print(f" ✅ 25°C = {convert_temp_logic(25, 'C')}") print(f" ✅ 77°F = {convert_temp_logic(77, 'F')}") # Base64 encoding logic import base64 text = "Hello, World!" encoded = base64.b64encode(text.encode('utf-8')).decode('utf-8') decoded = base64.b64decode(encoded).decode('utf-8') print(f" ✅ Base64 encode '{text}': {encoded}") print(f" ✅ Base64 decode back: {decoded}") # Hash calculation logic import hashlib hash_func = hashlib.sha256() hash_func.update(text.encode('utf-8')) hash_result = hash_func.hexdigest() print(f" ✅ SHA256 of '{text}': {hash_result}") # Text stats logic test_text = "Hello world!\nThis is a test.\nIt has multiple lines." lines = test_text.split('\n') words = test_text.split() print(f" ✅ Text stats for sample text:") print(f" Lines: {len(lines)}, Words: {len(words)}, Characters: {len(test_text)}") # Password generation logic import random import string length = 12 characters = string.ascii_letters + string.digits password = ''.join(random.choice(characters) for _ in range(length)) print(f" ✅ Generated sample password: {password}") # Date/time logic import datetime now = datetime.datetime.now() print(f" ✅ Current time: {now.strftime('%Y-%m-%d %H:%M:%S')}") print("\n🎉 All core functions are working correctly!") print("\n📋 Available Tools in this MCP Server:") tools = [ "convert_temp - Convert between °C and °F", "read_file - Read contents of a text file", "write_file - Write content to a file", "list_directory - List files and directories", "calculate_hash - Calculate MD5, SHA1, SHA256 hashes", "base64_encode_decode - Encode/decode Base64", "get_datetime_info - Get current date and time", "text_stats - Count words, characters, lines", "generate_password - Generate secure passwords" ] for i, tool in enumerate(tools, 1): print(f" {i}. {tool}") print(f"\n✅ Server ready with {len(tools)} tools!") except Exception as e: print(f"❌ Error: {e}") import traceback traceback.print_exc() return False return True if __name__ == "__main__": success = test_server() if success: print("\n🚀 Your MCP server is ready to use!") print(" To run the server: python server.py") print(" Use the URL in n.txt to connect with LM Studio") sys.exit(0 if success else 1)

Latest Blog Posts

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/aiforhumans/local-utils-mcp'

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