MCP-Math
MCP-Math is a Java-based Model Context Protocol (MCP) compatible tool that provides a suite of essential mathematical operations.
It is designed to be used by any AI agent or tool host that supports the MCP specification.
โก Fast, Accurate, and Lightweight
MCP-Math is engineered to deliver fast execution, mathematically accurate results, and minimal resource overhead. Each function is finely tuned to ensure:
- High performance even at scale (verified with performance tests)
- Reliable outputs with well-tested edge case handling
- Minimal dependencies for fast loading and lightweight deployment
Installation
Please refer to the ๐llms-install.md file for step-by-step installation instructions for Claude Desktop, MCP CLI, and more.
Features by Category
๐ Basic Math
sqrt(double num)โ Square rootsquare(double num)โ Squarepow(double base, double exponent)โ Exponentiationabs(double num)โ Absolute valuelog(double num)โ Natural loglog10(double num)โ Log base 10sin(double radians),cos(double radians),tan(double radians)โ Trigonometric functionsround(double num)โ Roundingmax(double a, double b),min(double a, double b)โ Max/Minmod(double a, double b)โ Moduloceil(double num),floor(double num)โ Ceiling/Floorgcd(int a, int b),lcm(int a, int b)โ GCD/LCMdegToRad(double degrees),radToDeg(double radians)โ Angle conversionsfactorial(int n)โ Factorial
๐ Statistics
mean(List<Double> numbers)โ Meanmedian(List<Double> numbers)โ Medianmode(List<Double> numbers)โ Moderange(List<Double> numbers)โ Rangevariance(List<Double> numbers)โ Sample VariancestandardDeviation(List<Double> numbers)โ Sample Standard Deviationsum(List<Double> numbers)โ Sumcount(List<Double> numbers)โ Count
๐ข Combinatorics
factorial(int n)โ FactorialnCr(int n, int r)โ CombinationsnPr(int n, int r)โ PermutationsmultiFactorial(int n, int k)โ k-step FactorialcatalanNumber(int n)โ Catalan Number
๐ Prime Numbers
isPrime(int num)โ Prime checknextPrime(int num)โ Next primecountPrimesUpTo(int n)โ Prime count up to nlistPrimesInRange(int start, int end)โ List primes in rangeprimeFactors(int n)โ Prime factorization
๐ Sequences
fibonacci(int n)โ Fibonacci n-th termarithmeticTerm(long a, long d, int n)โ Arithmetic n-th termgeometricTerm(long a, long r, int n)โ Geometric n-th termsumArithmeticSeries(long a, long d, int n)โ Arithmetic sumsumGeometricSeries(long a, long r, int n)โ Geometric sumisFibonacci(long num)โ Fibonacci membershipsumFibonacci(int n)โ Fibonacci sumgenerateArithmeticSequence(long a, long d, int n)โ Arithmetic listgenerateGeometricSequence(long a, long r, int n)โ Geometric listnthTriangularNumber(int n)โ Triangular number
๐ Geometry
circleArea(double radius)โ Circle areacircleCircumference(double radius)โ Circle circumferencetriangleArea(double base, double height)โ Triangle area (base/height)trianglePerimeter(double a, double b, double c)โ Triangle perimeterheronArea(double a, double b, double c)โ Triangle area (Heron's formula)pythagorean(double a, double b)โ Hypotenuse (Pythagorean theorem)rectangleArea(double width, double height)โ Rectangle arearectanglePerimeter(double width, double height)โ Rectangle perimeterdistance2D(double x1, double y1, double x2, double y2)โ 2D distancedistance3D(double x1, double y1, double z1, double x2, double y2, double z2)โ 3D distance
โน๏ธ All functions are annotated with
@Tooland can be auto-discovered by any compliant MCP host at runtime.
Usage Examples
Once installed in an MCP-compatible host:
sqrt(25)returns5pow(2, 4)returns16round(3.7)returns4cos(0)returns1
Technical Details
- Built with Spring Boot and
spring-ai-mcp-server-spring-boot-starter - MCP-compatible methods are annotated with
@Tool manifest.jsonis automatically generated using ClassGraph to scan the tool package- Executable jar is placed under
./libsfor use by MCP hosts
Build Instructions
./gradlew clean build
This will:
- Build the executable Spring Boot jar
- Generate
manifest.json - Copy the jar to
./libsfor publication
Output
The following files will be generated and should be committed:
libs/MCP-Math-0.0.1-SNAPSHOT.jarmanifest.json
License
This project is licensed under the MIT License. See the LICENSE file for details.
ยฉ 2025 JUNG JE KIM Original author and maintainer: JUNG JE KIM
Author
- Email: [email protected]
- GitHub: @key824999