Mathematica MCP Server
Enables execution of Wolfram Language code in a secure, session-based environment, with tools for session initialization, code execution, and resource management.
Provides tools for creating sessions, executing Wolfram Language code, and managing session resources within a Mathematica kernel, enabling secure, session-based interaction with Wolfram Language.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Mathematica MCP Server solve the equation x^2 + 3x - 4 = 0"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Mathematica MCP Server
This project provides a Model Context Protocol (MCP) server for interacting with a Wolfram Mathematica kernel. It allows Large Language Models (LLMs) to execute Wolfram Language code in a secure, session-based environment.
The animalid folder contains a simple tool for generating unique, animal-based identifiers. Since LLMs often fail to copy UUIDs correctly, this tool replaces them with animal-themed IDs that are more likely to be transcribed accurately.
Tools Provided
create_mathematica_session: Initializes a new Wolfram Language session and returns a unique session ID.execute_mathematica_code: Executes Wolfram Language code within a specified session.close_mathematica_session: Terminates a session and releases its resources.
Related MCP server: Wolfram Language MCP
Prerequisites
Python 3.10 or higher.
uvPython package manager. (Installation guide)A local installation of the Wolfram Engine or Mathematica. The
wolframclientlibrary requires this to function.
Installation & Setup
Set the Security Key:
This server uses 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: Do not use a weak key or hardcode it in the script.
Usage
To use this server, you need to connect it 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.jsonfor Claude for Desktop) and add the following server configuration.Important: Replace
/path/to/your/project/my_mcpwith the absolute path to this project's directory on your system.{ "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" } } } }You may need to use the full path to the
uvexecutable in thecommandfield if it's not in your system's PATH. You can find it by runningwhich uv(macOS/Linux) orwhere uv(Windows).
screenshot

Available Tools
3 toolsclose_mathematica_sessionA
Terminates a specific Wolfram Language session and releases all associated resources.
It is good practice to call this tool when you are finished with a session to free up system memory and kernel licenses. Once a session is closed, its ID can no longer be used.
Args: session_id: The unique identifier of the session you wish to close. This must be an ID from an active, open session. Example: 'bee-sloth-auk-mole'.
Returns: A confirmation message indicating that the session was successfully closed.
Inputs: session_id (required). Returns: result
create_mathematica_sessionA
Creates and initializes a new, isolated Wolfram Language session.
This tool is the first step for any Mathematica-related task. It returns a unique, secure session identifier (e.g., 'fox-wolf-bear-lion') that you MUST use in subsequent calls to 'execute_code' and 'close_session'.
Each session is completely independent and maintains its own state (variables, function definitions, etc.).
Returns: A string containing a success message and the unique session ID. Example: "Session created successfully. Your session ID is: bee-sloth-auk-mole"
Inputs: no named parameters. Returns: result
execute_mathematica_codeA
Executes a string of Wolfram Language code within a specific, active session.
To use this tool, you must provide a valid 'session_id' obtained from a previous call to 'create_session'. The code will be executed in the context of that session, meaning it can access variables and functions defined in previous calls within the same session.
Args: session_id: The unique identifier for an active session, provided by 'create_session'. Example: 'bee-sloth-auk-mole'. code: A string containing the Wolfram Language code to be executed. The code should be syntactically correct. Example 1 (simple calculation): 'Total[Range[100]]' Example 2 (symbolic computation): 'Solve[x^2 - 5x + 6 == 0, x]' Example 3 (data visualization): 'Plot[Sin[x], {x, 0, 2 Pi}]'
Returns: The direct result of the code execution from the Wolfram Engine. The data type can vary (e.g., integer, list, string, or a complex expression). For plots, it may return a representation of the graphics object.
Inputs: code (required), session_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose with no overlap: create_mathematica_session initiates sessions, execute_mathematica_code runs code within them, and close_mathematica_session terminates them. The descriptions reinforce these distinct roles, making misselection unlikely.
All tools follow a consistent verb_noun pattern with 'mathematica' as a prefix (create_mathematica_session, execute_mathematica_code, close_mathematica_session). The naming is predictable and enhances readability across the set.
With 3 tools, this server is well-scoped for its purpose of managing Mathematica sessions and code execution. Each tool earns its place by covering the essential lifecycle: create, execute, and close, without unnecessary bloat or gaps.
The tool set provides complete CRUD/lifecycle coverage for the domain of Wolfram Language sessions: creation, execution, and termination. There are no obvious gaps, as agents can manage sessions end-to-end without dead ends.
Maintenance
Related MCP Connectors
Build Apps and run code in 30 languages — sandboxed, with persistent sessions for agent loops.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Access Pollinations models and API capabilities through agent tools.
Enable Large Language Model clients to interact seamlessly with any MediaWiki wiki. Perform action…
Related MCP Servers
- AlicenseCqualityCmaintenanceEnables AI agents to run Mathematica code, control live notebooks, and verify results through natural language.8261 PyPI57MIT
- AlicenseNot gradedqualityDmaintenanceEnables mathematical computation via Wolfram Language/Mathematica integration, supporting calculations, equation solving, calculus, matrix operations, and symbolic mathematics.13MIT
- AlicenseAqualityCmaintenanceEnables AI agents to interact with the Baltamatica scientific computing kernel, executing code, managing variables, and running scripts while preserving workspace state across calls.65MIT
- AlicenseAqualityBmaintenanceEnables an AI agent to run Wolfram Language in a persistent Mathematica kernel, interrupt running computations while preserving state, and replay notebooks in a headless environment.14Do What The F*ck You Want To Public