### Install Dependencies Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Installs the necessary dependencies for the project. Run this before building. ```bash npm install ``` -------------------------------- ### Build the Server Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Compiles the project for production. This command should be run after installing dependencies. ```bash npm run build ``` -------------------------------- ### Build MCP Server Commands from Local Source Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Clone the repository, install dependencies, and build the project locally. This method is useful for development or when npx installation is not preferred. ```bash # Clone and build git clone https://github.com/g0t4/mcp-server-commands.git cd mcp-server-commands npm install npm run build ``` -------------------------------- ### Start HTTP Server with mcpo (Bash) Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Initiate the MCP server as an HTTP service on a specified port, using an API key for authentication. This allows integration with HTTP clients like `curl`. ```bash # Start HTTP server on port 3010 uvx mcpo --port 3010 --api-key "supersecret" -- npx mcp-server-commands # The server now accepts HTTP requests curl -X POST http://localhost:3010/tools/run_process \ -H "Authorization: Bearer supersecret" \ -H "Content-Type: application/json" \ -d '{"command_line": "hostname"}' ``` -------------------------------- ### Development Build with Auto-Rebuild Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Starts the build process in watch mode, which automatically rebuilds the server on code changes. Useful for active development. ```bash npm run watch ``` -------------------------------- ### Run mcpo with mcp-server-commands Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Starts the mcpo server to provide an HTTP/OpenAPI interface for mcp-server-commands. This command bridges STDIO communication with HTTP. ```bash uvx mcpo --port 3010 --api-key "supersecret" -- npx mcp-server-commands # uvx runs mcpo => mcpo run npx => npx runs mcp-server-commands # then, mcpo bridges STDIO <=> HTTP ``` -------------------------------- ### Start MCP Inspector (Bash) Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Launch the MCP Inspector tool, which provides a browser-based UI for interactive debugging, testing tool calls, and viewing server logs. ```bash # From the project directory npm run inspector # Or directly npx @modelcontextprotocol/inspector build/index.js ``` -------------------------------- ### Manual Session with Verbose Logging Source: https://github.com/g0t4/mcp-server-commands/blob/master/tests/manual/stdio/README.md Start a manual session with verbose logging enabled. Paste requests on a single line and press return to submit. ```sh node ~/repos/github/g0t4/mcp-server-commands/build/index.js --verbose # => paste request and hit return (new line) to "submit" # entire message must be on one line ``` -------------------------------- ### Provide Input to Shell Command via stdin_text Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Use `stdin_text` to pass input to a command's standard input, similar to a heredoc. This example pipes 'Hello World' to `cat`. ```typescript // Pass input to cat command const result = await runProcess({ command_line: "cat", stdin_text: "Hello World" }); // Result: { content: [{ name: "EXIT_CODE", text: "0" }, { name: "STDOUT", text: "Hello World" }] } ``` -------------------------------- ### Change Working Directory for Command Execution Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Use the `cwd` option to specify a working directory for the command. This example runs `pwd` in `/tmp`. ```typescript // Run command in specific directory const result = await runProcess({ command_line: "pwd", cwd: "/tmp" }); // Result: { content: [{ name: "EXIT_CODE", text: "0" }, { name: "STDOUT", text: "/tmp\n" }] } ``` -------------------------------- ### Configure Claude Desktop with Local Build Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Configuration for Claude Desktop to use a local build of 'mcp-server-commands'. Requires running `npm run build` first. The 'command' should point to the built executable. ```json { "mcpServers": { "mcp-server-commands": { "command": "/path/to/mcp-server-commands/build/index.js" } } } ``` -------------------------------- ### Configure Claude Desktop with npm Package Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Configuration for Claude Desktop to use the published npm package 'mcp-server-commands'. Ensure the 'command' and 'args' are correctly set. ```json { "mcpServers": { "mcp-server-commands": { "command": "npx", "args": ["mcp-server-commands"] } } } ``` -------------------------------- ### Execute Shell Command with Variable Expansion and Globbing Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Shows how to use shell variables (e.g., `$HOME`) and globbing patterns (e.g., `*.json`) within `command_line` for dynamic command execution. ```typescript // Variable expansion and globbing const result = await runProcess({ command_line: "echo $HOME && ls *.json" }); ``` -------------------------------- ### Create File using stdin_text Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Demonstrates using `stdin_text` with a shell command like `cat > filename` to create a file with specified content. ```typescript // Create a file using cat with stdin const result = await runProcess({ command_line: "cat > /tmp/example.txt", stdin_text: "This is the file content\nLine 2\nLine 3" }); ``` -------------------------------- ### List Tools with MCP Server Commands Source: https://github.com/g0t4/mcp-server-commands/blob/master/tests/manual/stdio/README.md Use this command to list available tools by piping a JSONRPC request to the mcp-server-commands script and processing the output with jq. ```sh echo '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} }' \ | npx ~/repos/github/g0t4/mcp-server-commands/build/index.js | jq ``` -------------------------------- ### Execute Shell Command with Pipes and Redirects Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Demonstrates executing shell commands that utilize pipes (`|`) and redirects (`>`). This allows for complex command chaining and data manipulation. ```typescript // Using pipes and redirects const result = await runProcess({ command_line: "cat /etc/passwd | grep root | head -1" }); ``` -------------------------------- ### Execute Git Commands Directly Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Demonstrates invoking `git` commands with specific arguments using the `argv` property for direct process execution. ```typescript // Git commands with arguments const result = await runProcess({ argv: ["git", "status", "--porcelain"] }); ``` -------------------------------- ### Enable Verbose Logging (JSON) Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Configure MCP server commands to output verbose logs for debugging purposes by including the `--verbose` flag in the arguments. ```json { "mcpServers": { "mcp-server-commands": { "command": "npx", "args": ["mcp-server-commands", "--verbose"] } } } ``` -------------------------------- ### Execute npm Commands in Project Directory Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Shows how to execute `npm` commands within a specific application directory by setting the `cwd` option. ```typescript // npm commands in project directory const result = await runProcess({ command_line: "npm run build", cwd: "/home/user/my-app" }); ``` -------------------------------- ### Inspect MCP Server Commands Requests Source: https://github.com/g0t4/mcp-server-commands/blob/master/tests/manual/stdio/README.md Run the inspector to build requests using a GUI form. This is useful for generating complex requests before copying and pasting them. ```sh npm run inspector ``` -------------------------------- ### Execute Git Commands in Specific Directory Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Demonstrates running `git` commands within a specified project directory using the `cwd` option. ```typescript // Git operations in a specific repository const result = await runProcess({ argv: ["git", "log", "--oneline", "-5"], cwd: "/home/user/my-project" }); ``` -------------------------------- ### Execute Basic Shell Command Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Use `command_line` to execute a simple shell command like `ls -la /tmp`. The result object contains exit code and STDOUT. ```typescript // Basic shell command const result = await runProcess({ command_line: "ls -la /tmp" }); // Result: { content: [{ name: "EXIT_CODE", text: "0" }, { name: "STDOUT", text: "..." }] } ``` -------------------------------- ### Execute Node.js Script Directly Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Shows how to execute a Node.js script with arguments, such as running an inline script using `node -e`, via the `argv` property. ```typescript // Node.js script execution const result = await runProcess({ argv: ["node", "-e", "console.log(JSON.stringify({version: process.version}))"] }); ``` -------------------------------- ### Pull Qwen2.5-Coder Model Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Pulls the Qwen2.5-Coder model using Ollama. This model supports tool use but may require coaxing. ```sh # Qwen2.5-Coder has tool use but you have to coax it ollama pull qwen2.5-coder ``` -------------------------------- ### Specify Custom Log File Location (JSON) Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Configure the MCP server commands to write logs to a specific file path by providing the `--logFile` argument. ```json { "mcpServers": { "mcp-server-commands": { "command": "npx", "args": ["mcp-server-commands", "--verbose", "--logFile=/tmp/mcp-commands.log"] } } } ``` -------------------------------- ### Execute Complex Shell Scripting Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Illustrates running more complex shell constructs like `for` loops directly within the `command_line` argument. ```typescript // Complex shell operations const result = await runProcess({ command_line: "for i in 1 2 3; do echo $i; done" }); ``` -------------------------------- ### View MCP Server Commands Log Source: https://github.com/g0t4/mcp-server-commands/blob/master/tests/manual/stdio/README.md Access the command log file to review past requests and tool executions. ```sh cat ~/.local/share/mcp-server-commands/commands.log ``` -------------------------------- ### Enable Verbose Logging for MCP Server Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Add the `--verbose` argument to the server configuration to increase the logging level. Logs are written to STDERR. ```bash args: [--verbose] ``` -------------------------------- ### Directly Invoke an Executable Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Use the `argv` property to directly execute a program (e.g., `cat`) with its arguments, bypassing shell interpretation. ```typescript // Direct executable invocation const result = await runProcess({ argv: ["cat", "/etc/hostname"] }); // Result: { content: [{ name: "EXIT_CODE", text: "0" }, { name: "STDOUT", text: "myhost\n" }] } ``` -------------------------------- ### Pull OpenHands LM Model Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Pulls the OpenHands LM model from Hugging Face using Ollama. Ensure your system has sufficient VRAM for optimal performance. ```sh # NOTE: make sure to review variants and sizes, so the model fits in your VRAM to perform well! # Probably the best so far is [OpenHands LM](https://www.all-hands.dev/blog/introducing-openhands-lm-32b-32b-v0.1-GGUF) ollama pull https://huggingface.co/lmstudio-community/openhands-lm-32b-v0.1-GGUF ``` -------------------------------- ### OpenAI Codex Shell Tool Schema Source: https://github.com/g0t4/mcp-server-commands/blob/master/TODO.md This JSON schema defines a tool for running shell commands, including parameters for the command itself, working directory, and timeout. It's used by tools like OpenAI's Codex. ```json { "name": "shell", "description": "Runs a shell command, and returns its output.", "strict": false, "parameters": { "type": "object", "properties": { "command": { "type": "array", "items": { "type": "string" } }, "workdir": { "type": "string", "description": "The working directory for the command." }, "timeout": { "type": "number", "description": "The maximum time to wait for the command to complete in milliseconds." } }, "required": [ "command" ], "additionalProperties": false } } ``` -------------------------------- ### Pass Bash Script via stdin Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Execute a bash script by providing its content via `stdin_text` to the `bash` interpreter invoked using `argv`. ```typescript // Pass a bash script via stdin const result = await runProcess({ argv: ["bash"], stdin_text: "#!/bin/bash\necho 'Running from stdin'\ndate\npwd" }); ``` -------------------------------- ### Pass Python Script via stdin Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Execute a Python script by passing its source code via `stdin_text` to the `python3` interpreter invoked using `argv`. ```typescript // Pass a Python script via stdin const result = await runProcess({ argv: ["python3"], stdin_text: "import sys\nprint('Python version:', sys.version)\nprint('Hello from stdin!')" }); ``` -------------------------------- ### Handle Command Errors (TypeScript) Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Commands that fail return an `isError: true` object containing detailed error information, including exit codes, STDERR, and signal information. ```typescript // Non-existent command (shell mode) const result = await runProcess({ command_line: "nonexistent_command" }); // Result: { // isError: true, // content: [ // { name: "EXIT_CODE", text: "127" }, // { name: "STDERR", text: "/bin/sh: nonexistent_command: command not found\n" } // ] // } ``` ```typescript // Non-existent executable (argv mode) const result = await runProcess({ argv: ["nonexistent_executable"] }); // Result: { // isError: true, // content: [ // { name: "EXIT_CODE", text: "ENOENT" }, // { name: "MESSAGE", text: "spawn nonexistent_executable ENOENT" } // ] // } ``` ```typescript // Command with non-zero exit code const result = await runProcess({ command_line: "exit 42" }); // Result: { isError: true, content: [{ name: "EXIT_CODE", text: "42" }] } ``` ```typescript // Invalid argument combinations const result = await runProcess({ command_line: "echo hi", argv: ["date"] // Cannot use both! }); // Result: { // isError: true, // content: [{ name: "ERROR", text: "Cannot pass both 'command_line' and 'argv'. Use one or the other." }] // } ``` -------------------------------- ### Pull Devstral Model Source: https://github.com/g0t4/mcp-server-commands/blob/master/README.md Pulls the Devstral model using Ollama. This model is available in the Ollama library. ```sh # https://ollama.com/library/devstral ollama pull devstral ``` -------------------------------- ### Set Timeout for Long-Running Commands (TypeScript) Source: https://context7.com/g0t4/mcp-server-commands/llms.txt Configure a timeout in milliseconds to automatically abort commands that exceed the specified duration. The default timeout is 30,000ms (30 seconds). ```typescript // Short timeout for quick commands const result = await runProcess({ command_line: "curl -s https://api.example.com/health", timeout_ms: 5000 // 5 second timeout }); ``` ```typescript // Longer timeout for builds const result = await runProcess({ command_line: "npm run build", cwd: "/home/user/my-project", timeout_ms: 300000 // 5 minute timeout }); ``` ```typescript // Timeout will result in SIGTERM signal const result = await runProcess({ argv: ["sleep", "60"], timeout_ms: 1000 // Kill after 1 second }); // Result: { isError: true, content: [{ name: "SIGNAL", text: "SIGTERM" }] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.