Skip to main content

MCP server for scientific computing with multiple backends

Project description

SciCompute MCP Server

MCP server for scientific computing with multiple backends. Provides AI coding assistants with mathematical computation and visualization capabilities.

Features

  • Multiple computing backends (Mathematica, Octave, Python Scientific, R, SageMath)
  • Image output support (plots, graphics)
  • Automatic backend selection
  • Persistent session state (variables persist across calls)
  • Documentation query for unknown symbols
  • Multi-platform support (Claude Code, Claude Desktop, OpenCode/Crush)

Supported Backends

Backend Status Capabilities
Mathematica ✅ Ready symbolic, numeric, plot, image, audio
SageMath ✅ Ready symbolic, numeric, plot
Python Scientific ✅ Ready symbolic, numeric, plot
R ✅ Ready numeric, plot
Octave ✅ Ready numeric, plot
Maxima 🔒 Reserved symbolic, numeric, plot
MATLAB 🔲 Planned numeric, plot
Julia 🔲 Planned numeric, plot

Note: Maxima backend is available but disabled by default. To enable, uncomment the registration line in manager.py.

Installation

Quick Start (Recommended)

# Install and run with uvx (auto-manages environment)
uvx scicompute-mcp

# Or install with pip
pip install scicompute-mcp
scicompute-mcp

Install with Optional Backends

# With Mathematica support
pip install scicompute-mcp[mathematica]

# With Octave support
pip install scicompute-mcp[octave]

# With all backends
pip install scicompute-mcp[all]

Environment Architecture

┌─────────────────────────────────────────────────────────────┐
│                    MCP Server (Python 3.10+)                │
│  ┌─────────────┐ ┌─────────────┐ ┌────────────────────────┐ │
│  │ Mathematica │ │   Octave    │ │     py_scientific      │ │
│  │   Backend   │ │   Backend   │ │  (same Python env)     │ │
│  └──────┬──────┘ └──────┬──────┘ └────────────────────────┘ │
│         │               │                                    │
│         ▼               ▼                                    │
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐            │
│  │  Wolfram    │ │   octave    │ │      R      │   sage     │
│  │  Kernel     │ │   process   │ │   process   │  process   │
│  └─────────────┘ └─────────────┘ └─────────────┘            │
│         │               │               │          │         │
│         ▼               ▼               ▼          ▼         │
│   Independent     Independent      Independent   conda env  │
│   (official)      (apt/brew)       (apt/brew)  (Python 3.11)│
└─────────────────────────────────────────────────────────────┘

Key Points:

  • MCP server only needs one Python environment
  • Each backend (except py_scientific) runs as independent process, not sharing Python environment
  • SageMath requires separate conda environment (Python < 3.13)

Step 1: Install Computing Backends

Install the computing backends you need (not all required):

Python Scientific Backend

Pre-installed with the main package, no additional configuration needed.

SageMath Backend

SageMath requires Python < 3.13, must be installed separately via conda:

# Configure mirror (optional, recommended for users in China)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

# Create SageMath environment
conda create -n sage python=3.11 -y
conda install -n sage -c conda-forge sage -y

Configure path (choose one):

# Method A: Environment variable (recommended)
export SAGE_PATH="$HOME/miniconda3/envs/sage/bin/sage"

# Method B: Modify SAGE_PATH in code
# Edit src/scicompute_mcp/backends/sage.py

R Backend

# Ubuntu/Debian
sudo apt install r-base

# macOS
brew install r

# Windows: Download from CRAN

Octave Backend

# Ubuntu/Debian
sudo apt install octave gnuplot

# macOS
brew install octave gnuplot

# Windows: Download Octave installer

Mathematica Backend

  1. Purchase and install from Wolfram website
  2. Configure path:
export MATHEMATICA_KERNEL_PATH="/usr/local/Wolfram/Wolfram/14.3/Executables/WolframKernel"

Configuration

Environment Variables

Variable Description Example
SAGE_PATH SageMath path $HOME/miniconda3/envs/sage/bin/sage
MATHEMATICA_KERNEL_PATH WolframKernel path /usr/local/Wolfram/Wolfram/14.3/Executables/WolframKernel
SCICOMPUTE_PRIORITY Backend priority mathematica,sage,py_scientific

Claude Code (.mcp.json)

{
  "mcpServers": {
    "scicompute": {
      "command": "uvx",
      "args": ["scicompute-mcp"]
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "scicompute": {
      "command": "uvx",
      "args": ["scicompute-mcp"]
    }
  }
}

OpenCode / Crush (.opencode.json)

{
  "mcpServers": {
    "scicompute": {
      "type": "stdio",
      "command": "uvx",
      "args": ["scicompute-mcp"]
    }
  }
}

Local Development

For development or if you want to use a local installation:

{
  "mcpServers": {
    "scicompute": {
      "command": "/path/to/.venv/bin/python",
      "args": ["-m", "scicompute_mcp.server"]
    }
  }
}

Multi-Platform Support

This project supports multiple AI assistant platforms. Configuration templates are provided in the configs/ directory:

File Platform
configs/claude-code.json Claude Code
configs/claude-desktop.json Claude Desktop
configs/opencode.json OpenCode / Crush

Custom Prompts / Skills

Each platform has its own way to provide custom instructions:

Platform Directory Format
Claude Code .claude/skills/*.md Markdown
OpenCode / Crush .opencode/commands/*.md Markdown

This project includes pre-made skill files for both platforms to help the AI assistant use the computing backends effectively.

Tools

compute(code, backend?)

Execute scientific computing code.

# Plot with Octave
compute("x = 0:0.1:10; y = sin(x); plot(x, y)", "octave")

# Symbolic computation with SageMath
compute("integrate(sin(x), x)", "sage")
compute("diff(x^3 * exp(x), x)", "sage")

# Mathematica
compute("Plot[Sin[x], {x, 0, 2 Pi}]", "mathematica")
compute("Integrate[x^2, x]", "mathematica")

# R Statistics
compute("mean(rnorm(1000))", "r")
compute("hist(rnorm(1000))", "r")

# Python Scientific
compute("sp.integrate(sp.sin(sp.Symbol('x')), sp.Symbol('x'))", "py_scientific")

list_backends()

List all available backends and their capabilities.

stop(backend?)

Stop backend process and clear all state. Useful to reset variables or free memory.

stop()          # List running backends (does NOT stop any)
stop("octave")  # Stop specific backend
stop("ALL")     # Stop all running backends

Safety design: Calling stop() without arguments will NOT stop any backends. It returns a list of running backends. This prevents accidental data loss.

doc(symbol, backend?)

Query documentation for a symbol.

doc("Plot3D", "mathematica")  # Mathematica usage
doc("integrate", "sage")       # SageMath usage

Usage Examples

Ask your AI assistant:

Plot sin(x) from 0 to 2π

Calculate ∫x²dx from 0 to 1

Solve x² - 4 = 0

Look up NDSolve usage

Documentation

  • docs/sage.md - SageMath collaboration guide
  • docs/r.md - R collaboration guide
  • docs/maxima.md - Maxima collaboration guide
  • docs/octave.md - Octave collaboration guide

Requirements

  • Miniconda (recommended) or Python 3.10+
  • For SageMath backend: conda environment with Python 3.11
  • For R backend: R installation
  • For Octave backend: GNU Octave + gnuplot
  • For Mathematica backend: Wolfram Mathematica

License

Unlicense - Public Domain

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scicompute_mcp-0.1.0.tar.gz (106.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scicompute_mcp-0.1.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file scicompute_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: scicompute_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 106.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for scicompute_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0db7f689193f68d27921782411b693d154be98d0fd8e007ecca164ba42ebe9f6
MD5 604542c792394e393d15a9011cd17734
BLAKE2b-256 fe3e7b349ffa4e89f2c0e81ea6c9dfa14ab5fd3cd717d7577ce2e29266eda215

See more details on using hashes here.

File details

Details for the file scicompute_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scicompute_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for scicompute_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8481ef87356d071458a52738e5c1eaa08d4227b039a9e7b77123debfb2a0e2f4
MD5 3f103f67be44df4680ffbd1d40b14800
BLAKE2b-256 eb27c4905badc0e5df186a09cc7b6d6a913acd4b88c3890fd7d04f71a15037c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page