Skip to main content
Glama

MCP Server Demo

by bollam1818
setup_dev.py•4.22 kB
#!/usr/bin/env python3 """ Development setup script for MCP Server Demo This script helps set up the development environment for the MCP server project. """ import subprocess import sys import os from pathlib import Path def run_command(command: str, description: str) -> bool: """Run a command and return True if successful""" print(f"šŸ”„ {description}...") try: result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) print(f"āœ… {description} completed successfully") return True except subprocess.CalledProcessError as e: print(f"āŒ {description} failed: {e}") if e.stdout: print(f"Output: {e.stdout}") if e.stderr: print(f"Error: {e.stderr}") return False def check_python_version(): """Check if Python version is >= 3.10""" version = sys.version_info if version.major < 3 or (version.major == 3 and version.minor < 10): print(f"āŒ Python 3.10+ required, found {version.major}.{version.minor}") print("Please upgrade Python and try again.") return False print(f"āœ… Python {version.major}.{version.minor}.{version.micro} is compatible") return True def setup_virtual_environment(): """Create and activate virtual environment""" venv_path = Path("venv") if venv_path.exists(): print("āœ… Virtual environment already exists") return True return run_command("python3 -m venv venv", "Creating virtual environment") def install_dependencies(): """Install project dependencies""" # Determine the correct pip command based on OS if os.name == 'nt': # Windows pip_cmd = "venv\\Scripts\\pip" else: # Unix-like systems pip_cmd = "venv/bin/pip" # Upgrade pip first upgrade_pip = run_command(f"{pip_cmd} install --upgrade pip", "Upgrading pip") if not upgrade_pip: return False # Install requirements return run_command(f"{pip_cmd} install -r requirements.txt", "Installing dependencies") def create_run_scripts(): """Create convenient run scripts""" # Windows batch script windows_script = """@echo off call venv\\Scripts\\activate echo Starting MCP Server in development mode... mcp dev server.py pause """ # Unix shell script unix_script = """#!/bin/bash source venv/bin/activate echo "Starting MCP Server in development mode..." mcp dev server.py """ try: with open("run_dev.bat", "w") as f: f.write(windows_script) with open("run_dev.sh", "w") as f: f.write(unix_script) # Make shell script executable os.chmod("run_dev.sh", 0o755) print("āœ… Created run_dev.bat and run_dev.sh scripts") return True except Exception as e: print(f"āŒ Failed to create run scripts: {e}") return False def main(): """Main setup function""" print("šŸš€ Setting up MCP Server Demo development environment...\n") # Check Python version if not check_python_version(): sys.exit(1) # Setup virtual environment if not setup_virtual_environment(): print("āŒ Failed to setup virtual environment") sys.exit(1) # Install dependencies if not install_dependencies(): print("āŒ Failed to install dependencies") sys.exit(1) # Create run scripts if not create_run_scripts(): print("āš ļø Warning: Failed to create run scripts, but setup is otherwise complete") print("\nšŸŽ‰ Development environment setup complete!") print("\nNext steps:") print("1. Activate the virtual environment:") if os.name == 'nt': print(" venv\\Scripts\\activate") else: print(" source venv/bin/activate") print("\n2. Run the server in development mode:") print(" mcp dev server.py") print("\n3. Or use the convenience script:") if os.name == 'nt': print(" run_dev.bat") else: print(" ./run_dev.sh") print("\n4. To install in Claude Desktop:") print(" mcp install server.py") if __name__ == "__main__": 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/bollam1818/MCPServer'

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