Skip to main content
Glama
aac6fef

Mathematica MCP Server

by aac6fef

close_mathematica_session

Terminates a specific Wolfram Language session and releases associated resources to free up system memory and kernel licenses. Use to close active sessions efficiently.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Implementation Reference

  • The core handler function for the 'close_mathematica_session' tool. Decorated with @mcp.tool() which also handles registration in the FastMCP server. Validates session ID using AnimalIdGenerator, terminates the WolframLanguageSession, removes it from the global sessions dictionary, and returns a success message or raises an error.
    @mcp.tool() def close_mathematica_session(session_id: str) -> str: """ 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. """ # 验证 session_id if not id_generator.verify(session_id): raise ValueError("Invalid session ID.") session = sessions.get(session_id) if not session: raise ValueError(f"Session with ID '{session_id}' not found or already closed.") try: # 终止会话并从字典中移除 session.terminate() del sessions[session_id] return f"Session '{session_id}' closed successfully." except Exception as e: raise RuntimeError(f"An error occurred while closing session '{session_id}': {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