Skip to main content
Glama
youngsu-Kim

macaulay2-mcp

by youngsu-Kim

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
M2_BINNoPath 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_JOURNALNoDirectory 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_ALLOWNoComma-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

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
m2_evaluateA

Evaluate Macaulay2 code in the persistent session and return its output.

    State (rings, variables, ideals, ...) persists across calls. M2 errors
    are included in the returned text and do not break the session.
    Separate statements with newlines: a trailing ";" suppresses that
    statement's result (use an explicit "print" to force output).

    Args:
        code: Macaulay2 code, e.g. "R = QQ[x,y,z]

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. With stop_on_error=True the budget applies PER INPUT. 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). show_memory: True (default) appends one line naming the kernel's memory (resident + peak; swap when it is paging) to the result; False omits it. The values are recorded in the journal either way.

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_memoryA

Report the persistent Macaulay2 kernel's memory: RSS, peak, swap, pid, uptime.

Reads the operating system's bookkeeping for the kernel child process — an unprivileged read; nothing is sent to M2 and the session is untouched. Peak comes from kernel-tracked counters (no sampler involved); swap is M2's own swapped pages on Linux, or the system-wide swap growth since this kernel started on macOS (no unprivileged per-process counter exists there). The probe is lock-free: call it WHILE a long m2_evaluate runs to watch memory live before deciding whether m2_interrupt is worthwhile. RSS reads as a high-water mark because M2 rarely returns freed pages to the OS.

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 print output is returned — the script must print its own results.

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

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A4.4/5.0

Scored across 9 tools

Disambiguation5/5

Each tool targets a clearly distinct operation: persistent evaluation vs. isolated script execution vs. file import, package management, help, memory, and interrupt. The few potential overlaps (e.g., m2_evaluate vs. m2_import_file) are well-separated by input source and session-state semantics.

Naming Consistency4/5

All tools use the same m2_ prefix and snake_case, making the set highly readable. Minor deviations from a strict verb_noun pattern appear in m2_session_reset (noun_verb) and single-word tools like m2_help, m2_memory, and m2_interrupt.

Tool Count5/5

The 9 tools are well-scoped for controlling a Macaulay2 session. Each tool covers a discrete need (execute, batch, import, packages, help, reset, memory, interrupt) without redundancy.

Completeness5/5

The surface covers the full session lifecycle: code evaluation, batch execution, file import, package listing/loading, documentation lookup, kernel reset, memory monitoring, and interruption. No obvious gaps exist for the stated domain, and noted M2 limitations (e.g., no unload) are appropriately handled.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive