Skip to main content
Glama
mcp-parigp

mcp-parigp

by daedalus

mcp-parigp

MCP server exposing cypari2 (PARI/GP) number theory library

PyPI Python Coverage Ruff

mcp-name: io.github.daedalus/mcp-parigp

Install

pip install mcp-parigp

Related MCP server: mcp-sympy

Usage

As MCP Server

Run directly:

mcp-parigp

Or use with an MCP client by configuring in your settings:

{
  "mcpServers": {
    "mcp-parigp": {
      "command": "mcp-parigp"
    }
  }
}

In Python

from mcp_parigp import eval_expression, factor, isprime

# Evaluate PARI/GP expressions
result = eval_expression("factor(100)")
print(result)  # [[2, 2], [5, 2]]

# Factor integers
print(factor(100))  # [[2, 2], [5, 2]]

# Test primality
print(isprime(29))  # True

API

Number Theory

  • factor(n) - Factor an integer

  • isprime(n) - Test if n is prime

  • gcd(a, b) - Greatest common divisor

  • phi(n) - Euler's totient function

  • sigma(n, k) - Sum of k-th power of divisors

  • jacobi(a, n) - Jacobi symbol

  • znorder(x, n) - Multiplicative order modulo n

  • primes(n) - First n primes

  • nextprime(n) - Next prime after n

Polynomials

  • polroots(pol) - Find roots of polynomial

  • polcyclo(n) - n-th cyclotomic polynomial

  • deriv(pol) - Derivative of polynomial

  • subst(pol, v, expr) - Substitute in polynomial

Number Fields

  • nfinit(pol) - Initialize number field

  • bnfinit(pol) - Initialize with Buchmann's algorithm

  • idealadd(nf, a, b) - Add ideals

  • idealmul(nf, a, b) - Multiply ideals

Elliptic Curves

  • ellinit(eq) - Initialize elliptic curve

  • ellap(E, p) - Trace of Frobenius at p

  • elltors(E) - Torsion subgroup

  • ellheight(E, P) - Canonical height

Matrices

  • matid(n) - n×n identity matrix

  • matdet(m) - Matrix determinant

  • matinv(m) - Matrix inverse

  • matrank(m) - Matrix rank

Elementary Functions

  • sin, cos, tan, asin, acos, atan

  • sinh, cosh, tanh, asinh, acosh, atanh

  • exp, log, sqrt, abs

  • pi(), euler(), I()

Development

git clone https://github.com/daedalus/mcp-parigp.git
cd mcp-parigp
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/

Available Tools

143 tools
absB

Compute absolute value.

Inputs: x (required), precision.

acosC

Compute arccosine.

Inputs: x (required), precision.

acoshC

Compute inverse hyperbolic cosine.

Inputs: x (required), precision.

addprimesC

Add primes to the factorisation table.

Inputs: primes. Returns: result

agmB

Compute the arithmetic-geometric mean.

Inputs: x (required), y, precision.

airyB

Compute Airy functions Ai(z) and Bi(z).

Inputs: z (required). Returns: result

algdepB

Find polynomial of degree k with integer coefficients approximating x.

Inputs: k (required), x (required), flag.

allocatememC

Change the PARI stack size.

Inputs: size, sizemax. Returns: result

asinB

Compute arcsine.

Inputs: x (required), precision.

asinhB

Compute inverse hyperbolic sine.

Inputs: x (required), precision.

atanB

Compute arctangent.

Inputs: x (required), precision.

atanhB

Compute inverse hyperbolic tangent.

Inputs: x (required), precision.

besselB

Compute the Bessel function J_nu(x).

Inputs: x (required), nu (required), precision.

besselhC

Compute the Bessel function H_nu(x).

Inputs: x (required), nu (required), precision.

bezoutA

Compute the Bezout identity: gcd(a,b) = au + bv.

Inputs: a (required), b (required). Returns: result

binomialB

Compute the binomial coefficient C(n,k).

Inputs: k (required), n (required). Returns: result

bnfinitC

Initialize a number field with Buchmann's algorithm.

Inputs: pol (required), do_buchall.

bnrinitC

Initialize a ray number field (class field).

Inputs: nf (required), modulus (required), sign.

bnrL1C

Compute the first derivative of Artin L-function.

Inputs: bnr (required), s, flag.

bnrrootnumberC

Compute the root number of Artin L-function.

Inputs: bnr (required), flag, character.

CatalanB

Get Catalan's constant.

Inputs: precision. Returns: result

centerliftC

Lift a modular object with centered representatives.

Inputs: mod (required).

ColD

Convert to a column vector.

Inputs: x (required), n.

complexB

Create a complex number.

Inputs: imag (required), real (required). Returns: result

cosC

Compute cosine.

Inputs: x (required), precision.

coshB

Compute hyperbolic cosine.

Inputs: x (required), precision.

cusp_formC

Create a cusp form from its q-expansion.

Inputs: q (required), v, weight.

derivB

Compute the derivative of a polynomial.

Inputs: pol (required), v.

dirichletC

Compute Dirichlet L-function.

Inputs: s (required), chi (required), precision.

discC

Compute the discriminant of a polynomial.

Inputs: pol (required), v. Returns: result

eisensteinC

Compute the Eisenstein series E_k(q).

Inputs: k (required), n, precision.

elladdC

Add two points on an elliptic curve.

Inputs: E1 (required), E2 (required).

ellapB

Compute the trace of Frobenius for an elliptic curve at prime p.

Inputs: E (required), p (required). Returns: result

elletaA

Compute the eta-quotients for an elliptic curve.

Inputs: E (required). Returns: result

ellglobalredB

Compute the global reduction type of an elliptic curve.

Inputs: E (required). Returns: result

ellheightA

Compute the canonical height of a point on an elliptic curve.

Inputs: E (required), P (required), flags. Returns: result

ellinitC

Initialize an elliptic curve.

Inputs: pol (required), sign.

elljB

Compute the j-invariant of an elliptic curve.

Inputs: E (required).

elllocalredB

Compute the local reduction type at prime p.

Inputs: E (required), p (required). Returns: result

elllogB

Compute the discrete logarithm of a point on an elliptic curve.

Inputs: E (required), G (required), P (required). Returns: result

ellmulC

Multiply a point on an elliptic curve by an integer.

Inputs: E (required), n (required), P.

ellorderC

Compute the order of a point on an elliptic curve.

Inputs: E (required), P (required). Returns: result

elltorsB

Compute the torsion subgroup of an elliptic curve.

Inputs: E (required). Returns: result

ellwpC

Compute the Weierstrass p-function.

Inputs: E (required), n, flags.

ellzetaC

Compute the Weierstrass zeta function.

Inputs: E (required), z (required).

etaC

Compute the Dedekind eta function.

Inputs: z (required), flag, precision.

eulerB

Get Euler's constant.

Inputs: precision. Returns: result

eval_expressionB

Evaluate a PARI/GP expression string.

Inputs: expr (required), timeout.

expC

Compute exponential.

Inputs: x (required), precision.

factorB

Factor an integer.

Inputs: n (required). Returns: result

factorialA

Compute the factorial n!.

Inputs: n (required). Returns: result

factorpadicC

Factor a polynomial over the p-adic numbers.

Inputs: p (required), pol (required), n. Returns: result

fibonacciB

Compute the nth Fibonacci number.

Inputs: n (required). Returns: result

gcdB

Compute the greatest common divisor of two integers.

Inputs: a (required), b (required). Returns: result

genus2redC

Reduce a genus 2 curve.

Inputs: P (required), p.

get_pari_versionA

Get the PARI/GP version string.

Returns: String describing the PARI version.

Example: >>> get_pari_version() 'GP/PARI CALCULATOR Version 2.15...'

Inputs: no named parameters. Returns: result

getrandA

Get PARI's current random number seed.

Returns: The current random seed.

Example: >>> getrand() [1, 2, 3, ...]

Inputs: no named parameters.

get_real_precisionA

Get the current PARI default real precision in decimal digits.

Returns: Current precision in decimal digits.

Example: >>> get_real_precision() 15

Inputs: no named parameters. Returns: result

get_real_precision_bitsA

Get the current PARI default real precision in bits.

Returns: Current precision in bits.

Example: >>> get_real_precision_bits() 53

Inputs: no named parameters. Returns: result

hessC

Compute the Hessenberg form of a matrix.

Inputs: m (required).

hilbertC

Compute the Hilbert symbol (n, m) or (n, m)_p.

Inputs: m (required), n (required), p. Returns: result

IA

Get the imaginary unit.

Returns: The imaginary unit I = sqrt(-1).

Example: >>> I() I

Inputs: no named parameters. Returns: imag, real

idealaddA

Add two ideals in a number field.

Inputs: nf (required), ideal1 (required), ideal2 (required).

idealfactorA

Factor an ideal in a number field.

Inputs: nf (required), ideal (required). Returns: result

idealmulB

Multiply two ideals in a number field.

Inputs: nf (required), ideal1 (required), ideal2 (required).

idealpowC

Compute a power of an ideal.

Inputs: n (required), nf (required), ideal (required).

init_primesB

Initialize the primes table up to M.

Inputs: M (required).

integB

Compute the integral of a polynomial.

Inputs: pol (required), v.

ispowerB

Test if n is a perfect k-th power.

Inputs: n (required), k.

isprimeA

Test if an integer is prime.

Inputs: n (required). Returns: result

is_squareB

Test if n is a perfect square.

Inputs: n (required). Returns: result

jacobiB

Compute the Jacobi symbol (a/n).

Inputs: a (required), n (required). Returns: result

lcmB

Compute the least common multiple of two integers.

Inputs: a (required), b (required). Returns: result

legendreB

Compute the Legendre symbol (a/p).

Inputs: a (required), p (required). Returns: result

lfunB

Compute general L-function.

Inputs: s (required), F, r.

lfunthetaC

Compute theta function of L-function.

Inputs: F (required), t (required), precision.

liftB

Lift a modular object (remove Mod wrapper).

Inputs: mod (required).

ListC

Create an empty list or convert to a list.

Inputs: x.

logB

Compute natural logarithm.

Inputs: x (required), precision.

lucasB

Compute the nth Lucas number.

Inputs: n (required). Returns: result

MatC

Convert to a matrix.

Inputs: x (required).

matcharpolyB

Compute the characteristic polynomial of a matrix.

Inputs: m (required), v.

matdetB

Compute the determinant of a matrix.

Inputs: m (required).

mateigenC

Compute the eigenvalues of a matrix.

Inputs: m (required). Returns: result

matidA

Create an n x n identity matrix.

Inputs: n (required).

matimageB

Compute the image of a matrix.

Inputs: m (required).

matinvC

Compute the inverse of a matrix.

Inputs: m (required).

matkerC

Compute the kernel of a matrix.

Inputs: m (required).

matrankB

Compute the rank of a matrix.

Inputs: m (required). Returns: result

matrixB

Create an m x n matrix.

Inputs: m (required), n, entries.

matzeroD

Create a zero matrix.

Inputs: m (required), n.

ModC

Create a modular number or polynomial.

Inputs: a (required), b (required).

modular_lambdaC

Compute the modular lambda function.

Inputs: tau (required), precision.

modulr_symC

Compute the modular symbol.

Inputs: s (required), g, precision.

moebiusB

Compute the Möbius function mu(n).

Inputs: n (required). Returns: result

nextprimeB

Find the next prime after n.

Inputs: n (required). Returns: result

nfinitC

Initialize a number field defined by a polynomial.

Inputs: pol (required).

normB

Compute the norm of a polynomial/algebraic number.

Inputs: pol (required), v.

oneA

Get the integer 1.

Returns: Integer 1.

Example: >>> one() 1

Inputs: no named parameters. Returns: result

phiB

Compute Euler's totient function phi(n).

Inputs: n (required). Returns: result

piA

Get the value of pi.

Inputs: precision. Returns: result

PolC

Convert to a polynomial.

Inputs: x (required), v.

polchebyshevB

Compute the nth Chebyshev polynomial of the first kind.

Inputs: n (required), v.

polcycloC

Compute the nth cyclotomic polynomial.

Inputs: n (required), v.

polhermiteA

Compute the nth Hermite polynomial (probabilists' version).

Inputs: n (required), v.

pollegendreC

Compute the nth Legendre polynomial.

Inputs: n (required), v.

PolrevC

Convert to a polynomial (reverse order).

Inputs: x (required), v.

polrootsB

Compute the complex roots of a polynomial.

Inputs: pol (required). Returns: result

polrootsmodB

Compute the roots of a polynomial modulo p.

Inputs: p (required), pol (required). Returns: result

polrootspadicB

Compute the p-adic roots of a polynomial.

Inputs: p (required), pol (required), n. Returns: result

polsubcycloC

Compute sub-cyclotomic polynomials.

Inputs: d (required), n (required), v. Returns: result

prevprimeA

Find the previous prime before n.

Inputs: n (required). Returns: result

primeA

Return the nth prime (1-indexed).

Inputs: n (required). Returns: result

primesC

Return prime numbers.

Inputs: n, end. Returns: result

QfbC

Create a binary quadratic form.

Inputs: a (required), b (required), c (required), D, +1 more.

qfbclassnoB

Compute the class number of binary quadratic form discriminant D.

Inputs: D (required), flags. Returns: result

qfbsolveB

Solve Q(x) = n for binary quadratic form Q.

Inputs: Q (required), n (required).

quadratic_formsB

Compute reduced binary quadratic forms of discriminant D.

Inputs: D (required). Returns: result

quadregulatorC

Compute the regulator of real quadratic field.

Inputs: D (required), precision.

removeprimesB

Remove primes from the factorisation table.

Inputs: primes. Returns: result

resultantC

Compute the resultant of two polynomials.

Inputs: pol1 (required), pol2 (required), v. Returns: result

SerD

Convert to a power series.

Inputs: x (required), d, v.

SetC

Convert to a set.

Inputs: x (required). Returns: result

setrandA

Set PARI's random number seed.

Inputs: seed (required).

set_real_precisionB

Set the PARI default real precision in decimal digits.

Inputs: n (required). Returns: result

set_real_precision_bitsC

Set the PARI default real precision in bits.

Inputs: n (required). Returns: result

sigmaC

Compute the sum of k-th powers of divisors of n.

Inputs: n (required), k. Returns: result

sinC

Compute sine.

Inputs: x (required), precision.

sinhC

Compute hyperbolic sine.

Inputs: x (required), precision.

sqrtC

Compute square root.

Inputs: x (required), precision.

stacksizeA

Get the current PARI stack size in bytes.

Returns: Current stack size.

Example: >>> stacksize() 8000000

Inputs: no named parameters. Returns: result

stacksizemaxA

Get the maximum PARI stack size in bytes.

Returns: Maximum stack size.

Example: >>> stacksizemax() 536870912

Inputs: no named parameters. Returns: result

substB

Substitute a variable in a polynomial.

Inputs: v (required), pol (required), expr (required).

tanC

Compute tangent.

Inputs: x (required), precision.

tanhC

Compute hyperbolic tangent.

Inputs: x (required), precision.

thetaC

Compute the theta function theta(z, tau).

Inputs: z (required), tau (required), precision.

traceB

Compute the trace of a polynomial/algebraic number.

Inputs: pol (required), v.

VecC

Convert to a row vector.

Inputs: x (required), n.

vectorC

Create a vector of length n.

Inputs: n (required), entries.

weberC

Compute the Weber function.

Inputs: z (required), flag, precision.

zeroA

Get the integer 0.

Returns: Integer 0.

Example: >>> zero() 0

Inputs: no named parameters. Returns: result

znorderB

Compute the multiplicative order of x modulo n.

Inputs: n (required), x (required). Returns: result

znstarB

Compute the structure of (Z/nZ)*.

Inputs: n (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 143 tools

    Disambiguation5/5

    Each tool corresponds to a distinct mathematical operation or concept, with clear names and descriptions that avoid confusion. Only a few generic tools like 'abs' and 'sqrt' are unambiguous, and most have specialized domains (e.g., elliptic curve functions, number field functions).

    Naming Consistency5/5

    All tool names are lowercase, single words (or concatenated without underscores), following a consistent pattern of using the mathematical symbol or abbreviation. No mixing of cases or styles, making it predictable.

    Tool Count2/5

    With 143 tools, the server is excessively large for typical use, overwhelming agents with choices. While the full PARI/GP library warrants many functions, this count far exceeds the recommended 3-15 range for a coherent toolset.

    Completeness4/5

    The tool set covers a broad range of mathematical domains including arithmetic, number theory, elliptic curves, linear algebra, and modular forms. Minor gaps exist (e.g., Galois group functions), but the overall coverage is very comprehensive.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables mathematical operations and calculations through an MCP server interface. Provides computational capabilities accessible via HTTP endpoints for mathematical processing tasks.
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      An MCP server that provides access to SymPy's symbolic mathematics library for advanced algebraic computations. It enables users to perform complex tasks such as symbolic simplification, calculus, equation solving, matrix operations, and number theory.
      100
      45 PyPI
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A Python-based MCP server providing mathematical computation tools and plotting utilities for a wide range of math topics including calculus, matrix operations, statistics, and more.
      22
      13 PyPI
      5
      MIT