Mathematica-MCP-Server

jkoets/Mathematica-MCP-Server

3.2

If you are the rightful owner of Mathematica-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This MCP server integrates Wolfram Mathematica with Claude for advanced mathematical computations and visualizations.

Tools
6
Resources
0
Prompts
0

Mathematica MCP Server

This MCP (Model Context Protocol) server provides Claude with access to Wolfram Mathematica for advanced mathematical computation, symbolic manipulation, and visualization.

I've got Mathematica 14.3 installed and it works well with that, but I've not tested with other versions. As long as you're pointing to your version of wolframscript.exe, you'll probably be ok.

Features

  • Symbolic Mathematics: Solve equations, integrate, differentiate, manipulate expressions
  • Numerical Computation: High-precision calculations, numerical methods, optimization
  • Graphics & Visualization: Create plots, 3D graphics, contour plots, and more
  • Session Management: Maintain state between evaluations for complex workflows
  • Full Mathematica Access: Any Mathematica function or operation is available

Prerequisites

  • Wolfram Mathematica (version 12.x or later recommended, tested with 14.3)
  • Python 3.8+
  • WolframScript must be accessible from the command line

Verifying WolframScript Installation

Open a command prompt and run:

wolframscript -code "2+2"

If this returns 4, you're all set! If not, you may need to add Mathematica to your PATH.

Installation

  1. Install Python dependencies:

    cd path/to/Mathematica_mcp
    python -m venv venv
    venv\Scripts\pip install -r requirements.txt
    
  2. Configure Claude Desktop:

    Add this to your claude_desktop_config.json (typically at %APPDATA%\Claude\claude_desktop_config.json):

    {
      "mcpServers": {
        "mathematica": {
          "command": "path/to/Mathematica_mcp/venv/Scripts/python.exe",
          "args": ["path/to/Mathematica_mcp/server.py"],
          "env": {
            "PYTHONUNBUFFERED": "1"
          }
        }
      }
    }
    

    Replace path/to/Mathematica_mcp with your actual installation path.

  3. Restart Claude Desktop

Available Tools

mathematica_evaluate

Main tool for evaluating Mathematica code. Handles symbolic and numerical computations.

Parameters:

  • code: Mathematica expression to evaluate
  • output_format: "text" (default), "plaintext", or "formatted"

Examples:

Integrate[x^2, x]
Solve[x^2 - 5x + 6 == 0, x]
FactorInteger[123456789]
D[Sin[x]*Cos[x], x]
Limit[Sin[x]/x, x -> 0]

mathematica_evaluate_with_graphics

Evaluate code that produces graphics and export the result to a file.

Parameters:

  • code: Mathematica code that generates graphics
  • export_format: "png" (default), "svg", or "pdf"
  • image_size: Width in pixels (default: 800)

Examples:

Plot[Sin[x], {x, 0, 2Pi}]
Plot3D[Sin[x*y], {x, -3, 3}, {y, -3, 3}]
ContourPlot[x^2 + y^2, {x, -2, 2}, {y, -2, 2}]
ListPlot[Table[{x, x^2}, {x, 0, 10}]]

mathematica_session_evaluate

Evaluate code in a persistent session that maintains state between calls.

Use Cases:

  • Define functions once, use multiple times
  • Load large datasets once
  • Build complex computations incrementally

Example Workflow:

Call 1: f[x_] := x^2 + 2x + 1
Call 2: f[5]  (* Returns 36 *)
Call 3: D[f[x], x]  (* Returns 2 + 2x *)

mathematica_clear_session

Clear all definitions and state from the persistent session.

mathematica_get_info

Get version information and system details about your Mathematica installation.

mathematica_help

Get documentation for Mathematica functions.

Example:

mathematica_help("Integrate")

Usage Examples

Basic Calculus

Integrate[Exp[x]*Sin[x], x]
D[x^3 + 2x^2 - x + 1, {x, 2}]
Limit[(1 + 1/n)^n, n -> Infinity]

Solving Equations

Solve[x^3 - 6x^2 + 11x - 6 == 0, x]
DSolve[y'[x] == y[x], y[x], x]
NSolve[x^5 - x - 1 == 0, x]

Linear Algebra

Eigenvalues[{{1, 2}, {3, 4}}]
Inverse[{{1, 2, 3}, {4, 5, 6}, {7, 8, 10}}]
Det[{{a, b}, {c, d}}]

Statistics

Mean[{1, 2, 3, 4, 5}]
StandardDeviation[{1, 2, 3, 4, 5}]
PDF[NormalDistribution[0, 1], x]

Number Theory

PrimeQ[1000000007]
FactorInteger[123456789]
GCD[12345, 67890]

Tips for Use

  1. Complex Expressions: Mathematica can handle very complex symbolic expressions. Don't hesitate to ask for complicated integrals or equation solving.

  2. Verification: Use Mathematica to verify mathematical results or check your work.

  3. Symbolic vs Numerical: By default, Mathematica tries symbolic computation. Use N[expr] to get numerical approximations.

  4. Graphics: Always use mathematica_evaluate_with_graphics for plots and visualizations. The tool will save the image and tell you where to find it.

  5. Sessions: Use session mode when defining functions or working with definitions that span multiple operations.

Troubleshooting

"WolframScript not found"

  • Ensure Mathematica is installed
  • Add WolframScript to your system PATH
  • On Windows, typically: C:\Program Files\Wolfram Research\Mathematica\14.3\

Timeouts

  • Complex computations have a 5-minute timeout
  • Break very long computations into smaller steps
  • Consider using session mode for incremental work

Session Issues

  • If a session gets corrupted, use mathematica_clear_session to start fresh
  • Sessions reset when the MCP server restarts

What's New in Version 14.3

Your Mathematica 14.3 includes many modern features:

  • Enhanced machine learning capabilities
  • Improved symbolic tensor operations
  • Better performance for large-scale computations
  • Extended visualization options
  • More comprehensive special functions

Explore the new features at: https://www.wolfram.com/mathematica/new-in-14/

License

This MCP server is a wrapper around Wolfram Mathematica. You must have a valid Mathematica license to use this tool.

Support

For Mathematica-specific questions, consult the official documentation:

For MCP server issues, check that:

  1. WolframScript is accessible from command line
  2. Claude Desktop configuration is correct
  3. Python dependencies are installed