npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qinggeng2015/mcp-tool-math

v1.1.0

Published

A Model Context Protocol tool for mathematical calculations and matrix operations using mathjs

Readme

MathJS MCP 工具插件

这是一个基于 Node.js 和 MathJS 库的 Model Context Protocol (MCP) 工具插件。它提供了数学计算功能,可以作为 MCP 工具集成到支持 MCP 的应用中。

功能

基础计算

  1. calculate - 执行任意数学表达式计算
  2. basic_arithmetic - 执行基本算术运算(加、减、乘、除)

矩阵计算

  1. create_matrix - 创建矩阵
  2. matrix_operation - 执行矩阵运算(加法、减法、乘法)
  3. matrix_transpose - 计算矩阵的转置
  4. matrix_inverse - 计算矩阵的逆矩阵
  5. matrix_determinant - 计算矩阵的行列式
  6. matrix_trace - 计算矩阵的迹(主对角线元素之和)
  7. matrix_eigenvalues - 计算矩阵的特征值
  8. matrix_rank - 计算矩阵的秩

安装

npm install

使用方法

npm start

启动后,该工具会监听 stdin 并通过 stdout 输出 MCP 协议消息。

工具详情

calculate 工具

执行任意数学表达式计算。

参数:

  • expression (string, 必需): 要计算的数学表达式,例如: "2+2", "sqrt(16)", "sin(pi/2)"

示例:

{
  "method": "tools/call",
  "params": {
    "name": "calculate",
    "arguments": {
      "expression": "2+2*3"
    }
  }
}

basic_arithmetic 工具

执行基本算术运算。

参数:

  • operation (string, 必需): 运算类型,可选值: "add", "subtract", "multiply", "divide"
  • a (number, 必需): 第一个操作数
  • b (number, 必需): 第二个操作数

示例:

{
  "method": "tools/call",
  "params": {
    "name": "basic_arithmetic",
    "arguments": {
      "operation": "add",
      "a": 5,
      "b": 3
    }
  }
}

create_matrix 工具

创建矩阵对象。

参数:

  • matrix (array, 必需): 二维数组表示的矩阵,例如: [[1,2],[3,4]]

示例:

{
  "method": "tools/call",
  "params": {
    "name": "create_matrix",
    "arguments": {
      "matrix": [[1, 2], [3, 4]]
    }
  }
}

matrix_operation 工具

执行矩阵运算(加法、减法、乘法)。

参数:

  • operation (string, 必需): 运算类型,可选值: "add", "subtract", "multiply"
  • matrixA (array, 必需): 第一个矩阵,二维数组格式
  • matrixB (array, 必需): 第二个矩阵,二维数组格式

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_operation",
    "arguments": {
      "operation": "multiply",
      "matrixA": [[1, 2], [3, 4]],
      "matrixB": [[5, 6], [7, 8]]
    }
  }
}

matrix_transpose 工具

计算矩阵的转置。

参数:

  • matrix (array, 必需): 要转置的矩阵,二维数组格式

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_transpose",
    "arguments": {
      "matrix": [[1, 2, 3], [4, 5, 6]]
    }
  }
}

matrix_inverse 工具

计算矩阵的逆矩阵(必须是方阵且可逆)。

参数:

  • matrix (array, 必需): 要求逆的矩阵,必须是方阵

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_inverse",
    "arguments": {
      "matrix": [[1, 2], [3, 4]]
    }
  }
}

matrix_determinant 工具

计算矩阵的行列式(必须是方阵)。

参数:

  • matrix (array, 必需): 要计算行列式的矩阵,必须是方阵

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_determinant",
    "arguments": {
      "matrix": [[1, 2], [3, 4]]
    }
  }
}

matrix_trace 工具

计算矩阵的迹(主对角线元素之和,必须是方阵)。

参数:

  • matrix (array, 必需): 要计算迹的矩阵,必须是方阵

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_trace",
    "arguments": {
      "matrix": [[1, 2], [3, 4]]
    }
  }
}

matrix_eigenvalues 工具

计算矩阵的特征值(必须是方阵)。

参数:

  • matrix (array, 必需): 要计算特征值的矩阵,必须是方阵

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_eigenvalues",
    "arguments": {
      "matrix": [[1, 2], [3, 4]]
    }
  }
}

matrix_rank 工具

计算矩阵的秩。

参数:

  • matrix (array, 必需): 要计算秩的矩阵,二维数组格式

示例:

{
  "method": "tools/call",
  "params": {
    "name": "matrix_rank",
    "arguments": {
      "matrix": [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
    }
  }
}

MathJS 功能

该插件使用 MathJS 库,支持多种数学运算:

  • 基本运算:+, -, *, /
  • 数学函数:sin, cos, tan, log, sqrt 等
  • 常量:pi, e 等
  • 复杂表达式求值
  • 矩阵运算:创建矩阵、矩阵加减乘、转置、求逆、行列式、迹、特征值、秩等

了解更多 MathJS 功能,请参考 MathJS 文档