Skip to main content
Glama

mcp-server-commands

by g0t4
exec-file-with-stdin.cjs1.23 kB
const { execFile } = require('child_process'); /** * Executes a file with the given arguments, piping input to stdin. * @param {string} file - The file to execute. * @param {string[]} args - Array of arguments for the file. * @param {string} input - The string to pipe to stdin. * @returns {Promise<{ stdout: string, stderr: string }>} Resolves with stdout and stderr. */ function execFileWithInputTest(file, args, input) { return new Promise((resolve, reject) => { const child = execFile(file, args, (error, stdout, stderr) => { if (error) { reject({ error, stdout, stderr }); } else { resolve({ stdout, stderr }); } }); if (input) { child.stdin.write(input); child.stdin.end(); } }); } // Example usage execFileWithInputTest('cat', [], 'Hello, world!') .then(({ stdout, stderr }) => { //throw new Error('This should not be executed'); // demo how catch would catch this too and yeah not desirable (necessarily) console.log('STDOUT:', stdout); console.log('STDERR:', stderr); }) .catch(({ error, stdout, stderr }) => { console.error('ERROR:', error); console.error('STDOUT:', stdout); console.error('STDERR:', stderr); });

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