Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

Mathematica MCP Server

This repository contains a Model Context Protocol (MCP) server that allows MCP clients (like Cursor) to execute Mathematica code via wolframscript and verify mathematical derivations.

Overview

This server acts as a bridge, enabling applications that support MCP to leverage the power of a local Mathematica installation for tasks such as:

  • Performing complex mathematical calculations.
  • Verifying mathematical derivation steps provided by humans or AI models.
  • Generating LaTeX or Mathematica string representations of expressions.

Prerequisites

  • Mathematica must be installed on your system.
  • The wolframscript command-line utility must be available in your system's PATH. You can test this by running wolframscript -help in your terminal.
  • Node.js (Recommended: v16 or later, as inferred from tsconfig.json target ES2022).

Installation

  1. Clone the repository:
    git clone <repository-url>
    cd <repository-directory>
    
  2. Install dependencies:
    npm install
    
  3. Build the server:
    npm run build
    
    This command compiles the TypeScript source code from src/ into JavaScript in the build/ directory and makes the main script executable.

Running the Server

To start the MCP server, run the following command in your terminal:

node build/index.js

The server will start and listen for connections from MCP clients via standard input/output (stdio). Keep this terminal window open while you intend to use the server.

For more robust deployments, consider using a process manager like pm2 to run the server in the background and manage restarts.

Integration with MCP Clients (e.g., Cursor, Cline, Claude Desktop)

MCP clients generally discover and communicate with running MCP servers. The exact configuration steps can vary depending on the client application.

General Steps:

  1. Start the Mathematica MCP Server: Ensure the server is running in a terminal:
    node build/index.js
    
  2. Configure Your MCP Client: Add the server to your client's configuration. This often involves editing a JSON settings file. See client-specific instructions below.
  3. Restart Your MCP Client: After starting the server or changing configuration, restart your client application to ensure it detects the Mathematica server.

Client-Specific Configuration:

  • Cline: According to the Cline MCP Server Development Protocol, you typically configure servers in a settings file (often settings.json within the Cline configuration directory). You would add an entry like this:

    {
      "mcpServers": {
        "mathematica-server": {
          "command": "node",
          "args": ["/full/path/to/mcp-server-mathematica/build/index.js"], // Replace with the actual absolute path
          "disabled": false,
          "autoApprove": [] // Optional: Add tool names to auto-approve
        }
        // ... other servers ...
      }
    }
    

    Replace /full/path/to/mcp-server-mathematica/build/index.js with the absolute path to the built index.js file on your system.

  • Cursor: Cursor might require editing a specific settings file, potentially like ~/Library/Application Support/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json (though this path might change). The structure would be similar to the Cline example above.

  • Other Clients (e.g., Claude Desktop): Consult the documentation for your specific MCP client. Look for sections on "MCP Servers," "Tool Configuration," or "External Tools." The configuration generally involves specifying the command (node), the path to the server script (build/index.js), and potentially environment variables if needed.

Available Tools

The server exposes the following tools to MCP clients:

1. execute_mathematica

Executes arbitrary Mathematica code and returns the result.

Input Schema:

{
  type: "object",
  properties: {
    code: {
      type: "string",
      description: "Mathematica code to execute"
    },
    format: {
      type: "string",
      description: "Output format (text, latex, or mathematica)",
      enum: ["text", "latex", "mathematica"],
      default: "text"
    }
  },
  required: ["code"]
}

Example Usage (Client Request):

  • Natural Language: "Calculate the integral of x^2 from 0 to 1 using Mathematica and format as LaTeX"
  • Direct Tool Call:
    {
      "tool_name": "execute_mathematica",
      "arguments": {
        "code": "Integrate[x^2, {x, 0, 1}]",
        "format": "latex"
      }
    }
    

2. verify_derivation

Verifies a sequence of mathematical expressions to check if each step logically follows from the previous one using Simplify[prev == current].

Input Schema:

{
  type: "object",
  properties: {
    steps: {
      type: "array",
      description: "Array of mathematical expressions (as strings) representing steps in a derivation. Requires at least two steps.",
      items: {
        type: "string"
      }
    },
    format: {
      type: "string",
      description: "Output format for the verification report (text, latex, or mathematica)",
      enum: ["text", "latex", "mathematica"],
      default: "text"
    }
  },
  required: ["steps"]
}

Example Usage (Client Request):

  • Natural Language: "Verify this derivation: ['x^2 - y^2', '(x-y)(x+y)']"
  • Direct Tool Call:
    {
      "tool_name": "verify_derivation",
      "arguments": {
        "steps": [
          "x^2 - y^2",
          "(x-y)*(x+y)"
        ],
        "format": "text"
      }
    }
    

Troubleshooting

  • Server Not Found/Not Responding:
    • Ensure the server is running in a terminal (node build/index.js).
    • Check if wolframscript is installed and accessible in your PATH (wolframscript -help).
    • Restart your MCP client application.
    • Check the client's MCP configuration.
  • Tool Errors:
    • Check the server's terminal output (stderr) for logs and error messages from wolframscript.
    • Verify the syntax of the Mathematica code or steps provided.
    • Ensure the steps array for verify_derivation has at least two elements.
  • Mathematica Issues: Ensure your Mathematica installation is licensed and working correctly.

Project Structure

  • src/: TypeScript source code for the server.
  • build/: Compiled JavaScript output (generated by npm run build).
  • package.json: Project metadata and dependencies.
  • tsconfig.json: TypeScript compiler configuration.

相关推荐

  • av
  • Exécutez sans effort LLM Backends, API, Frontends et Services avec une seule commande.

  • 1Panel-dev
  • 🔥 1Panel fournit une interface Web intuitive et un serveur MCP pour gérer des sites Web, des fichiers, des conteneurs, des bases de données et des LLM sur un serveur Linux.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 LLM 资料总结 (数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Résumé des meilleures ressources LLM du monde.

  • rulego
  • ⛓️RULEGO est un cadre de moteur de règle d'orchestration des composants de nouvelle génération légère, intégrée, intégrée et de nouvelle génération pour GO.

  • sigoden
  • Créez facilement des outils et des agents LLM à l'aide de fonctions Plain Bash / JavaScript / Python.

  • hkr04
  • SDK C ++ MCP (Protocole de contexte modèle léger)

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 QQ / 微信 (企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 Dify 、 Claude 、 GEMINI 、 XAI 、 PPIO 、 OLLAMA 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 ChatGlm 、 Sillytraven 、 MCP 等 LLM 的机器人 / Agent | Plateforme de bots de messagerie instantanée basés sur LLM, prend en charge Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • dmayboroda
  • Rag de conversation sur site avec des conteneurs configurables

  • modelscope
  • Commencez à construire des applications multi-agents LLM, plus facilement.

  • paulwing
  • Un référentiel de test créé à l'aide du service MCP

    Reviews

    3.3 (8)
    Avatar
    user_8sAvmzDS
    2025-04-24

    The mcp-server-mathematica by Texra-AI has significantly improved my computational workflow. It easily integrated with my existing infrastructure, offering robust performance and seamless mathematical computations. The support and documentation provided are excellent, making it user-friendly even for those new to such tools. Highly recommend this product for anyone in need of a powerful and reliable server for mathematical processing.

    Avatar
    user_eZz2qgs7
    2025-04-24

    As an avid user of MCP applications, I must say that mcp-server-mathematica by texra-ai is an exceptional tool. It seamlessly integrates complex mathematical computations with user-friendly interfaces, making it a versatile solution for both professionals and students. Highly recommended!

    Avatar
    user_WQAIWck0
    2025-04-24

    As a dedicated user of mcp-server-mathematica by texra-ai, I find it incredibly efficient and powerful for my computational needs. The seamless integration and user-friendly interface make complex mathematical tasks effortless. Highly recommend this for anyone looking for robust mathematical computing solutions.

    Avatar
    user_BXc7bmVm
    2025-04-24

    As a devoted user of mcp-server-mathematica by texra-ai, I am truly impressed. This product has revolutionized the way I handle complex computations and data analysis. The seamless integration and intuitive interface make it a joy to use, saving me a significant amount of time and effort. Highly recommended for anyone looking to enhance their mathematical and computational workflows.

    Avatar
    user_L007P7TC
    2025-04-24

    As a loyal user of mcp-server-mathematica by texra-ai, I am thoroughly impressed by its seamless integration and powerful capabilities in handling complex mathematical computations. Whether I'm solving advanced equations or performing data analysis, this tool consistently delivers accurate and efficient results. Highly recommended for anyone in need of a reliable and robust mathematical server.

    Avatar
    user_e2l3IHiW
    2025-04-24

    As a dedicated user of mcp applications, I must say mcp-server-mathematica by texra-ai is a game-changer. The functionality it provides for server-side Mathematica computations is impressive and indispensable for our projects. Setup was seamless, and the user experience has been consistently smooth since day one. Highly recommend for anyone needing advanced computational capabilities on their servers!

    Avatar
    user_0CoBC4mi
    2025-04-24

    As a loyal user of mcp applications, I am thoroughly impressed with mcp-server-mathematica by texra-ai. This tool significantly enhances server-side calculations, incorporating the powerful Mathematica capabilities directly into my workflow. Its seamless integration and intuitive interface make complex computations more accessible and efficient. Highly recommended for anyone in need of robust mathematical server operations!

    Avatar
    user_3btBFqVY
    2025-04-24

    As a dedicated user of MCP applications, I highly recommend the mcp-server-mathematica by texra-ai. It offers a seamless integration with Mathematica, providing a powerful server-side computation engine. The performance is robust and the user experience is smooth, enhancing productivity for complex mathematical tasks. Truly a game-changer for professionals in the field.