Skip to main content
Glama

MCP Agent Tracker

by Big0290
start_stdio_server.py•3.4 kB
#!/usr/bin/env python3 """ Start MCP Server in stdio mode for interactive communication This allows the MCP server to communicate via standard input/output """ import asyncio import sys import os import signal from pathlib import Path # Add current directory to path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) async def start_stdio_server(): """Start the MCP server in stdio mode""" try: print("šŸš€ Starting MCP Server in stdio mode...", file=sys.stderr) # Import the main MCP server and ensure tools are registered from main import mcp print(f"āœ… MCP server loaded: {mcp.name}", file=sys.stderr) # Ensure tools are properly registered tools = getattr(mcp._tool_manager, '_tools', {}) print(f"šŸ”§ Available tools: {len(tools)}", file=sys.stderr) # List all available tools for tool_name in tools.keys(): print(f" šŸ“Œ {tool_name}", file=sys.stderr) # Check if the server has stdio support if hasattr(mcp, 'run_stdio_async'): print("āœ… Starting stdio server with async support...", file=sys.stderr) print("šŸ”Œ Server is now listening for stdio communication...", file=sys.stderr) print("šŸ’” You can now connect from Cursor or other MCP clients", file=sys.stderr) await mcp.run_stdio_async() elif hasattr(mcp, 'run_stdio'): print("āœ… Starting stdio server with sync support...", file=sys.stderr) print("šŸ”Œ Server is now listening for stdio communication...", file=sys.stderr) print("šŸ’” You can now connect from Cursor or other MCP clients", file=sys.stderr) mcp.run_stdio() else: print("āŒ MCP server doesn't support stdio mode", file=sys.stderr) print("Available methods:", file=sys.stderr) for attr in dir(mcp): if 'stdio' in attr.lower() or 'run' in attr.lower(): print(f" - {attr}", file=sys.stderr) return False return True except Exception as e: print(f"āŒ Error starting stdio server: {e}", file=sys.stderr) import traceback traceback.print_exc(file=sys.stderr) return False def signal_handler(signum, frame): """Handle shutdown signals gracefully""" print(f"\nšŸ›‘ Received signal {signum}, shutting down...", file=sys.stderr) sys.exit(0) if __name__ == "__main__": # Set up signal handlers signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) print("šŸ”Œ MCP Server stdio mode", file=sys.stderr) print("=" * 40, file=sys.stderr) try: # Start the stdio server success = asyncio.run(start_stdio_server()) if success: print("āœ… MCP Server stdio mode started successfully", file=sys.stderr) else: print("āŒ Failed to start MCP Server stdio mode", file=sys.stderr) sys.exit(1) except KeyboardInterrupt: print("\nšŸ›‘ Interrupted by user", file=sys.stderr) sys.exit(0) except Exception as e: print(f"āŒ Unexpected error: {e}", file=sys.stderr) import traceback traceback.print_exc(file=sys.stderr) sys.exit(1)

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/Big0290/MCP'

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