macaulay2-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| M2_BIN | No | Path to the Macaulay2 executable if it is installed in a non-standard location. The server looks for M2 in standard Homebrew locations by default. | |
| MACAULAY2_MCP_JOURNAL | No | Directory where the audit journal is written, or 'off' to disable journaling. Defaults to './.m2-mcp' in the project working directory. | ./.m2-mcp |
| MACAULAY2_MCP_OS_ALLOW | No | Comma-separated list of M2 OS-symbols (e.g., 'lines,openOut') to unblock from the OS-access gate. Leave unset to keep all OS-level functions blocked. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| m2_evaluateA | Evaluate Macaulay2 code in the persistent session and return its output. I = ideal(x^3 - y, x^4 - z) print generators (gb I)" timeout_s: Author-set safety limit (default 120, max 3600). Raise it for heavy computations (large Groebner bases, Hilbert polynomials, ...). On timeout the session is restarted, so the retried code must include all setup again. stop_on_error: Default False = REPL semantics (an error does not stop later lines from running). True sends the code input by input and halts at the first error, leaving later inputs unexecuted. Requires each line to be a self-contained statement (do not break a line after a binary operator). |
| m2_interruptA | Interrupt the Macaulay2 computation currently running in the session. Use this when the user wants to cancel or stop a long-running m2_evaluate. It sends a software interrupt (SIGINT), which M2 handles at safe checkpoints: the running m2_evaluate call returns with an "error: interrupted" message, and everything defined by statements that completed BEFORE the interrupted one stays available — the session does not restart. If nothing is running, this is a harmless no-op. In the rare case of a computation that ignores the interrupt (deep engine loops), the running m2_evaluate's own timeout_s remains the backstop: it kills and restarts the kernel on expiry. |
| m2_session_resetA | Restart the Macaulay2 kernel, discarding ALL session state. Use before starting a fresh line of computation, or whenever the session seems corrupted. After a reset, rings and definitions from earlier calls no longer exist. |
| m2_helpA | Look up Macaulay2 documentation for a function, class, or concept. Args: topic: Documentation entry point, e.g. "groebnerBasis", "resolution", "HilbertPolynomial", "Package". |
| m2_run_scriptA | Run a .m2 file in a FRESH, isolated Macaulay2 process. Does not touch the persistent session (and its state is not visible
afterwards). Use for long or self-contained computations, or when a
repeated m2_evaluate timeout suggests a heavy job. This is batch mode:
only explicit Args: path: ABSOLUTE path to the .m2 file, e.g. "/tmp/compute.m2". timeout_s: Author-set safety limit (default 120, max 3600). On timeout the process is killed and any partial output is returned. |
| m2_list_packagesA | List the Macaulay2 packages currently loaded in the session. Returns the package names, e.g. {Varieties, Complexes, PrimaryDecomposition, Core, ...}. |
| m2_load_packageA | Load a Macaulay2 package into the session. Packages stay loaded until the session is reset (M2 has no unload operation). Loading an already-loaded package is a harmless no-op: the tool reports that and changes nothing. Use reload=True ONLY when the package's source on disk changed and must be re-read (M2's reload machinery is fragile for packages with dependencies). Args: name: Package name as it appears on the M2 search path, e.g. "HilbertSchemes", "CommutativeAlgebra", "BoijSoederberg". reload: Re-read the package from disk even if already loaded (package-development workflow; leave False otherwise). |
| m2_import_fileA | Import a local .m2 file INTO the persistent session. Reads the file and evaluates its contents in the session, so newly defined or updated functions/variables become available immediately — no session restart needed. This is the M2 equivalent of what Emacs does when you "load" a file into a running kernel. Re-importing re-defines the file's symbols. Args: path: ABSOLUTE path to the .m2 file to import. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 8 tools
The tools are largely distinct: evaluating code, interrupting, resetting, getting help, running scripts, and managing packages each have clear roles. The only mild overlap is between m2_evaluate, m2_import_file, and m2_run_script, but their descriptions clearly separate persistent-session evaluation, file import into the session, and isolated batch execution.
All tools share the m2_ prefix and most follow a verb_noun pattern like run_script, list_packages, load_package, and import_file. Minor deviations include m2_session_reset (object before verb instead of reset_session) and verb-only names like m2_evaluate, m2_interrupt, and m2_help, but the overall style is readable and predictable.
Eight tools is a well-scoped size for an interactive computation server. Each tool covers a necessary operation—evaluation, interrupt, reset, help, script execution, package listing, package loading, and file import—without redundancy or bloat.
The tool surface covers the full lifecycle of an interactive Macaulay2 session: evaluate code, interrupt long runs, reset state, load packages, import files, run standalone scripts, and access documentation. There are no obvious dead ends or missing operations for the stated purpose.