A lightweight Bash implementation of an MCP server that allows creating and using custom command-line tools via a JSON-RPC interface.
Shell MCP provides a simple framework to create, manage, and use custom command-line tools. The server loads tools from the tools
directory and makes them available through a standardized interface.
To start the MCP server with the default configuration:
./mcp-server.sh
The server will load all tools from the tools
directory and begin listening for commands via stdin.
Shell MCP includes a CLI option to easily create new tools.
# Create a new tool
./mcp-server.sh --add-tool NAME DESCRIPTION "PARAM1:TYPE,PARAM2:TYPE"
# Show help information
./mcp-server.sh --help
# Create a new multiplication tool
./mcp-server.sh --add-tool multiply "Multiplies two numbers" "num1:int,num2:int"
This will generate a new tool file at tools/multiply.tool.sh
with a basic implementation template.
We welcome contributions from the community! You can create your own general-purpose tools and submit them as pull requests.
Guidelines for contributing tools:
- Tools should be general-purpose and useful to a wide audience
- Follow the existing pattern for tool implementation
- Include clear documentation within your tool file
- Make sure your tool works correctly before submitting
- Submit a pull request with your tool added to the
tools
directory
Each tool consists of:
- A function that implements the tool's logic
- A call to
register_tool
to make the tool available to the server
Here's an example of a simple tool implementation:
#!/usr/bin/env bash
# Addition tool implementation
# Function that performs the addition
addition_impl() {
local num1=$1
local num2=$2
# Calculate the sum
local sum=$((num1 + num2))
echo "sum of two numbers is $sum"
}
# Register the tool with the server
register_tool \
"addition" \
"addition of two numbers" \
"num1:int,num2:int" \
"addition_impl"
- Each tool function should accept parameters in the order they are defined
- Tools must use a single
echo
statement at the end to return their result - Parameter types are for documentation only - all parameters are passed as strings
- Make the tool file executable with
chmod +x
after creating it manually
shell-mcp/
├── mcp-server.sh # Main server script
├── tools/ # Directory containing all tools
│ ├── addition.tool.sh # Example tool
│ ├── bmi_calculator.tool.sh # Example tool
│ └── pokemon_fetcher.tool.sh # Example tool
└── mcp_server.log # Server log file (created when server runs)
The server implements a simplified JSON-RPC interface with the following methods:
initialize
: Initializes the server and returns its capabilitiestools/list
: Lists all available tools with their descriptions and parameterstools/call
: Calls a specific tool with the provided argumentsresources/list
: Lists available resources (not implemented)prompts/list
: Lists available prompts (not implemented)
- Bash 4.0 or higher
jq
for JSON processing
This project is open source and available under the MIT License.