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.
uv
Python package manager (install from https://astral.sh/uv/install.sh)wolframclient
library)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.
The server needs to be connected to an MCP-compatible client, such as Claude for Desktop.
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).
Once configured, the following tools will be available to your LLM:
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.
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.
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"
}
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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