Using Epsil with AI Assistants
The epsil command includes a Model Context Protocol
(MCP) server. Connect it to ChatGPT, Claude Code, Claude Desktop, or another
MCP client, and your AI assistant can evaluate Epsil programs — exact
arithmetic, symbolic computation, calculus, linear algebra — instead of doing
math "in its head".
Epsil is experimental. Its syntax and behavior may change between releases.
Setup for Local MCP Clients
With Claude Code, register the server with a single command:
claude mcp add epsil -- npx -y @cortex-js/compute-engine mcp
For Claude Desktop and most other MCP clients, add the server to the client's JSON configuration:
{
"mcpServers": {
"epsil": {
"command": "npx",
"args": ["-y", "@cortex-js/compute-engine", "mcp"]
}
}
}
If the Compute Engine package is already installed in your project, you can
run the local copy instead of downloading one: use npx epsil mcp (that
is, "command": "npx", "args": ["epsil", "mcp"]).
That's it. The next time you start the client, the Epsil tools are available to the assistant.
Setup for ChatGPT
ChatGPT developer mode connects to a public HTTPS MCP endpoint using Streamable HTTP or to an OpenAI Secure MCP Tunnel; it cannot start the local stdio command directly. A Secure MCP Tunnel is the recommended way to connect the local Epsil server without opening an inbound port or making it public.
-
In ChatGPT, open Settings → Security and login and enable Developer mode. Availability depends on your account and workspace policy.
-
Create a tunnel in the OpenAI Platform tunnel settings, associate it with the ChatGPT workspace that will use Epsil, and copy its
tunnel_id. Downloadtunnel-clientfrom the link in those settings or from its latest release. -
Configure
tunnel-clientto launch Epsil over stdio, validate the configuration, and run it:export CONTROL_PLANE_API_KEY="sk-..."tunnel-client init \--sample sample_mcp_stdio_local \--profile epsil \--tunnel-id tunnel_0123456789abcdef0123456789abcdef \--mcp-command "npx -y @cortex-js/compute-engine mcp"tunnel-client doctor --profile epsil --explaintunnel-client run --profile epsilReplace the example API key and tunnel ID with your own values. Keep
tunnel-client runrunning while using Epsil from ChatGPT. -
In ChatGPT, open Settings → Plugins, select the plus button, choose Tunnel under Connection, and select the tunnel you created.
-
Start a new conversation, add Epsil from the tools menu, and try one of the prompts below. ChatGPT should discover the six Epsil tools and use
evaluatefor a computation.
See OpenAI's developer-mode connection guide for current availability and interface details.
Alternative: Public Development Endpoint
You can instead start Epsil's native Streamable HTTP transport and expose it through an HTTPS development tunnel.
-
Start the local HTTP endpoint:
npx -y @cortex-js/compute-engine mcp \--transport streamable-http \--port 8000The MCP endpoint is now available locally at
http://localhost:8000/mcp. -
In another terminal, expose port 8000 with an HTTPS tunnel that supports streaming. For example, with ngrok:
ngrok http 8000 -
Append
/mcpto the HTTPS forwarding URL printed by ngrok. For example:https://example.ngrok.app/mcp. -
In ChatGPT, open Settings → Plugins, select the plus button, and create a connection using the public
/mcpURL. Do not enter the localhost URL; ChatGPT must be able to reach the endpoint from the Internet.
The public development URL is temporary and, unless you configure tunnel authentication, reachable by anyone who knows it while both processes are running. Stop the tunnel and Epsil server after testing. For shared or production use, use Secure MCP Tunnel or put the HTTP endpoint behind a stable HTTPS reverse proxy with appropriate authentication, rate limits, logging, and monitoring.
What the Assistant Gets
| Tool | Purpose |
|---|---|
evaluate | Run an Epsil program and return its value — as display text, Epsil source, LaTeX, and MathJSON — along with any diagnostics; format: "latex" evaluates a single LaTeX expression instead; fancySymbols: true writes the Epsil source with the Unicode notations (√x, x², ×, ⩽, …) |
check | Validate a program without evaluating it; effects: true adds the inferred effects of each top-level function |
doc | Look up a library function by name, or search the library by keywords |
parse | Convert Epsil source, or LaTeX with format: "latex", to MathJSON |
serialize | Convert MathJSON to Epsil source, or to LaTeX with format: "latex"; fancySymbols: true for the Unicode notations |
compile | Show the code a compilation target (JavaScript, GLSL, WGSL, Python, interval JavaScript) generates for a program or a LaTeX expression, or why the target declines it |
The server also publishes the language card for AI agents
as a resource (epsil://docs/for-agents), and its setup instructions tell
the assistant to read it before writing Epsil — so the assistant learns the
language's syntax and idioms on its own.
A second resource, epsil://docs/compute-engine-api, is the
Compute Engine card for AI agents: a guide to
the JavaScript API for an assistant writing code that uses the
@cortex-js/compute-engine library. The setup instructions point to it too.
Formulas in LaTeX
An assistant often has a formula in LaTeX already: from a paper, from the
conversation, or from a math editor. It does not need to translate it into
Epsil first. evaluate and parse accept format: "latex", and then take a
single LaTeX expression instead of a program:
{ "source": "\\int_0^1 x^2\\,dx", "format": "latex" }
The result has the same shape as for an Epsil program: value, epsil,
latex and mathjson, with diagnostics listing any LaTeX parse error and
the fragment where it occurred. In the other direction, serialize with
format: "latex" writes a MathJSON expression as LaTeX, and every
evaluate result includes a latex form of the value, ready to display.
For anything with several steps or definitions, an Epsil program is still the better fit.
Compiling
compile shows what the Compute Engine generates for an expression on a
compilation target, without running it. It is useful to an assistant that
writes code which compiles expressions, or that investigates why a
compilation fails:
{
"source": "\\arg(z)+1",
"format": "latex",
"to": "glsl",
"declarations": { "z": "complex" }
}
The result has ok, the generated code (atan(z.y, z.x) + 1.0), and
freeSymbolTypes: for each free symbol, its type, the type the target reads
it as (here vec2, the uniform to declare), and whether it was declared or
inferred. When the target declines, ok is false, there is no code, and
error and diagnostic give the reason. to is javascript (the default),
glsl, wgsl, python or interval-js, and mode selects the arithmetic
discipline: auto (the default), strict or complex.
Each call uses a new engine. A symbol that is not declared has the type
inferred from its uses, so declare the types the compilation depends on with
declarations, a map from symbol name to type. A declaration of a name the
library defines, such as Pi, replaces that definition, and the result has a
warnings entry that says so. A compilation has the same deadline as an
evaluation (timeLimit).
Trying It Out
Ask your assistant something that benefits from exact computation, and mention Epsil if it doesn't reach for the tools on its own:
- "Use Epsil to compute the exact value of the sum of 1/k² for k from 1 to 100."
- "Solve x³ − 6x² + 11x − 6 = 0 exactly with Epsil."
- "What does the Epsil function
reducedo?" - "Evaluate
\int_0^\infty e^{-x^2}\,dxwith Epsil."
The assistant writes a small Epsil program, runs it with the evaluate
tool, and reports the result — exact fractions, radicals, and symbolic
constants included, with none of the rounding or slips of doing arithmetic
token by token.
Good to Know
- Each
evaluatecall is independent. A call runs a complete program in a fresh session; definitions do not carry over from one call to the next. The assistant knows this and writes self-contained programs. - Evaluations have a deadline. By default a program is canceled after
10 seconds. Start the server with
epsil mcp --time-limit <ms>to change the default (0disables it); the assistant can also adjust it per call. - The computation runs locally by default. The server is part of the npm
package, and programs evaluate in the Node.js process that runs
epsil mcp. A ChatGPT connection still uses the configured Secure MCP Tunnel or HTTPS endpoint to reach that process. - The HTTP transport is local by default. It binds to
127.0.0.1, limits requests to 1 MiB, and rejects unapproved browser origins. Use--host,--port, and--pathto configure the listener. Repeat--allow-origin <origin>for browser clients that run on another origin. Binding to a public interface does not add authentication or TLS.