wjdwo951219

MCP-Math

Community wjdwo951219
Updated

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 root
  • square(double num) โ€“ Square
  • pow(double base, double exponent) โ€“ Exponentiation
  • abs(double num) โ€“ Absolute value
  • log(double num) โ€“ Natural log
  • log10(double num) โ€“ Log base 10
  • sin(double radians), cos(double radians), tan(double radians) โ€“ Trigonometric functions
  • round(double num) โ€“ Rounding
  • max(double a, double b), min(double a, double b) โ€“ Max/Min
  • mod(double a, double b) โ€“ Modulo
  • ceil(double num), floor(double num) โ€“ Ceiling/Floor
  • gcd(int a, int b), lcm(int a, int b) โ€“ GCD/LCM
  • degToRad(double degrees), radToDeg(double radians) โ€“ Angle conversions
  • factorial(int n) โ€“ Factorial

๐Ÿ“Š Statistics

  • mean(List<Double> numbers) โ€“ Mean
  • median(List<Double> numbers) โ€“ Median
  • mode(List<Double> numbers) โ€“ Mode
  • range(List<Double> numbers) โ€“ Range
  • variance(List<Double> numbers) โ€“ Sample Variance
  • standardDeviation(List<Double> numbers) โ€“ Sample Standard Deviation
  • sum(List<Double> numbers) โ€“ Sum
  • count(List<Double> numbers) โ€“ Count

๐Ÿ”ข Combinatorics

  • factorial(int n) โ€“ Factorial
  • nCr(int n, int r) โ€“ Combinations
  • nPr(int n, int r) โ€“ Permutations
  • multiFactorial(int n, int k) โ€“ k-step Factorial
  • catalanNumber(int n) โ€“ Catalan Number

๐Ÿ” Prime Numbers

  • isPrime(int num) โ€“ Prime check
  • nextPrime(int num) โ€“ Next prime
  • countPrimesUpTo(int n) โ€“ Prime count up to n
  • listPrimesInRange(int start, int end) โ€“ List primes in range
  • primeFactors(int n) โ€“ Prime factorization

๐Ÿ” Sequences

  • fibonacci(int n) โ€“ Fibonacci n-th term
  • arithmeticTerm(long a, long d, int n) โ€“ Arithmetic n-th term
  • geometricTerm(long a, long r, int n) โ€“ Geometric n-th term
  • sumArithmeticSeries(long a, long d, int n) โ€“ Arithmetic sum
  • sumGeometricSeries(long a, long r, int n) โ€“ Geometric sum
  • isFibonacci(long num) โ€“ Fibonacci membership
  • sumFibonacci(int n) โ€“ Fibonacci sum
  • generateArithmeticSequence(long a, long d, int n) โ€“ Arithmetic list
  • generateGeometricSequence(long a, long r, int n) โ€“ Geometric list
  • nthTriangularNumber(int n) โ€“ Triangular number

๐Ÿ“ Geometry

  • circleArea(double radius) โ€“ Circle area
  • circleCircumference(double radius) โ€“ Circle circumference
  • triangleArea(double base, double height) โ€“ Triangle area (base/height)
  • trianglePerimeter(double a, double b, double c) โ€“ Triangle perimeter
  • heronArea(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 area
  • rectanglePerimeter(double width, double height) โ€“ Rectangle perimeter
  • distance2D(double x1, double y1, double x2, double y2) โ€“ 2D distance
  • distance3D(double x1, double y1, double z1, double x2, double y2, double z2) โ€“ 3D distance

โ„น๏ธ All functions are annotated with @Tool and can be auto-discovered by any compliant MCP host at runtime.

Usage Examples

Once installed in an MCP-compatible host:

  • sqrt(25) returns 5
  • pow(2, 4) returns 16
  • round(3.7) returns 4
  • cos(0) returns 1

Technical Details

  • Built with Spring Boot and spring-ai-mcp-server-spring-boot-starter
  • MCP-compatible methods are annotated with @Tool
  • manifest.json is automatically generated using ClassGraph to scan the tool package
  • Executable jar is placed under ./libs for use by MCP hosts

Build Instructions

./gradlew clean build

This will:

  • Build the executable Spring Boot jar
  • Generate manifest.json
  • Copy the jar to ./libs for publication

Output

The following files will be generated and should be committed:

  • libs/MCP-Math-0.0.1-SNAPSHOT.jar
  • manifest.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

MCP Server ยท Populars

MCP Server ยท New