Skip to main content
Glama

FastMCP Demo

by gogouravr
test-hello.tsโ€ข2.4 kB
#!/usr/bin/env node /** * Test script to call the hello tool */ import { spawn } from "child_process"; import { join } from "path"; const serverPath = join(process.cwd(), "dist", "index.js"); console.log("๐Ÿงช Testing hello tool...\n"); // Spawn the server process const server = spawn("node", [serverPath], { stdio: ["pipe", "pipe", "pipe"], }); let requestId = 1; // Initialize the connection const initRequest = { jsonrpc: "2.0", id: requestId++, method: "initialize", params: { protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "test-client", version: "1.0.0", }, }, }; server.stdin.write(JSON.stringify(initRequest) + "\n"); // After initialization, call the hello tool setTimeout(() => { const helloRequest = { jsonrpc: "2.0", id: requestId++, method: "tools/call", params: { name: "hello", arguments: { name: "Alice", }, }, }; console.log("๐Ÿ“ค Sending request:", JSON.stringify(helloRequest, null, 2)); console.log("\nโณ Waiting for response...\n"); server.stdin.write(JSON.stringify(helloRequest) + "\n"); }, 200); // Collect responses let buffer = ""; server.stdout.on("data", (data) => { buffer += data.toString(); const lines = buffer.split("\n").filter((line) => line.trim()); for (const line of lines) { if (line.trim()) { try { const response = JSON.parse(line); if (response.method === "notifications/initialized") { // Skip initialization notification continue; } if (response.id === 2) { // This is our hello tool response console.log("โœ… Response received:"); console.log(JSON.stringify(response, null, 2)); console.log("\n๐Ÿ“ Result:"); if (response.result?.content?.[0]?.text) { console.log(response.result.content[0].text); } server.kill(); process.exit(0); } } catch (e) { // Not JSON, might be error output } } } buffer = ""; }); server.stderr.on("data", (data) => { const message = data.toString(); if (message.includes("running")) { console.log("โœ… Server:", message.trim()); } }); // Timeout safety setTimeout(() => { console.log("\nโฑ๏ธ Test timeout"); server.kill(); process.exit(1); }, 3000);

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/gogouravr/fast-mcp'

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