Skip to main content
Glama

Model Context Provider (MCP) Server

by Mark850409
connection_check.py1.47 kB
import anyio import logging import sys from mcpcli.config import load_config from mcpcli.messages.send_initialize_message import send_initialize from mcpcli.messages.send_ping import send_ping from mcpcli.messages.send_tools_list import send_tools_list from mcpcli.transport.stdio.stdio_client import stdio_client # Configure logging logging.basicConfig( level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s', stream=sys.stderr ) async def main(): """Stripped-down script to initialize the server and send a ping.""" # Configuration values config_path = "server_config.json" server_name = "sqlite" # Load server configuration server_params = await load_config(config_path, server_name) # Establish stdio communication async with stdio_client(server_params) as (read_stream, write_stream): # Initialize the server init_result = await send_initialize(read_stream, write_stream) # check we got a result if not init_result: print("Server initialization failed") return # connected print(f"We're connected!!!") # Send a ping result = await send_ping(read_stream, write_stream) print("Ping successful" if result else "Ping failed") # get tools result = await send_tools_list(read_stream, write_stream) print(result) # Run the script if __name__ == "__main__": anyio.run(main)

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/Mark850409/20250223_mcp-client'

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