Skip to main content
Glama
send-mcp.ts1.23 kB
import * as readline from "node:readline"; const message = { type: "request", id: "test-1", method: "tools.call", params: { name: "browser_get_console_logs", arguments: {}, }, }; function send(obj: unknown) { const json = JSON.stringify(obj); process.stdout.write(`Content-Length: ${Buffer.byteLength(json, "utf8")}\r\n\r\n${json}`); } const rl = readline.createInterface({ input: process.stdin }); let state: "headers" | "body" = "headers"; let contentLength = 0; let body = ""; rl.on("line", (line) => { if (state === "headers") { if (line.toLowerCase().startsWith("content-length:")) { contentLength = Number(line.split(":")[1].trim()); } if (line === "") { state = "body"; if (contentLength === 0) { console.error("Received empty body"); state = "headers"; } } return; } body += line + "\n"; if (Buffer.byteLength(body, "utf8") >= contentLength) { try { const parsed = JSON.parse(body.trim()); console.error("<--", JSON.stringify(parsed, null, 2)); } catch (error) { console.error("Failed to parse response", error); } state = "headers"; body = ""; contentLength = 0; } }); send(message);

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/yetidevworks/yetibrowser-mcp'

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