MCP Command Server

by brunorozendo

Not rated
GitHub

About

A server for securely executing commands on the host system, requiring Java 21 or higher.

Details

Author
brunorozendo
Categories
Developer Tools, Other

Setup

Install MCP Command Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/brunorozendo/mcp-server-command

Follow the installation instructions in the repository README, then restart your MCP client.

A Model Context Protocol (MCP) server that enables secure command execution on the host system. This server allows AI assistants like Claude to run shell commands with optional working directory and stdin support.

The project is now modularized to support multiple transport methods: stdio, HTTP, and Server-Sent Events (SSE).

- Command Execution: Run any shell command on the host system
- Working Directory Support: Execute commands in specific directories
- STDIN Support: Pipe input data to commands
- Cross-Platform: Works on macOS, Linux, and Windows
- Timeout Protection: Commands timeout after 60 seconds to prevent hanging
- Special Fish Shell Support: Enhanced handling for the Fish shell
- Advanced Logging: Powered by Logback with configurable log levels (ERROR, WARN, INFO, DEBUG, TRACE), optional file logging, and rolling file support

- Java 25 or higher
- Gradle (for building from source)
- Claude Desktop app (for integration)

git clone <repository-url> cd mcp-server-command

This will create JAR files for each module:

- stdio/build/libs/stdio-1.0.0.jar- Standard I/O transport (recommended for Claude Desktop)
- http/build/libs/http-1.0.0.jar- HTTP transport
- sse/build/libs/sse-1.0.0.jar- Server-Sent Events transport

For better performance, you can build a native binary using GraalVM:

This creates a native executable atstdio/build/native/nativeCompile/mcp-server-command

If you have a pre-built JAR, skip the building step and proceed to configuration.
-

Locate your Claude Desktop configuration:

- macOS:~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:%APPDATA%\Claude\claude_desktop_config.json
- Linux:~/.config/Claude/claude_desktop_config.json

{ "mcpServers": { "mcp-server-command": { "command": "java", "args": [ "-jar", "/absolute/path/to/stdio-1.0.0.jar" ], "env":{ "LOG_DIR":"/Users/<username>/Library/Logs/Claude", "LOG_LEVEL":"DEBUG" } } } }
{ "mcpServers": { "mcp-server-command": { "command": "/absolute/path/to/stdio/build/native/nativeCompile/mcp-server-command", "env":{ "LOG_DIR":"/Users/<username>/Library/Logs/Claude", "LOG_LEVEL":"DEBUG" } } } }

- Restart Claude Desktop to load the new server

Once configured, Claude can use therun_commandtool to execute commands on your system.

Run 'git status' in the directory /Users/username/my-project
Create a new file called hello.txt with the content "Hello, World!" using the cat command
Run this Python script: print("Hello from Python") for i in range(5): print(f"Count: {i}")

- command(string, required): The command to execute with arguments
- workdir(string, optional): The working directory for command execution
- stdin(string, optional): Text to pipe into the command's STDIN

- stdout: Standard output from the command
- stderr: Standard error output from the command
- message: Error message if command fails
- isError: Boolean indicating if the command failed

{ "jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": { "name": "run_command", "arguments": { "command": "echo Hello World", "workdir": "/tmp", "stdin": "Input data" } } }
mcp-server-command/ ├── stdio/ # Standard I/O transport module │ ├── src/main/java/com/brunorozendo/mcp/ │ │ └── McpServer.java # Main server entry point │ └── build.gradle ├── http/ # HTTP transport module │ ├── src/main/java/com/brunorozendo/mcp/ │ │ └── McpServer.java # HTTP server implementation │ └── build.gradle ├── sse/ # Server-Sent Events transport module │ ├── src/main/java/com/brunorozendo/mcp/ │ │ └── McpServer.java # SSE server implementation │ └── build.gradle ├── tools/ # Shared command execution logic │ ├── src/main/java/com/brunorozendo/mcp/ │ │ ├── CommandExecutor.java # Command execution logic │ │ ├── CommandResult.java # Result data structure │ │ ├── ExecCommandTool.java # Tool implementation │ │ ├── Transport.java # Transport configuration │ │ └── ToolSchemas.java # Tool schema definitions │ └── build.gradle ├── settings.gradle # Multi-module configuration └── docs/ # Documentation

Execute the test script to verify functionality:

Create distribution archives (ZIP and TAR):

⚠️WARNING: This server executes commands with the same privileges as the user running the Java process.
- Only install this server if you trust the AI assistant
- Run the server with minimal necessary privileges
- Consider using a restricted user account for the server
- Be cautious when sharing your screen or command outputs
- Regularly review which commands are being executed
- Consider implementing command whitelisting for production use

- File system access and modification
- Network operations
- Process execution
- Access to environment variables and system information
- Verify the configuration file path is correct
- Ensure the JAR file path is absolute, not relative
- Check that Java 25+ is installed:java -version
- Restart Claude Desktop after configuration changes
- Set log level to DEBUG or TRACE to see detailed error messages
- Check file permissions for the working directory
- Verify the command syntax is correct for your shell
- Test commands directly in terminal first

- Commands timeout after 60 seconds
- For long-running commands, consider breaking them into smaller steps
- Use background processes with caution

# Using cat with stdin echo "File content" | cat > newfile.txt # Or directly with stdin parameter cat > newfile.txt # with stdin: "File content"
# Python python3 -c "print('Hello')" # Or with stdin for longer scripts python3 # with stdin: <your script content>

The server includes special handling for Fish shell to properly handle stdin:

- 1.0.0- Current version with modular architecture

- Modular design with stdio, HTTP, and SSE transport support
- Command execution with timeout protection
- Working directory support
- STDIN support
- Special Fish shell handling
- Advanced Logback-based logging with file rotation support
- Updated to MCP SDK 0.17.0
- Java 25 support
- GraalVM native compilation support

For advanced users, you can provide your ownlogback.xmlconfiguration file:
- Create your customlogback.xml
- Place it in the classpath or specify its location with-Dlogback.configurationFile=/path/to/logback.xml

[Add contribution guidelines if applicable]

- Check the troubleshooting section
- Set appropriate log level for debugging
- [Add support contact/repository issues link]

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Fast lightweight Java MCP server framework - Build Model Context Protocol servers with minimal boilerplate and full TypeScript SDK compatibility

A Java plugin that exposes the Jadx decompiler API over HTTP for interaction with MCP clients.

Specialized tools for analyzing and migrating Java applications from Java EE 8 (javax.) to Jakarta EE 9+ (jakarta.).

Java Archive Reader Protocol MCP server - Give AI agents X-ray vision into compiled Java code by decompiling JAR/WAR/EAR files and Maven/Gradle dependencies

A Model Context Protocol (MCP) server for searching Java documentation. This server enables AI assistants to search and retrieve Java API documentation from JSON files.

Allows AI assistants to remotely drive the JetBrains debugger via MCP, including breakpoints, stepping, and variable inspection.

Resolves your Gradle project’s real classpath and returns Java source, method signatures, and class structure for any dependency class—using the version your build actually uses, not random files from ~/.gradle/caches.

Legacy Java to Microservices Refactoring

A community gateway to migrate legacy Jakarta EE monoliths into Spring Boot using AST parsing.

Search for and retrieve detailed information, including READMEs and metadata, for Maven packages from Maven Central.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.