Wolfram Mathematica MCP server

Bridges to Wolfram Mathematica for executing Wolfram Language code in secure, session-based environments with animal-themed identifiers, enabling mathematical computations, symbolic algebra, data analysis, and scientific modeling tasks.
Back to servers
Setup instructions
Provider
aac6fef
Release date
Jul 26, 2025
Stats
1 star

This MCP server provides a way to integrate Wolfram Mathematica with Large Language Models (LLMs), enabling them to execute Wolfram Language code in secure, session-based environments. The server facilitates communication between an LLM and a Mathematica kernel through the Model Context Protocol.

Prerequisites

  • Python 3.10 or higher
  • uv Python package manager (install from https://astral.sh/uv/install.sh)
  • A local installation of the Wolfram Engine or Mathematica (required for the wolframclient library)

Installation & Setup

Set the Security Key

The server requires a secret key to generate secure session IDs. You must set this as an environment variable:

export ANIMALID_SECRET_KEY='your-super-secret-and-long-key-here'

Note: Use a strong, unique key and never hardcode it in scripts.

Usage

The server needs to be connected to an MCP-compatible client, such as Claude for Desktop.

Configure the MCP Client

Open your client's MCP configuration file (e.g., claude_desktop_config.json for Claude for Desktop) and add the following server configuration:

{
  "mcpServers": {
    "mathematica": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/your/project/my_mcp",
        "run",
        "wolfram_mathematica.py"
      ],
       "env": {
            "ANIMALID_SECRET_KEY": "default-secret-key-for-dev"
          }
    }
  }
}

Important: Replace /path/to/your/project/my_mcp with the absolute path to the project directory on your system.

If uv is not in your system's PATH, you may need to use its full path in the command field. Find it by running which uv (macOS/Linux) or where uv (Windows).

Available Tools

Once configured, the following tools will be available to your LLM:

  1. create_mathematica_session: Initializes a new Wolfram Language session and returns a unique session ID
  2. execute_mathematica_code: Executes Wolfram Language code within a specified session
  3. close_mathematica_session: Terminates a session and releases its resources

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mathematica" '{"command":"uv","args":["--directory","/path/to/your/project/my_mcp","run","wolfram_mathematica.py"],"env":{"ANIMALID_SECRET_KEY":"default-secret-key-for-dev"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mathematica": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/your/project/my_mcp",
                "run",
                "wolfram_mathematica.py"
            ],
            "env": {
                "ANIMALID_SECRET_KEY": "default-secret-key-for-dev"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mathematica": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/your/project/my_mcp",
                "run",
                "wolfram_mathematica.py"
            ],
            "env": {
                "ANIMALID_SECRET_KEY": "default-secret-key-for-dev"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later