
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
mcp-mathematics
Advanced tools
Production-ready MCP server built with FastMCP v2 for comprehensive mathematical operations, providing 52 advanced functions, 158 unit conversions, and enterprise-grade security
A comprehensive Model Context Protocol (MCP) server that turns any AI assistant into a powerful mathematical computation engine. MCP Mathematics gives you professional-grade features including 52 advanced mathematical functions, 158 unit conversions across 15 categories, complete financial calculations, and secure AST-based evaluation—all in a production-ready, secure environment.
MCP Mathematics is the most complete mathematical computation server for AI assistants, built specifically for the Model Context Protocol. This production-ready solution turns any MCP-compatible AI into a powerful mathematical tool that handles everything from simple arithmetic to complex financial calculations, unit conversions across many different fields, and advanced scientific computations.
Key Innovation: Using Python's Abstract Syntax Tree (AST) evaluation, MCP Mathematics gives you exceptional mathematical capabilities while staying completely secure—stopping code injection vulnerabilities without losing any features.
Before you install MCP Mathematics, make sure you have:
Choose the installation method that works best for you:
This is the fastest way to get started:
# Install the uv package manager if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install and run MCP Mathematics
uvx mcp-mathematics
If you prefer using pip:
pip install mcp-mathematics
📦 Package Information: mcp-mathematics on PyPI
If you want to help out or need the latest development version:
git clone https://github.com/SHSharkar/MCP-Mathematics.git
cd MCP-Mathematics
pip install -e .
To use MCP Mathematics with Claude Desktop, you'll need to update your configuration file.
Configuration file locations:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mcp-mathematics": {
"command": "uvx",
"args": [
"mcp-mathematics"
]
}
}
}
{
"mcpServers": {
"mcp-mathematics": {
"command": "mcp-mathematics"
}
}
}
If you're using VS Code with the Continue extension:
{
"models": [
{
"model": "claude-3-5-sonnet",
"provider": "anthropic",
"mcpServers": {
"mcp-mathematics": {
"command": "uvx",
"args": [
"mcp-mathematics"
]
}
}
}
]
}
MCP Mathematics is available as a cloud-hosted service through FastMCP for instant access without local installation. Choose from multiple connection methods:
Access your tools from the command line with quick setup:
claude mcp add --scope local --transport http mathematics https://mathematics.fastmcp.app/mcp
Use your tools directly in Claude's desktop app with one-click installation:
Download Link: https://mathematics.fastmcp.app/manifest.dxt?v=aa76634e-bffb-4be5-b1fd-c680cd7f7142
Downloads .dxt file. Open the file to connect automatically.
Access your tools in a Codex CLI session:
codex mcp add -- mathematics npx -y mcp-remote@latest https://mathematics.fastmcp.app/mcp
Durably store your MCP via Codex's configuration file by adding this to .codex/config.toml
:
[mcp_servers.mathematics]
command = "npx"
args = ["-y", "mcp-remote@latest", "https://mathematics.fastmcp.app/mcp"]
Access your tools from the command line with quick setup:
gemini mcp add mathematics https://mathematics.fastmcp.app/mcp --transport http
AI-powered code editor with built-in tool support. Click to connect instantly:
Connection Link: cursor://anysphere.cursor-deeplink/mcp/install?name=mathematics&config=eyJ1cmwiOiJodHRwczovL21hdGhlbWF0aWNzLmZhc3RtY3AuYXBwL21jcCJ9
FastMCP Cloud Benefits:
MCP Mathematics gives you access to all its mathematical features through 21 specialized tools with descriptive, mathematical domain names for maximum clarity and memorability. Each tool is designed for specific tasks and built for excellent performance:
evaluate_mathematical_expression
- Single Expression EvaluationThe main tool for working with mathematical expressions. It supports all 52 built-in functions, unit conversions, and financial calculations. It handles everything from simple arithmetic to complex scientific computations.
Use Cases:
"2 * pi * 10"
→ "62.83185307179586"
"sin(pi/2) + log10(1000)"
→ "4.0"
"compound_interest(5000, 6.5, 15)"
→ Complete interest breakdown"convert_between_measurement_units(100, 'km', 'mi', 'length')"
→ Automatic unit detection and conversionevaluate_multiple_mathematical_expressions
- Parallel Processing EngineBuilt to handle many expressions at the same time, giving you much better performance when doing lots of calculations or data analysis work.
Use Cases:
Input: ["sin(pi/2)", "cos(0)", "sqrt(16)", "factorial(5)"]
Output: ["1.0", "1.0", "4.0", "120"]
convert_between_measurement_units
- Advanced Unit Conversion SystemSmart unit conversion system that works with 158 units across 15 categories. It automatically figures out unit types, supports different spellings, and handles complex compound units.
Advanced Features:
Input: value=100, from_unit="meters", to_unit="feet"
Output: "328.084" (with automatic precision handling)
convert_units_from_natural_language
- Natural Language Unit ConversionConverts units using natural language queries, making unit conversions more intuitive and accessible. This tool parses natural language requests and automatically determines the appropriate conversion.
Supported Natural Language Patterns:
Input: "convert 100 kilometers to miles"
Output: {
"success": true,
"conversion": {
"original_query": "convert 100 kilometers to miles",
"input_value": 100,
"input_unit": "kilometers",
"output_value": 62.137119,
"output_unit": "miles",
"unit_type": "length"
}
}
compute_statistical_operations
- Statistical Analysis EnginePerforms comprehensive statistical calculations on datasets, providing essential statistical measures for data analysis and scientific computing.
Available Statistical Operations:
Input: data=[1, 2, 3, 4, 5], operation="mean"
Output: "Result: 3.0"
perform_matrix_mathematical_operations
- Matrix Mathematics EngineAdvanced matrix operations for linear algebra, engineering calculations, and scientific computing with support for multiple matrix operations.
Supported Matrix Operations:
Input: matrices=[[[1,2],[3,4]], [[5,6],[7,8]]], operation="multiply"
Output: Matrix multiplication result with proper formatting
perform_number_theory_analysis
- Number Theory AnalysisAdvanced number theory operations for mathematical research, cryptography, and computational mathematics.
Available Number Theory Operations:
Input: n=97, operation="is_prime"
Output: "Result: 97 is prime"
create_mathematical_calculation_session
- Session InitializationCreates a new calculation session with optional initial variables, enabling stateful mathematical computations across multiple operations.
Session Features:
Input: session_id="analysis_1", variables={"x": 10, "pi": 3.14159}
Output: "Session created: analysis_1"
evaluate_expression_in_session_context
- Stateful CalculationsPerforms calculations within a specific session context, with access to stored variables and the ability to save results for later use.
Input: session_id="analysis_1", expression="x * 2 + pi", save_as="result"
Output: "Result: 23.14159" (and saves as 'result' variable)
list_mathematical_session_variables
- Variable ManagementLists all variables currently stored in a calculation session, showing their names and values for easy reference.
Input: session_id="analysis_1"
Output: {"x": 10, "pi": 3.14159, "result": 23.14159}
delete_mathematical_calculation_session
- Session CleanupSafely removes a calculation session and all associated variables, freeing up memory and ensuring clean state management.
get_mathematical_computation_performance_metrics
- Performance MonitoringProvides comprehensive system performance metrics including computation statistics, memory usage, and operational uptime for monitoring system health.
Metrics Included:
get_mathematical_security_audit_report
- Security InformationReturns current security status including rate limiting information and session data for security monitoring and compliance.
get_mathematical_memory_usage_statistics
- Memory AnalyticsDetailed memory usage statistics for cache and session management, helping with performance optimization and resource planning.
get_mathematical_computation_history
- Calculation Audit TrailKeeps a complete record of all calculations with timestamps, so you can track, check, and repeat any mathematical work.
Features:
clear_mathematical_computation_history
- History ManagementLets you safely clear your calculation history when you need to for privacy, performance, or storage reasons.
optimize_mathematical_computation_memory
- Memory OptimizationCleans up expired cache entries and optimizes memory usage, helping maintain optimal performance in long-running sessions.
Optimization Features:
list_all_available_mathematical_functions_and_constants
- Complete Capability DiscoveryComplete reference tool that gives you instant access to all available mathematical functions, constants, unit conversions, and their settings.
Discovery Categories:
Note: This tool consolidates the functionality of listing functions, constants, and recent history access in a single comprehensive interface.
Access these resources directly through the MCP protocol with their corresponding implementation functions:
history://recent
- View recent calculation history (implemented by get_recent_mathematical_computation_history
)functions://available
- Browse available mathematical functions (implemented by get_available_mathematical_functions_catalog
)constants://math
- Access mathematical constants with their values (implemented by get_comprehensive_mathematical_constants_catalog
)Pre-configured prompts for common calculation patterns:
scientific_calculation
- Structured template for scientific computationsbatch_calculation
- Optimized template for batch processingMCP Mathematics gives you a complete mathematical computation environment with support for over 52 functions spanning basic arithmetic, advanced scientific computing, and specialized mathematical operations. The system handles everything from simple calculations to complex scientific and financial computations with precision and reliability.
Beyond standard arithmetic, MCP Mathematics supports easy-to-use mathematical operators including Unicode symbols for natural mathematical expression:
+
-
*
or ×
/
or ÷
//
%
**
or ^
Essential trigonometric operations in radians:
sin(x)
, cos(x)
, tan(x)
- Standard trigonometric functionsasin(x)
, acos(x)
, atan(x)
- Inverse trigonometric functionsatan2(y, x)
- Two-argument arctangent for proper quadrantComplete hyperbolic function set:
sinh(x)
, cosh(x)
, tanh(x)
- Hyperbolic functionsasinh(x)
, acosh(x)
, atanh(x)
- Inverse hyperbolic functionsComprehensive logarithmic operations:
log(x)
- Natural logarithmlog10(x)
- Common logarithm (base 10)log2(x)
- Binary logarithmlog1p(x)
- Natural logarithm of (1 + x) for precisionexp(x)
- Exponential function (e^x)exp2(x)
- Base-2 exponentialexpm1(x)
- Exponential minus 1 (e^x - 1)sqrt(x)
- Square rootpow(x, y)
- Power functionControl over numerical precision:
ceil(x)
- Round up to nearest integerfloor(x)
- Round down to nearest integertrunc(x)
- Remove decimal portionAdvanced mathematical operations:
factorial(x)
- Factorial computationgamma(x)
- Gamma functionlgamma(x)
- Natural logarithm of gamma functionerf(x)
- Error functionerfc(x)
- Complementary error functionInteger and combinatorial mathematics:
gcd(x, y)
- Greatest common divisorlcm(x, y)
- Least common multiple (Python 3.9+)isqrt(x)
- Integer square rootcomb(n, k)
- Binomial coefficient (combinations)perm(n, k)
- PermutationsPrecise control over floating-point arithmetic:
fabs(x)
- Floating-point absolute valuecopysign(x, y)
- Magnitude of x with sign of yfmod(x, y)
- Floating-point remainderremainder(x, y)
- IEEE remainder operationmodf(x)
- Separate integer and fractional partsfrexp(x)
- Decompose into mantissa and exponentldexp(x, i)
- Compute x × 2^i efficientlyhypot(x, y)
- Euclidean distance calculationcbrt(x)
- Cube root (Python 3.11+)Functions for numerical analysis:
isfinite(x)
- Check for finite valuesisinf(x)
- Check for infinityisnan(x)
- Check for Not-a-Numberisclose(a, b)
- Approximate equality testingSpecialized operations for scientific computing:
nextafter(x, y)
- Next representable floating-point valueulp(x)
- Unit of least precisionSeamless conversion between angle units:
degrees(x)
- Convert radians to degreesradians(x)
- Convert degrees to radiansAccess fundamental mathematical constants:
pi
- π ≈ 3.141592653589793e
- Euler's number ≈ 2.718281828459045tau
- τ = 2π ≈ 6.283185307179586inf
- Positive infinitynan
- Not a Numberevaluate_mathematical_expression("2 + 3 * 4") # Result: 14
evaluate_mathematical_expression("10 / 3") # Result: 3.3333333333333335
evaluate_mathematical_expression("2 ** 8") # Result: 256
evaluate_mathematical_expression("sin(pi/2)") # Result: 1.0
evaluate_mathematical_expression("log10(1000)") # Result: 3.0
evaluate_mathematical_expression("sqrt(16) + cos(0)") # Result: 5.0
evaluate_mathematical_expression("(2 + 3) * sqrt(16) / sin(pi/2)") # Result: 20.0
evaluate_mathematical_expression("factorial(5) + gcd(12, 8)") # Result: 124
evaluate_mathematical_expression("5 × 3") # Result: 15
evaluate_mathematical_expression("20 ÷ 4") # Result: 5.0
evaluate_mathematical_expression("2 ^ 10") # Result: 1024
MCP Mathematics includes a smart unit conversion system that works with 158 carefully calibrated units across 15 essential categories. This system does more than simple conversions—it provides smart unit detection, supports different spellings, handles complex compound units, and tracks your conversion history. This makes it perfect for scientific work, engineering calculations, and everyday conversions.
The conversion system automatically manages precision, accepts many different input formats, and works seamlessly with the mathematical expression engine for smooth integration in complex calculations.
m
, km
, cm
, mm
, nm
, micron
, angstrom
mi
, yd
, ft
, in
ly
(light-years), AU
(astronomical units), pc
(parsecs)nmi
(nautical miles)kg
, g
, mg
, ton
(metric), t
lb
, oz
, ton_us
(short ton), ton_uk
(long ton), st
(stone)ct
(carats), gr
(grains), amu
(atomic mass units)s
, min
, h
, d
, wk
, mo
, yr
ms
, us
, ns
, ps
decade
, century
, millennium
, fortnight
K
(Kelvin), C
(Celsius), F
(Fahrenheit)m2
, km2
, cm2
, mm2
, hectare
, are
ft2
, yd2
, in2
, mi2
, acre
, sqch
(square chains)L
, mL
, m3
, cm3
gal
, qt
, pt
, fl_oz
, cup
, tbsp
, tsp
gal_uk
, qt_uk
, pt_uk
ft3
, in3
m/s
, km/h
, mph
, ft/s
, knot
, mach
, cm/s
, mi/min
, in/s
, c
(speed of light percentage)B
, KB
, MB
, GB
, TB
, PB
, EB
, ZB
bit
, Kbit
, Mbit
, Gbit
, Tbit
KiB
, MiB
, GiB
Pa
, kPa
, MPa
, atm
, bar
, mbar
, psi
, torr
, mmHg
, inHg
J
, kJ
, MJ
, cal
, kcal
, Wh
, kWh
, BTU
, eV
, ft_lb
, erg
, therm
W
, kW
, MW
, hp
, PS
, BTU/h
, ft_lb/s
, cal/s
, erg/s
, ton_refrigeration
N
, kN
, lbf
, kgf
, dyne
, pdl
, ozf
, tonf
deg
, rad
, grad
, arcmin
, arcsec
, turn
Hz
, kHz
, MHz
, GHz
, rpm
, rad/s
mpg
, mpg_uk
, L/100km
, km/L
, mi/L
, gal/100mi
MCP Mathematics supports common unit aliases for convenience:
convert_between_measurement_units(
100, "kilometers", "miles", "length"
) # Works with full names
convert_between_measurement_units(100, "km", "mi", "length") # Works with abbreviations
convert_between_measurement_units(
100, "metre", "yard", "length"
) # Supports alternate spellings
The system automatically figures out unit types from context:
convert_between_measurement_units(
100, "kg", "lb", "mass"
) # Automatically detects mass conversion
Parse and handle complex compound units:
parse_compound_unit("m/s²") # Acceleration units
parse_compound_unit("kg·m/s²") # Force units
Automatic formatting for very large or small values:
format_scientific_notation(0.000001, precision=2) # 1.00e-6
format_scientific_notation(1000000, precision=2) # 1.00e+6
Track all conversions with timestamps:
convert_with_history(100, "m", "ft", precision=2) # Stores in history
conversion_history.get_recent(10) # Retrieve last 10
# Length conversions
convert_between_measurement_units(100, "meters", "feet", "length") # 328.084
convert_between_measurement_units(1, "mile", "kilometers", "length") # 1.60934
# Mass conversions
convert_between_measurement_units(1, "kg", "pounds", "mass") # 2.20462
convert_between_measurement_units(100, "grams", "ounces", "mass") # 3.52740
# Temperature conversions
convert_between_measurement_units(0, "C", "F", "temperature") # 32
convert_between_measurement_units(100, "F", "C", "temperature") # 37.7778
# Data storage conversions
convert_between_measurement_units(1024, "MB", "GB", "data") # 1.024
convert_between_measurement_units(1, "TB", "bytes", "data") # 1099511627776
MCP Mathematics includes a complete set of financial tools designed for professional use, education, and personal money management. The financial system supports advanced calculations including compound interest modeling, loan analysis, tax calculations, and business financial work.
All financial functions use high precision to make sure you get accurate money calculations and support different compounding frequencies, payment schedules, and tax situations you'll find in real-world financial work.
calculate_percentage(1000, 15) # 150 (15% of 1000)
calculate_percentage_of(50, 200) # 25 (50 is 25% of 200)
calculate_percentage_change(100, 150) # 50 (50% increase)
# Simple Interest
calculate_simple_interest(1000, 5, 10)
# Returns: {"interest": 500, "amount": 1500}
# Compound Interest
calculate_compound_interest(1000, 5, 10, 12) # Monthly compounding
# Returns: {"amount": 1647.01, "interest": 647.01}
# Calculate monthly payment
calculate_loan_payment(100000, 5, 30, 12) # $100k, 5%, 30 years, monthly
# Returns: {"payment": 536.82, "total_paid": 193255.78, "interest_paid": 93255.78}
# Calculate tax (inclusive or exclusive)
calculate_tax(100, 10, is_inclusive=False) # 10% tax on $100
# Returns: {"amount": 100, "tax": 10, "total": 110}
calculate_tax(110, 10, is_inclusive=True) # Price includes 10% tax
# Returns: {"amount": 100, "tax": 10, "total": 110}
# Split bill with tip
split_bill(100, 4, tip_percent=20)
# Returns: {"total": 120, "per_person": 30, "tip": 20}
# Calculate tip
calculate_tip(100, 18) # 18% tip on $100
# Returns: 18
# Calculate discount
calculate_discount(100, 20) # 20% off $100
# Returns: {"original": 100, "discount": 20, "final": 80}
# Calculate markup
calculate_markup(100, 25) # 25% markup on $100 cost
# Returns: {"cost": 100, "markup": 25, "price": 125}
MCP Mathematics is built as an enterprise-grade mathematical computation platform that combines strong security measures with production-ready architecture. The system is designed to handle mission-critical calculations while maintaining the highest standards of code quality and security.
This complete guide gives you everything you need to contribute to MCP Mathematics, from setting up your development environment to building production-ready distributions. The project follows strict quality standards and automated workflows to make sure everything works reliably and stays maintainable.
# Ensure Python 3.10+ is installed
python --version # Should be 3.10 or higher
# Clone the repository
git clone https://github.com/SHSharkar/MCP-Mathematics.git
cd MCP-Mathematics
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
Run the comprehensive test suite covering all 130 test cases:
# Run all tests with detailed output
python -m pytest tests/ -v
# Run tests with coverage reporting
python -m pytest tests/ --cov=src --cov-report=html
# Run specific test categories
python -m pytest tests/test_calculator.py -v # Core functionality
python -m pytest tests/test_unit_conversion.py -v # Unit conversions
python -m pytest tests/test_financial.py -v # Financial calculations
Keep professional code standards with automated quality tools:
# Auto-format code with Black (100-character line limit)
black src/ tests/ --line-length 100
# Comprehensive linting with Ruff
ruff check src/ tests/ --fix
# Type checking with mypy
mypy src/
# Run complete pre-commit validation
pre-commit run --all-files
# Security analysis
bandit -r src/
# Performance profiling for mathematical operations
python -m cProfile -s cumtime scripts/benchmark.py
# Memory usage analysis
python -m memory_profiler scripts/memory_test.py
Create optimized distribution packages for PyPI:
# Install build tools
pip install build twine
# Clean previous builds
rm -rf dist/ build/
# Build source and wheel distributions
python -m build
# Verify package integrity
twine check dist/*
# Test installation in clean environment
pip install dist/*.whl
# Tag release version
git tag -a v1.0.0 -m "Release version 1.0.0"
# Push tags to trigger CI/CD
git push origin --tags
# Upload to PyPI (maintainers only)
twine upload dist/*
MCP Mathematics gives you clear, helpful error messages to help you figure out what went wrong:
MCP Mathematics is released under the MIT License. Copyright © 2025 Md. Sazzad Hossain Sharkar
Md. Sazzad Hossain Sharkar GitHub: @SHSharkar Email: md@szd.sh
We welcome contributions that maintain our high standards for code quality. When you contribute:
MCP Mathematics is built on the Model Context Protocol (MCP) specification developed by Anthropic, extending it with production-ready mathematical capabilities designed for professional use.
FAQs
Production-ready MCP server built with FastMCP v2 for comprehensive mathematical operations, providing 52 advanced functions, 158 unit conversions, and enterprise-grade security
We found that mcp-mathematics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.