Skip to main content
Glama

Weather MCP Server

by gmailhasan
test-mcp-curl.sh1.92 kB
#!/bin/bash # Script to interact with the Weather MCP Server via curl SERVER_URL="http://localhost:3000/mcp" echo "📋 Step 1: Initialize MCP Session" echo "==================================" # Initialize session and capture the session ID from the response header RESPONSE=$(curl -i -X POST $SERVER_URL \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": { "name": "curl-client", "version": "1.0.0" } } }' 2>&1) # Extract session ID from the Mcp-Session-Id header SESSION_ID=$(echo "$RESPONSE" | grep -i "mcp-session-id:" | awk '{print $2}' | tr -d '\r') if [ -z "$SESSION_ID" ]; then echo "❌ Failed to get session ID" echo "$RESPONSE" exit 1 fi echo "✅ Session initialized: $SESSION_ID" echo "" echo "📋 Step 2: List Available Tools" echo "================================" # List tools using the session ID curl -X POST $SERVER_URL \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Mcp-Session-Id: $SESSION_ID" \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/list" }' | jq '.' echo "" echo "" echo "🌤️ Step 3: Call get_weather Tool (Sammamish, WA)" echo "==================================================" # Call the weather tool curl -X POST $SERVER_URL \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Mcp-Session-Id: $SESSION_ID" \ -d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "get_weather", "arguments": { "latitude": 47.6162, "longitude": -122.0356 } } }' | jq '.result.content[0].text' -r | head -20 echo "" echo "✅ Done!"

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/gmailhasan/mcpexample'

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