PARI/GP数论计算服务

通过MCP服务器提供PARI/GP数论库功能的Python接口,支持整数分解、素数测试、多项式计算等数学运算。

  • by daedalus
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 daedalus/mcp-parigp

使用说明

mcp配对

MCP服务器公开密码2(PARI/GP)数论库

mcp名称:io.github.daedalus/mcp-parigp

安装

pip install mcp-parigp

用法

作为MCP服务器

直接运行:

mcp-parigp

或者通过在设置中配置与MCP客户端一起使用:

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

在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

数论

  • factor(n) -因子一个整数
  • isprime(n) -测试n是否为素数
  • gcd(a, b) -最大公约数
  • phi(n) -欧拉函数
  • sigma(n, k) -除数的k次幂之和
  • jacobi(a, n) -雅各比符号
  • znorder(x, n) -模n的乘法阶
  • primes(n) -前n个素数
  • nextprime(n) -n之后的下一个素数

多项式

  • polroots(pol) -查找多项式的根
  • polcyclo(n) -第n个割圆多项式
  • deriv(pol) -多项式的导数
  • subst(pol, v, expr) -多项式中的替换

数域

  • nfinit(pol) -初始化数字字段
  • bnfinit(pol) -使用Buchmann算法进行初始化
  • idealadd(nf, a, b) -添加理想
  • idealmul(nf, a, b) -多重理想

椭圆曲线算法

  • ellinit(eq) -初始化椭圆曲线
  • ellap(E, p) -弗罗贝尼乌斯在p的踪迹
  • elltors(E) -扭转子组
  • ellheight(E, P) -标准高度

矩阵

  • matid(n) -n×n单位矩阵
  • matdet(m) -矩阵行列式
  • matinv(m) -矩阵逆
  • matrank(m) -矩阵排名

初等函数

  • sin, cos, tan, asin, acos, atan
  • sinh, cosh, tanh, asinh, acosh, atanh
  • exp, log, sqrt, abs
  • pi(), euler(), I()

发展

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/