Skip to main content
Glama

Weather MCP Server

by alesanabv
test.ts1.95 kB
import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; /** * Test client for the Weather MCP server */ async function testWeatherServer() { console.log('🧪 Testing Weather MCP Server\n'); const client = new Client({ name: "test-client", version: "1.0.0" }, { capabilities: {} }); const transport = new StdioClientTransport({ command: "npx", args: ["tsx", "main.ts"] }); console.log('📡 Connecting to server...'); await client.connect(transport); console.log('✅ Connected\n'); console.log('📋 Listing available tools...'); const toolsList = await client.listTools(); console.log(`Found ${toolsList.tools.length} tool(s):\n`); for (const tool of toolsList.tools) { console.log(` • ${tool.name}`); console.log(` ${tool.description}`); if (tool.inputSchema?.properties) { console.log(` Parameters:`, JSON.stringify(tool.inputSchema.properties, null, 2)); } console.log(''); } console.log('🌤️ Calling fetch-Weather with city="Bogotá"...'); const result = await client.callTool({ name: "fetch-Weather", arguments: { city: "Bogotá" } }); console.log('📬 Result:', JSON.stringify(result, null, 2)); console.log(''); console.log('🌧️ Calling fetch-Weather with city="London"...'); const result2 = await client.callTool({ name: "fetch-Weather", arguments: { city: "London" } }); console.log('📬 Result:', JSON.stringify(result2, null, 2)); console.log(''); await client.close(); console.log('✅ Test completed successfully!'); } testWeatherServer().catch((error) => { console.error('❌ Test failed:', error); process.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/alesanabv/mcpWeather'

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