Skip to main content
Glama

mcp-server-commands

by g0t4
messages.ts1.76 kB
import { ExecResult } from "./exec-utils.js"; import { TextContent } from "@modelcontextprotocol/sdk/types.js"; /** * Converts an ExecResult into an array of TextContent messages. */ export function messagesFor(result: ExecResult): TextContent[] { const messages: TextContent[] = []; if (result.code !== undefined) { messages.push({ type: "text", text: `${result.code}`, name: "EXIT_CODE", }); } // PRN any situation where I want to pass .message and/or .cmd? // maybe on errors I should? that way there's a chance to make sure the command was as intended // and maybe include message when it doesn't contain stderr? // FYI if I put these back, start with tests first // PRN use a test to add these, sleep 10s maybe and then kill that process? // definitely could be useful to know if a command was killed // make sure signal is not null, which is what's used when no signal killed the process // if (result.signal) { // messages.push({ // type: "text", // text: `Signal: ${result.signal}`, // name: "SIGNAL", // }); // } // if (!!result.killed) { // // killed == true is the only time to include this // messages.push({ // type: "text", // text: "Process was killed", // name: "KILLED", // }); // } if (result.stdout) { messages.push({ type: "text", text: result.stdout, name: "STDOUT", }); } if (result.stderr) { messages.push({ type: "text", text: result.stderr, name: "STDERR", }); } return messages; }

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/g0t4/mcp-server-commands'

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