A server for securely executing commands on the host system, requiring Java 21 or higher.
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.
git clone <repository-url>
cd mcp-server-command
./gradlew build
This will create the JAR file at build/libs/mcp-server-command-0.5.0.jar
If you have a pre-built JAR, skip the building step and proceed to configuration.
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2.1 Add the MCP server configuration - Java:
{
"mcpServers": {
"mcp-server-command": {
"command": "java",
"args": [
"-jar",
"/absolute/path/to/mcp-server-command-0.5.0.jar"
],
"env":{
"LOG_DIR":"/Users/<username>/Library/Logs/Claude",
"LOG_LEVEL":"DEBUG"
}
}
}
}
2.1 Add the MCP server configuration - Native:
{
"mcpServers": {
"mcp-server-command": {
"command": "/path/to/build/native/nativeCompile/mcp-server-command",
"env":{
"LOG_DIR":"/Users/<username>/Library/Logs/Claude",
"LOG_LEVEL":"DEBUG"
}
}
}
}
Once configured, Claude can use the run_command
tool to execute commands on your system.
Simple command execution:
Run the command: ls -la
Command with working directory:
Run 'git status' in the directory /Users/username/my-project
Command with stdin:
Create a new file called hello.txt with the content "Hello, World!" using the cat command
Python script execution:
Run this Python script:
print("Hello from Python")
for i in range(5):
print(f"Count: {i}")
Executes a command on the host system.
Parameters:
command
(string, required): The command to execute with argumentsworkdir
(string, optional): The working directory for command executionstdin
(string, optional): Text to pipe into the command's STDINReturns:
stdout
: Standard output from the commandstderr
: Standard error output from the commandmessage
: Error message if command failsisError
: Boolean indicating if the command failedExample Request:
{
"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/
├── src/main/java/com/example/mcp/server/command/
│ ├── McpCommandServer.java # Main server implementation
│ ├── CommandExecutor.java # Command execution logic
│ └── CommandResult.java # Result data structure
├── build.gradle # Build configuration
├── test_server.sh # Testing script
└── claude_desktop_config_example.json
Execute the test script to verify functionality:
./test_server.sh
Create distribution archives (ZIP and TAR):
./gradlew distZip distTar
⚠️ WARNING: This server executes commands with the same privileges as the user running the Java process.
Security Best Practices:
Potential Risks:
java -version
# 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:
fish -c "echo $USER"
For advanced users, you can provide your own logback.xml
configuration file:
logback.xml
-Dlogback.configurationFile=/path/to/logback.xml
[Add your license information here]
[Add contribution guidelines if applicable]
For issues and questions:
An example of a remote MCP server deployable on Cloudflare Workers without authentication.
Empowers LLMs with real-time network traffic analysis using tshark. Requires Wireshark's tshark to be installed.
MCP Server that exposes Creatify AI API capabilities for AI video generation, including avatar videos, URL-to-video conversion, text-to-speech, and AI-powered editing tools.
An AI gateway for the Blend Protocol on Stellar, enabling DeFi actions like lending, borrowing, and pool creation through AI assistants or apps.
An SSE-based MCP server that allows LLM-powered applications to interact with OCI registries. It provides tools for retrieving information about container images, listing tags, and more.
Provides call graph analysis for LLMs using the nuanced library.
Generate images using OpenAI's DALL-E API.
A test server that demonstrates all features of the MCP protocol, including prompts, tools, resources, and sampling.
Interact with the Bitcoin and Lightning Network to generate keys, validate addresses, decode transactions, and query the blockchain.
Interact with the JFrog Platform API for repository management, build tracking, and release lifecycle management.