A Model Context Protocol (MCP) server for executing Octave scripts non-interactively.
- Execute Octave scripts via MCP protocol
- Supports both HTTP and stdio communication modes
- Built-in security for HTTP mode (localhost only)
- Automatic Octave installation verification
- Go 1.21+ (for building/running)
- GNU Octave installed and available in PATH (tested version 8.4.0)
-
Clone the repository:
git clone https://github.com/fmcato/octave-mcp.git cd octave-mcp -
Build the server:
go build ./cmd/octave-server
Start the HTTP server:
./octave-server -http localhost:8080Start the stdio server:
./octave-serverThe server provides two tools:
run_octave- Execute Octave scripts:
{
"script": "string"
}Example:
{
"script": "disp('Hello from Octave');"
}generate_plot- Generate plots from Octave scripts:
{
"script": "string",
"format": "png|svg"
}Example:
{
"script": "plot([1,2,3,4]);",
"format": "png"
}Plot Generation Notes:
- Output formats supported: PNG or SVG
You can run the Octave MCP server using Docker for easier deployment and isolation.
The Docker image uses a multi-stage build process:
- Build stage: Uses
golang:alpinefor compiling the binary - Runtime stage: Uses the official
gnuoctave/octaveimage - This approach reduces the final image size and improves security
Build and run the server:
docker-compose up --buildThe server will be available at http://localhost:8080.
Build the image:
docker build -t octave-mcp -f docker/Dockerfile .Run the container:
docker run -p 8080:8080 octave-mcpTo verify the Docker image is working correctly:
-
Start the container:
docker-compose up -d
-
Use a tool like MCP Inspector to verify the server is accessible at http://localhost:8080/mcp
-
Check the logs:
docker-compose logs octave-mcp
-
Stop the container:
docker-compose down
The server accepts the following flags:
-http: HTTP address to listen on (empty for stdio mode)
The following environment variables can be used to configure server behavior:
OCTAVE_SCRIPT_TIMEOUT: Script execution timeout in seconds (default: 10)OCTAVE_CONCURRENCY_LIMIT: Maximum concurrent executions (default: 10)OCTAVE_SCRIPT_LENGTH_LIMIT: Maximum script length in characters (default: 10000)OCTAVE_MCP_ALLOW_NON_LOCALHOST: Set totrueto allow non-localhost connections (default:false). Use with caution in production environments.
- Scans scripts for dangerous patterns
- Filters output to remove sensitive information
- Uses temporary directories with restricted permissions
When running in HTTP mode:
- Only accepts connections from localhost (unless
OCTAVE_MCP_ALLOW_NON_LOCALHOST=trueis set) - Implements strict CORS and security headers
- Validates request origins
This project is licensed under the GNU General Public License v3.0. See LICENSE for the full license text.
