Skip to main content
Glama
test_hevy_mcp.pyβ€’2.46 kB
""" Nightly integration test for hevy-mcp using mcp-use. This test installs hevy-mcp from npm and verifies: 1. The MCP server starts correctly 2. Tools are properly registered 3. A basic tool call works (get-workouts) """ import asyncio import os import sys from mcp_use import MCPClient async def main(): api_key = os.environ.get("HEVY_API_KEY") if not api_key: print("❌ HEVY_API_KEY environment variable not set") sys.exit(1) print("πŸ”§ Configuring hevy-mcp via pnpm dlx...") # Use pnpm dlx instead of npx - it may handle PATH better config = { "mcpServers": { "hevy": { "command": "pnpm", "args": ["dlx", "hevy-mcp"], "env": {"HEVY_API_KEY": api_key}, } } } client = MCPClient.from_dict(config) try: print("πŸš€ Starting MCP session...") await client.create_all_sessions() session = client.get_session("hevy") if session is None: print("❌ Failed to create session") sys.exit(1) print("βœ… Session created successfully") # List available tools print("πŸ“‹ Listing available tools...") tools = await session.list_tools() tool_names = [tool.name for tool in tools] print(f" Found {len(tool_names)} tools: {tool_names}") # Verify expected tools exist expected_tools = ["get-workouts", "get-routines", "get-exercise-templates"] missing_tools = [t for t in expected_tools if t not in tool_names] if missing_tools: print(f"❌ Missing expected tools: {missing_tools}") sys.exit(1) print("βœ… All expected tools are registered") # Call get-workouts tool print("πŸ‹οΈ Calling get-workouts tool...") result = await session.call_tool( name="get-workouts", arguments={"page": 1, "pageSize": 1} ) if result.content: print(f"βœ… get-workouts returned: {result.content[0].text[:200]}...") else: print( "⚠️ get-workouts returned empty content (may be expected if no workouts)" ) print("\nπŸŽ‰ All tests passed!") except Exception as e: print(f"❌ Test failed with error: {e}") sys.exit(1) finally: await client.close_all_sessions() if __name__ == "__main__": asyncio.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/chrisdoc/hevy-mcp'

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