Skip to main content
Glama
aac6fef

Mathematica MCP Server

by aac6fef

create_mathematica_session

Initiate a new, isolated Wolfram Language session for Mathematica computations. Obtain a unique session ID to manage state, execute code, and maintain independence across tasks.

Instructions

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"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'create_mathematica_session' tool. It is decorated with @mcp.tool() for registration and implements the logic to create a new Wolfram Mathematica session using WolframLanguageSession, store it in a sessions dictionary with a unique animal ID, and return the session ID.
    @mcp.tool() def create_mathematica_session() -> str: """ 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" """ session_id = id_generator.generate() try: # 创建一个新的 Wolfram Language 会话, 使用自动检测到的内核路径 session = WolframLanguageSession(KERNEL_PATH) sessions[session_id] = session return f"Session created successfully. Your session ID is: {session_id}" except Exception as e: raise RuntimeError(f"Failed to create Wolfram Language session: {e}") from e

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aac6fef/mathematica_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server