Skip to main content
Glama

MCP Shell Server

by mkusaka
shell-config.ts1.63 kB
import { Command } from "commander"; import os from "os"; import path from "path"; // Shell configuration const getShell = (): string => { if (process.env.SHELL) { return process.env.SHELL; } const shellProgram = new Command(); shellProgram .name("mcp-shell") .description("MCP Shell Server - A server for executing shell commands") .version("0.1.0") .option("-s, --shell <shell>", "Specify the path to the shell to use"); shellProgram.parse(process.argv); const options = shellProgram.opts(); if (options.shell) { return options.shell; } // Set default shell based on OS return os.platform() === "win32" ? "cmd.exe" : "/bin/bash"; }; export const isUnderHome = (dirPath: string): boolean => { const homePath = os.homedir(); const absoluteDirPath = path.resolve(dirPath); const absoluteHomePath = path.resolve(homePath); const relativePath = path.relative(absoluteHomePath, absoluteDirPath); return !relativePath.startsWith("..") && !path.isAbsolute(relativePath); }; // Get working directory configuration export const getWorkingDir = (): string => { const workingDirProgram = new Command(); workingDirProgram .name("mcp-shell") .description("MCP Shell Server - A server for executing shell commands") .version("0.1.0") .option( "-w, --working-dir <directory>", "Specify the working directory for command execution", ); workingDirProgram.parse(process.argv); const options = workingDirProgram.opts(); if (options.workingDir) { return options.workingDir; } return os.homedir(); }; export default getShell;

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/mkusaka/mcp-shell-server'

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