demo.pyā¢2.71 kB
#!/usr/bin/env python3
"""
FastMCP Server Demonstration
Shows how to start the server and list available tools
"""
import sys
from pathlib import Path
# Add the current directory to Python path
sys.path.insert(0, str(Path(__file__).parent))
def main():
"""Main demonstration function."""
print("š FastMCP Multi-Tool Server")
print("=" * 50)
try:
# Import the server module
import server
print(f"ā Server initialized: {server.mcp.name}")
# Get the list of available tools
if hasattr(server.mcp, '_tools'):
tools = list(server.mcp._tools.keys())
print(f"\nš Available Tools ({len(tools)}):")
print("-" * 30)
tool_descriptions = {
'get_current_time': 'š Get current date and time',
'get_weather': 'š¤ļø Get weather for any city',
'create_file': 'š Create new files',
'read_file': 'š Read file contents',
'list_directory': 'š List directory contents',
'execute_command': 'š» Execute shell commands safely',
'search_files': 'š Search for text in files',
'calculate_expression': 'š§® Calculate mathematical expressions',
'get_system_info': 'āļø Get system information',
'create_temporary_file': 'š Create temporary files'
}
for i, tool in enumerate(sorted(tools), 1):
description = tool_descriptions.get(tool, 'š§ Utility tool')
print(f"{i:2d}. {description}")
print(f" Function: {tool}")
print("\n" + "=" * 50)
print("šÆ How to Use:")
print("1. Start the server: python server.py")
print("2. Configure Claude Desktop with the server")
print("3. Use the tools through Claude's interface")
print("\nš Documentation:")
print("See README.md for detailed setup and usage instructions")
print("\nš§ Configuration:")
print("- Environment file: .env")
print("- Add OpenWeatherMap API key for weather functionality")
return True
except Exception as e:
print(f"ā Error loading server: {e}")
return False
if __name__ == "__main__":
success = main()
if success:
print("\nā
Server is ready to run!")
print("\nTo start the server now, run:")
print("python server.py")
else:
print("\nā Server has issues. Check the error messages above.")
sys.exit(0 if success else 1)