mcp-server-command
MCP Command Server
Documentation
MCP Command Server
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).
Features
- 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
Prerequisites
- Java 25 or higher
- Gradle (for building from source)
- Claude Desktop app (for integration)
Installation
Building from Source
1. Clone the repository:
git clone
cd mcp-server-command2. Build the project:
./gradlew buildThis 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
Native Binary (Optional)
For better performance, you can build a native binary using GraalVM:
./gradlew stdio:nativeCompileThis creates a native executable at `stdio/build/native/nativeCompile/mcp-server-command`
Pre-built JAR
If you have a pre-built JAR, skip the building step and proceed to configuration.
Configuration
Claude Desktop Integration
1. Locate your Claude Desktop configuration:
2. Add the MCP server configuration:
Option A: Java JAR (Recommended)
{
"mcpServers": {
"mcp-server-command": {
"command": "java",
"args": [
"-jar",
"/absolute/path/to/stdio-1.0.0.jar"
],
"env":{
"LOG_DIR":"/Users//Library/Logs/Claude",
"LOG_LEVEL":"DEBUG"
}
}
}
}Option B: Native Binary
{
"mcpServers": {
"mcp-server-command": {
"command": "/absolute/path/to/stdio/build/native/nativeCompile/mcp-server-command",
"env":{
"LOG_DIR":"/Users//Library/Logs/Claude",
"LOG_LEVEL":"DEBUG"
}
}
}
}3. Restart Claude Desktop to load the new server
Usage
Once configured, Claude can use the `run_command` tool to execute commands on your system.
Basic Examples
Simple command execution:
Run the command: ls -laCommand with working directory:
Run 'git status' in the directory /Users/username/my-projectCommand with stdin:
Create a new file called hello.txt with the content "Hello, World!" using the cat commandPython script execution:
Run this Python script:
print("Hello from Python")
for i in range(5):
print(f"Count: {i}")API Reference
Tool: run_command
Executes a command on the host system.
Parameters:
- `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
Returns:
- `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
Example Request:
{
"jsonrpc": "2.0",
"method": "tools/call",
"id": 1,
"params": {
"name": "run_command",
"arguments": {
"command": "echo Hello World",
"workdir": "/tmp",
"stdin": "Input data"
}
}
}Development
Project Structure
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/ # DocumentationRunning Tests
Execute the test script to verify functionality:
./test_server.shBuilding a Distribution
Create distribution archives (ZIP and TAR):
./gradlew distZip distTarSecurity Considerations
⚠️ WARNING: This server executes commands with the same privileges as the user running the Java process.
Security Best Practices:
1. Only install this server if you trust the AI assistant
2. Run the server with minimal necessary privileges
3. Consider using a restricted user account for the server
4. Be cautious when sharing your screen or command outputs
5. Regularly review which commands are being executed
6. Consider implementing command whitelisting for production use
Potential Risks:
- File system access and modification
- Network operations
- Process execution
- Access to environment variables and system information
Troubleshooting
Server not appearing in Claude
1. Verify the configuration file path is correct
2. Ensure the JAR file path is absolute, not relative
3. Check that Java 25+ is installed: `java -version`
4. Restart Claude Desktop after configuration changes
Commands failing
1. Set log level to DEBUG or TRACE to see detailed error messages
2. Check file permissions for the working directory
3. Verify the command syntax is correct for your shell
4. Test commands directly in terminal first
Timeout errors
- Commands timeout after 60 seconds
- For long-running commands, consider breaking them into smaller steps
- Use background processes with caution
Advanced Usage
Creating Files
# Using cat with stdin
echo "File content" | cat > newfile.txt
# Or directly with stdin parameter
cat > newfile.txt
# with stdin: "File content"Running Scripts
# Python
python3 -c "print('Hello')"
# Or with stdin for longer scripts
python3
# with stdin:Fish Shell Support
The server includes special handling for Fish shell to properly handle stdin:
fish -c "echo $USER"Version History
- 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
Custom Logback Configuration
For advanced users, you can provide your own `logback.xml` configuration file:
1. Create your custom `logback.xml`
2. Place it in the classpath or specify its location with `-Dlogback.configurationFile=/path/to/logback.xml`
License
[Add your license information here]
Contributing
[Add contribution guidelines if applicable]
Support
For issues and questions:
- Check the troubleshooting section
- Set appropriate log level for debugging
- [Add support contact/repository issues link]
Frequently asked questions
What is mcp-server-command?
mcp-server-command is MCP Command Server
How do I install mcp-server-command?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-server-command open source?
Yes — it is hosted on GitHub at https://github.com/brunorozendo/mcp-server-command.
Related MCP tools
MCP Server for Ghidra Java-based implementation. Trusted by 6400+ developers. Trusted by 6400+ developers. Trusted by 6400+ developers.
The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI Trusted by 2800+ developers.
A library for communication with a Minecraft client/server. Built for the Model Context Protocol to enhance AI capabilities. Java-based implementation.
Model Context Protocol Servers
Pre-indexed code knowledge graph, auto syncs on code changes, for Claude Code, Codex, Gemini, Cursor, OpenCode, AntiGravity, Kiro, CoPilot, and Hermes Agent — fewer tokens, fewer tool calls, 100% local
an open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP