Skip to main content
Glama
test_mcp_stdio.py1.8 kB
"""Test if MCP server can communicate via stdio (required by Claude Desktop)""" import sys import json # Simulate what Claude Desktop does - send initialization message def test_stdio_communication(): print("Testing stdio communication...", file=sys.stderr) # Read from stdin try: line = sys.stdin.readline() if line: print(f"Received: {line}", file=sys.stderr) try: msg = json.loads(line.strip()) print(f"Parsed JSON: {msg}", file=sys.stderr) return True except json.JSONDecodeError as e: print(f"JSON decode error: {e}", file=sys.stderr) return False else: print("No input received", file=sys.stderr) return False except Exception as e: print(f"Error: {e}", file=sys.stderr) return False if __name__ == "__main__": # Import the actual server import sys import os sys.path.insert(0, os.path.dirname(__file__)) # Try to import and check if server is ready try: from inventory_mcp_server import mcp print("Server imported successfully", file=sys.stderr) print("MCP server is ready for stdio communication", file=sys.stderr) except ImportError as e: # Handle the hyphen in filename print(f"Import error (expected): {e}", file=sys.stderr) print("This is normal - filename has hyphen", file=sys.stderr) # Try direct import import importlib.util spec = importlib.util.spec_from_file_location("server", "inventory-mcp-server.py") server_module = importlib.util.module_from_spec(spec) spec.loader.exec_module(server_module) print("Server loaded directly", file=sys.stderr)

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/Adiitiir/inventory-mcp-server'

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