A MCP server in jlFriCAS or FriCAS

10 views
Skip to first unread message

Grégory Vanuxem

unread,
Mar 3, 2026, 12:54:05 PM (3 days ago) Mar 3
to fricas...@googlegroups.com
Hello,

I have implemented a draft version of a MCP server for FriCAS or jlFriCAS with AI help. For FriCAS only some minor modifications are necessary. You can see it in the commit: https://github.com/gvanuxem/jlfricas/commit/31f8615b2aa4a6bd09b3b7188efd207907e525fc

The following commits are some draft adjustments to configure and an example of a .json file for the client, Antigravity or Claude Desktop for example. Actually it should run on (jl)FriCAS built on top of SBCL on Linux). For a quick look at it, a simple git clone of https://github.com/gvanuxem/jlfricas and the mcp_config.json put in ~/.gemini/antigravity/ for Antigravity, see https://github.com/gvanuxem/jlfricas/tree/master/examples

And build it using:
./configure --enable-julia --enable-mcp (julia in the PATH)

Julia is required as of now, I just need to tweak the src/lisp/Makefile.in to support "pure" FriCAS.

Below is a test session done this morning, Only one thing to note, this session was run in Antigravity using Gemini Flash 3 (fast) and importantly, in the jlfricas sources folder. The documentation below is taken from the src/algebra/ directory by Gemini. I plan to add support of, in my settings, /usr/local/lib/fricas/target/x86_64-linux-gnu/src/algebra/, to avoid the need of the (jl)FriCAS sources.

I have not tested FriCAS to speak frankly but I do not see why that would not work.

So if you clone jlfricas, ./configure --enable-julia --enable-mcp  should do the trick + the  content of mcp_config.json put in the correct directory of your client and adapted to it.

The chat session:

Chat Conversation

Note: This is purely the output of the chat conversation and does not contain any raw data, codebase snippets, etc. used to generate the output.

User Input

Solve me numerically 0=3+x^2+5*x^3 using jlFriCAS

Running MCP tool

Planner Response

Numerical solution for the equation  using jlFriCAS yields the following roots:

Real Root:

Complex Roots:

These values were obtained by calling complexSolve(5*x^3 + x^2 + 3 = 0, 1.e-10) within the FriCAS environment.

User Input

Can you return results but not in LaTeX form

Planner Response

The numerical solutions for  in plain text are:

Real Root: x1 = -0.9156445838

Complex Roots: x2 = 0.3578222919 - 0.7261124531i x3 = 0.3578222919 + 0.7261124531i

User Input

What is the documentation of complexSolve please

Running MCP tool

Running MCP tool

Running MCP tool

Searched filesystem

Grep searched codebase

*Viewed [numsolve.spad](file:///home/greg/Git/jlfricas/src/algebra/numsolve.spad) *

Planner Response

The documentation for complexSolve (from the FloatingComplexPackage) describes it as a function for finding approximate complex solutions to systems of polynomial equations or rational functions.

Key Overloads and Usage

  • complexSolve(p, eps): Finds all complex solutions of the rational function p (or polynomial) with respect to its variable, using precision eps.
  • complexSolve(eq, eps): Finds all complex solutions of the equation eq.
  • complexSolve(lp, eps): Finds all complex solutions for a list of rational functions lp.
  • complexSolve(leq, eps): Finds all complex solutions for a list of equations leq.

Arguments

  1. Expression/Equation: The polynomial, rational function, or equation to solve.
  2. Precision (eps):
    • If you provide a Float (e.g., 1.e-10), the results are returned as Complex Floats.
    • If you provide a Fraction Integer (e.g., 1/10^10), the results are returned as Complex Rational Numbers.

Description from Source

"This is a package for the approximation of complex solutions for systems of equations of rational functions with complex rational coefficients. The results are expressed as either complex rational numbers or complex floats depending on the type of the precision parameter..."

The function internally uses the ComplexRootPackage for univariate cases and a Groebner-basis-based solver (GroebnerSolve) for multivariate systems to isolate roots before refining them to the requested precision.

User Input

Solve me 0=3+x^2+5*x^3 using jlFriCAS

Running MCP tool

Planner Response

The numerical solutions for the equation  are:

Real Root: x = -0.9156445838

Complex Roots: x = 0.3578222919 - 0.7261124531i x = 0.3578222919 + 0.7261124531i

These results were calculated with a precision of 10^-10.

User Input

Can you solve it symbolically?

Running MCP tool

Running MCP tool

Planner Response

The symbolic solutions for the equation 5x^3 + x^2 + 3 = 0 involve nested radicals. Here they are as provided by jlFriCAS:

Root 1:

           +-----------------+2
           |    +----+
   +---+   |45 \|2029  - 2027
(- \|- 3+1)3|-----------------
          \|        2
+ 
           +-----------------+
           |    +----+
   +---+   |45 \|2029  - 2027
(- \|- 3-1)3|----------------- - 2
          \|        2
/
           +-----------------+
           |    +----+
   +---+   |45 \|2029  - 2027
(15 \|- 3+15)3|-----------------
          \|        2

Root 2:

           +-----------------+2
           |    +----+
   +---+   |45 \|2029  - 2027
(- \|- 3-1)3|-----------------
          \|        2
+ 
           +-----------------+
           |    +----+
   +---+   |45 \|2029  - 2027
(- \|- 3+1)3|----------------- + 2
          \|        2
/
           +-----------------+
           |    +----+
   +---+   |45 \|2029  - 2027
(15 \|- 3-15)3|-----------------
          \|        2

Root 3:

    +-----------------+2    +-----------------+
    |    +----+             |    +----+
    |45 \|2029  - 2027      |45 \|2029  - 2027
   3|-----------------   - 3|-----------------  + 1
   \|        2             \|        2
x = ------------------------------------------------
                    +-----------------+
                    |    +----+
                    |45 \|2029  - 2027
                15 3|-----------------
                   \|        2

These solutions are derived using the cubic formula. The expression \|- 3 refers to the square root of -3 (proportional to the imaginary unit i).


If you have a Markdown previewer see the attached file from this session, it is badly transcripted in a mail.

Greg

Solving Polynomial.md

Grégory Vanuxem

unread,
Mar 3, 2026, 12:59:26 PM (3 days ago) Mar 3
to fricas...@googlegroups.com
I forgot to say, it requires cl-yason, I am in a hurry, sorry.
YASON is a JSON encoder/decoder for Common Lisp.

Qian Yun

unread,
Mar 4, 2026, 8:44:04 AM (2 days ago) Mar 4
to fricas...@googlegroups.com
Looks very interesting.

BTW, was the MCP interface itself written by LLM or human,
or both?

- Best,
- Qian

On 3/4/26 1:53 AM, Grégory Vanuxem wrote:
> Hello,
>
> I have implemented a draft version of a MCP server for FriCAS or
> jlFriCAS with AI help. For FriCAS only some minor modifications are
> necessary. You can see it in the commit: https://github.com/gvanuxem/
> jlfricas/commit/31f8615b2aa4a6bd09b3b7188efd207907e525fc <https://
> github.com/gvanuxem/jlfricas/
> commit/31f8615b2aa4a6bd09b3b7188efd207907e525fc>
>
> The following commits are some draft adjustments to configure and an
> example of a .json file for the client, Antigravity or Claude Desktop
> for example. Actually it should run on (jl)FriCAS built on top of SBCL
> on Linux). For a quick look at it, a simple git clone of https://
> github.com/gvanuxem/jlfricas <https://github.com/gvanuxem/jlfricas> and
> the mcp_config.json put in ~/.gemini/antigravity/ for Antigravity,
> see https://github.com/gvanuxem/jlfricas/tree/master/examples <https://
> github.com/gvanuxem/jlfricas/tree/master/examples>
>
> And build it using:
> ./configure --enable-julia --enable-mcp (julia in the PATH)
>
> Julia is required as of now, I just need to tweak the src/lisp/
> Makefile.in to support "pure" FriCAS.
>
> Below is a test session done this morning, Only one thing to note, this
> session was run in Antigravity using Gemini Flash 3 (fast) and
> importantly, in the jlfricas sources folder. The documentation below is
> taken from the src/algebra/ directory by Gemini. I plan to add support
> of, in my settings, /usr/local/lib/fricas/target/x86_64-linux-gnu/src/
> algebra/, to avoid the need of the (jl)FriCAS sources.
>
> I have not tested FriCAS to speak frankly but I do not see why that
> would not work.
>
> So if you clone jlfricas, ./configure --enable-julia --enable-mcp 
> should do the trick + the  content of mcp_config.json put in the correct
> directory of your client and adapted to it.
>
> The chat session:
>
>
> Chat Conversation
>
> Note: /This is purely the output of the chat conversation and does not
> contain any raw data, codebase snippets, etc. used to generate the output./
>
>
> User Input
>
> Solve me numerically 0=3+x^2+5*x^3 using jlFriCAS
>
> /Running MCP tool/
>
>
> Planner Response
>
> Numerical solution for the equation 5x3+x2+3=0 using jlFriCAS yields the
> following roots:
>
>
> Real Root:
>
> * x1≈−0.9156445838
>
>
> Complex Roots:
>
> * x2≈0.3578222919−0.7261124531i
> * x3≈0.3578222919+0.7261124531i
>
> These values were obtained by calling |complexSolve(5*x^3 + x^2 + 3 = 0,
> 1.e-10)| within the FriCAS environment.
>
>
> User Input
>
> Can you return results but not in LaTeX form
>
>
> Planner Response
>
> The numerical solutions for 5x3+x2+3=0 in plain text are:
>
> Real Root: x1 = -0.9156445838
>
> Complex Roots: x2 = 0.3578222919 - 0.7261124531i x3 = 0.3578222919 +
> 0.7261124531i
>
>
> User Input
>
> What is the documentation of complexSolve please
>
> /Running MCP tool/
>
> /Running MCP tool/
>
> /Running MCP tool/
>
> /Searched filesystem/
>
> /Grep searched codebase/
>
> *Viewed [numsolve.spad](file:///home/greg/Git/jlfricas/src/algebra/
> numsolve.spad) *
>
>
> Planner Response
>
> The documentation for |complexSolve| (from the |FloatingComplexPackage|)
> describes it as a function for finding approximate complex solutions to
> systems of polynomial equations or rational functions.
>
>
> Key Overloads and Usage
>
> * |complexSolve(p, eps)|: Finds all complex solutions of the rational
> function |p| (or polynomial) with respect to its variable, using
> precision |eps|.
> * |complexSolve(eq, eps)|: Finds all complex solutions of the
> equation |eq|.
> * |complexSolve(lp, eps)|: Finds all complex solutions for a list of
> rational functions |lp|.
> * |complexSolve(leq, eps)|: Finds all complex solutions for a list of
> equations |leq|.
>
>
> Arguments
>
> 1. Expression/Equation: The polynomial, rational function, or equation
> to solve.
> 2. Precision (|eps|):
> * If you provide a Float (e.g., |1.e-10|), the results are
> returned as Complex Floats.
> * If you provide a Fraction Integer (e.g., |1/10^10|), the results
> are returned as Complex Rational Numbers.
>
>
> Description from Source
>
> /"This is a package for the approximation of complex solutions for
> systems of equations of rational functions with complex rational
> coefficients. The results are expressed as either complex rational
> numbers or complex floats depending on the type of the precision
> parameter..."/
>
> The function internally uses the |ComplexRootPackage| for univariate
> cases and a Groebner-basis-based solver (|GroebnerSolve|) for
> multivariate systems to isolate roots before refining them to the
> requested precision.
>
>
> User Input
>
> Solve me 0=3+x^2+5*x^3 using jlFriCAS
>
> /Running MCP tool/
>
>
> Planner Response
>
> The numerical solutions for the equation 5x3+x2+3=0 are:
>
> Real Root: x = -0.9156445838
>
> Complex Roots: x = 0.3578222919 - 0.7261124531i x = 0.3578222919 +
> 0.7261124531i
>
> These results were calculated with a precision of 10^-10.
>
>
> User Input
>
> Can you solve it symbolically?
>
> /Running MCP tool/
>
> /Running MCP tool/
>
>
> Planner Response
>
> The symbolic solutions for the equation 5x^3 + x^2 + 3 = 0 involve
> nested radicals. Here they are as provided by jlFriCAS:
>
> Root 1:
>
> |+-----------------+2 | +----+ +---+ |45 \|2029 - 2027 (- \|-
> 3+1)3|----------------- \| 2 + +-----------------+ | +----+ +---+ |45 \|
> 2029 - 2027 (- \|- 3-1)3|----------------- - 2 \| 2 / +-----------------
> + | +----+ +---+ |45 \|2029 - 2027 (15 \|- 3+15)3|----------------- \| 2 |
>
> Root 2:
>
> |+-----------------+2 | +----+ +---+ |45 \|2029 - 2027 (- \|-
> 3-1)3|----------------- \| 2 + +-----------------+ | +----+ +---+ |45 \|
> 2029 - 2027 (- \|- 3+1)3|----------------- + 2 \| 2 / +-----------------
> + | +----+ +---+ |45 \|2029 - 2027 (15 \|- 3-15)3|----------------- \| 2 |
>
> Root 3:
>
> |+-----------------+2 +-----------------+ | +----+ | +----+ |45 \|2029 -
> 2027 |45 \|2029 - 2027 3|----------------- - 3|----------------- + 1 \|
> 2 \| 2 x = ------------------------------------------------
> +-----------------+ | +----+ |45 \|2029 - 2027 15 3|----------------- \| 2 |
>
> These solutions are derived using the cubic formula. The expression |\|-
> 3| refers to the square root of -3 (proportional to the imaginary unit |i|).
>
>
> If you have a Markdown previewer see the attached file from this
> session, it is badly transcripted in a mail.
>
> Greg
>
> --
> You received this message because you are subscribed to the Google
> Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to fricas-devel...@googlegroups.com <mailto:fricas-
> devel+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/fricas-
> devel/
> CAHnU2dbWjoq9ZmJzQZQqK%2BpamrNrWdny%2BCi8XhZGSawCx87FEw%40mail.gmail.com
> <https://groups.google.com/d/msgid/fricas-devel/
> CAHnU2dbWjoq9ZmJzQZQqK%2BpamrNrWdny%2BCi8XhZGSawCx87FEw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Grégory Vanuxem

unread,
Mar 4, 2026, 5:09:17 PM (2 days ago) Mar 4
to fricas...@googlegroups.com
Hello Qian,

Le mer. 4 mars 2026 à 14:44, Qian Yun <oldk...@gmail.com> a écrit :
>
> Looks very interesting.

Thanks!

> BTW, was the MCP interface itself written by LLM or human,
> or both?


In fact, it's the first time that I use exclusively the LLM for a
(simple) project, principally the CL part. It was not my primary
intention. Usually I use it for tests, documentation (creation, typo,
syntax...) and sometimes some advice when I am stuck in Spad. Here the
Makefile and configure parts were implemented by me. I just maybe
changed some names in the CL code. A temporary implementation. My
commit was more a backup than to make this code public.

I downloaded last week antigravity-awesome-skills
(https://github.com/sickn33/antigravity-awesome-skills) and tested the
@braistorming tool to ask the AI engine how to produce a MCP server in
FriCAS and quicky, after choosing local and not accessible from
everywhere, I want access to local file system, CL and not Spad (JSON
parsing, String handling in Spad etc.) and a few other things it
proposed me to code a preliminary version. The CL code was done in
just about a minute, the Spad also but it is very simple ($Lisp
calls). I introduced more later via the AI used.

From my point of view using AI is not a problem since conception is
more important than coding. That's become the norm I think and that's
a good thing if we take care of what is produced.

Concerning Spad code with AI this is not an easy task. I had
availability today and I rewrote in pure Spad some routines that I
coded using libpcre from Julia, to display plain text ++ docstrings
using BrowserInformation. Using AI was a pain and I spent all my
tokens from some very silly errors. And even, destruction/rewriting of
good code/documentation since when the AI does not find a solution it
tends to modify a lot of other, sometimes not at all related, code
parts. The main problem with Spad and AI is the error messages of the
compiler. They are sometimes completely unrelated and so
incomprehensible.

Try to compile this:

res := concat(res, concat [newline()::String, _
"Example: ", clean_tex(elt(arg_res, text)), newline()::String])

Without the String coercion, something like concat [str1, newline(),
str2, newline(), str3]

You'll end up with a completely "strange" error whereas it's very
simple to see it. Gemini modified my docstrings, my algebra makefile
to reorder it, several routines but never saw this issue. Same for
Claude Opus 4.6. Maybe one day I will look at the Spad compiler, I
never did it, but I guess it will be cryptic to me.

Greg

PS: https://github.com/gvanuxem/jlfricas/blob/master/src/algebra/sdoc.spad
For a use in (jl)FriCAS (without Julia).
Reply all
Reply to author
Forward
0 new messages