SharkMath MCP

SharkMath MCP

A Model Context Protocol server providing 150+ mathematical functions across arithmetic, trigonometry, statistics, unit conversions, and more, consolidated into 15 powerful tools for seamless integration with VS Code Copilot and other MCP-compatible clients.

Category
访问服务器

README

SharkMath MCP

A comprehensive Model Context Protocol (MCP) server providing 150+ mathematical functions consolidated into 15 powerful tools across all mathematical domains. This MCP server integrates seamlessly with VS Code Copilot and other MCP-compatible clients to provide powerful mathematical computation capabilities through parameter-based routing.

🚀 Features

15 Consolidated Mathematical Tools

  • calculate_arithmetic - Basic arithmetic operations, expression evaluation, and power operations
  • calculate_trigonometry - Complete trigonometric and inverse functions with degree/radian support
  • calculate_statistics - Statistical operations including central tendency, dispersion, and percentiles
  • convert_units - Universal unit converter supporting 80+ conversions across all measurement types
  • calculate_logarithmic - Logarithmic and exponential functions with domain validation
  • calculate_hyperbolic - Hyperbolic functions with overflow protection
  • format_precision - Number formatting including rounding, floor, ceiling, and absolute value
  • analyze_numbers - Number theory and combinatorial mathematics (primes, GCD, LCM, factorial, etc.)
  • solve_equations - Equation solvers for quadratic and linear equations
  • calculate_geometry_2d - 2D geometry calculations for distance, slope, areas, and perimeters
  • manipulate_matrices - Matrix operations including addition, multiplication, determinant, and transpose
  • financial_calculations - Financial and business calculations including interest, loans, and investment analysis
  • computer_science_tools - Programming utilities including base conversions, hash functions, and algorithm analysis
  • data_analysis - Advanced statistical analysis including correlation, distribution analysis, and outlier detection
  • utility_functions - Helper functions providing mathematical constants, validation, and operation help

📦 Installation

Prerequisites

  • Python 3.8+
  • VS Code with MCP extension support
  • uv package manager (recommended)

Setup

  1. Clone the repository:
git clone https://github.com/tonygod/SharkMath-MCP.git
cd SharkMath-MCP
  1. Install dependencies:
uv venv mcp-env
source mcp-env/bin/activate  # On Windows: mcp-env\Scripts\activate
uv pip install mcp fastmcp
  1. Run the MCP server:
uv run sharkmath_server.py

🔧 VS Code Integration

Configure the MCP server in your VS Code settings (.vscode/mcp.json):

{
  "mcpServers": {
    "sharkmath-mcp": {
      "command": "uv",
      "args": ["--directory", ".", "run", "sharkmath_server.py"],
      "cwd": "/path/to/SharkMath-MCP"
    }
  }
}

📚 API Reference

SharkMath uses parameter-based routing where each consolidated tool accepts an operation parameter to specify the desired function.

Arithmetic Operations - calculate_arithmetic

  • operation="add" - Addition: a + b
  • operation="subtract" - Subtraction: a - b
  • operation="multiply" - Multiplication: a * b
  • operation="divide" - Division with zero-division protection: a / b
  • operation="calculate" - Enhanced expression evaluation with 20+ mathematical functions
    • Basic Functions: sqrt(), pow(), abs(), round()
    • Trigonometric: sin(), cos(), tan(), asin(), acos(), atan()
    • Logarithmic: log(), log10(), ln() (natural log alias)
    • Hyperbolic: sinh(), cosh(), tanh()
    • Rounding: floor(), ceil(), trunc()
    • Constants: pi, e
    • Examples: sqrt(25), sin(pi/2), log(e), sqrt((5-0)^2 + (12-0)^2)
  • operation="power" - Exponentiation: base^exponent
  • operation="square" - Square:
  • operation="cube" - Cube:
  • operation="square_root" - Square root: √n

Statistical Functions - calculate_statistics

  • operation="mean" - Arithmetic mean
  • operation="median" - Median value
  • operation="mode" - Most frequent value
  • operation="standard_deviation" - Standard deviation
  • operation="variance" - Variance calculation
  • operation="range_stats" - Min, max, and range
  • operation="percentile" - Percentile calculation (requires percentile parameter)

Trigonometric Functions - calculate_trigonometry

  • operation="sin" - Sine function
  • operation="cos" - Cosine function
  • operation="tan" - Tangent function
  • operation="asin" - Inverse sine (arcsine)
  • operation="acos" - Inverse cosine (arccosine)
  • operation="atan" - Inverse tangent (arctangent)
  • operation="atan2" - Two-argument arctangent (requires x and y parameters)

Matrix Operations - manipulate_matrices

  • operation="add" - Matrix addition
  • operation="multiply" - Matrix multiplication
  • operation="determinant" - Determinant calculation
  • operation="transpose" - Matrix transpose

Unit Conversions - convert_units

  • Energy: watts, kilowatts, horsepower, joules, calories, btu
  • Temperature: celsius, fahrenheit
  • Length: meters, feet, inches, centimeters, kilometers, miles
  • Weight: kilograms, pounds
  • Volume: liters, gallons
  • Time: seconds, minutes, hours, days, weeks, months, years
  • Area: square_meters, square_feet, acres, hectares
  • Speed: mps, kmh, mph, knots
  • Pressure: pascals, atmospheres, psi, bar
  • Data: bytes, kilobytes, megabytes, gigabytes, terabytes

Financial Calculations - financial_calculations

  • operation="compound_interest" - Compound interest calculation
  • operation="simple_interest" - Simple interest calculation
  • operation="present_value" - Present value calculation
  • operation="future_value" - Future value calculation
  • operation="loan_payment" - Monthly loan payment
  • operation="roi" - Return on investment
  • operation="mortgage_payment" - Mortgage payment calculation

📖 Complete API Documentation - Full reference for all tools and operations

🏗️ Architecture

The project uses a consolidated tool architecture with parameter-based routing and FastMCP:

sharkmath_server.py          # Main MCP server (15 consolidated tools)
├── arithmetic.py            # calculate_arithmetic (arithmetic + power operations + 20+ math functions)
├── trigonometric.py         # calculate_trigonometry (trig + inverse trig functions)
├── stats_operations.py      # calculate_statistics (statistical operations + percentiles)
├── convert_units.py         # convert_units (80+ unit conversions)
├── logarithmic.py           # calculate_logarithmic (log + exponential functions)
├── hyperbolic.py            # calculate_hyperbolic (hyperbolic functions)
├── precision.py             # format_precision (rounding + precision utilities)
├── number_theory.py         # analyze_numbers (number theory + combinatorics)
├── solve_equations.py       # solve_equations (quadratic + linear solvers)
├── calculate_geometry_2d.py # calculate_geometry_2d (2D geometry calculations)
├── matrix_operations.py     # manipulate_matrices (matrix operations)
├── financial_calculations.py # financial_calculations (financial + business calcs)
├── computer_science_tools.py # computer_science_tools (CS + programming utilities)
├── data_analysis.py         # data_analysis (advanced statistical analysis)
└── utility_functions.py     # utility_functions (constants + validation + help)

Consolidated Tool Pattern

Each module implements parameter-based routing:

  • Single tool registration with operation parameter
  • Function routing based on operation parameter value
  • Comprehensive error handling with ✅/❌ prefixes
  • Input validation specific to each mathematical operation
  • Consistent return formatting across all operations

Key Architecture Benefits

  • Reduced tool count: 70+ individual tools → 15 consolidated tools
  • Improved maintainability: Logical grouping of related functions
  • Better performance: Single tool registration per domain
  • Enhanced usability: Intuitive parameter-based operation selection
  • MCP compatibility: Avoids tool registration limits

🧪 Testing

Run the comprehensive test suite:

cd Tests
python test_runner.py

Individual Consolidated Tool Testing

Each consolidated tool has its own dedicated test suite:

python test_calculate_arithmetic.py      # 45+ arithmetic operation tests
python test_calculate_trigonometry.py    # 42+ trigonometric function tests
python test_calculate_statistics.py      # 37+ statistical operation tests
python test_convert_units.py             # 51+ unit conversion tests
python test_manipulate_matrices.py       # 31+ matrix operation tests
python test_financial_calculations.py    # 31+ financial calculation tests
python test_computer_science_tools.py    # 41+ CS utility tests
python test_data_analysis.py             # 36+ advanced analysis tests
# ... and more for each consolidated tool

Test Coverage

  • 500+ individual tests across all consolidated tools
  • Parameter validation testing for all operation types
  • Error condition testing with comprehensive edge case coverage
  • Integration testing with MCP server registration verification
  • Regression testing ensuring all original functionality preserved

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-function)
  3. Add your mathematical function to the appropriate module
  4. Include comprehensive tests
  5. Update documentation
  6. Submit a pull request

Adding New Functions

  1. Choose the appropriate consolidated tool module
  2. Add your operation to the module's operation routing dictionary
  3. Implement the function with proper error handling and validation
  4. Add comprehensive test coverage to the tool's test suite
  5. Update documentation with the new operation parameter

Example: Adding a New Operation

# In arithmetic.py - adding a new operation
def calculate_arithmetic(operation: str, a: float = None, b: float = None, ...):
    operations = {
        "add": lambda: a + b,
        "subtract": lambda: a - b,
        "new_operation": lambda: your_new_function(a, b),  # Add here
        # ... other operations
    }
    
    if operation not in operations:
        return f"❌ Unsupported operation: {operation}"
    
    try:
        result = operations[operation]()
        return f"✅ {operation.title()} result: {result}"
    except Exception as e:
        return f"❌ Error in {operation}: {str(e)}"

📋 Requirements

  • Python 3.8+
  • MCP (Model Context Protocol)
  • FastMCP framework

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built on the Model Context Protocol (MCP) framework
  • Uses FastMCP for efficient server implementation
  • Inspired by the need for comprehensive mathematical tools in AI workflows

📞 Support

  • Create an issue for bug reports or feature requests
  • Check the Tests/ directory for comprehensive function validation
  • Review Docs/sharkmath_tools_refactor.md for architecture details
  • All 15 consolidated tools with 150+ operations are thoroughly tested and documented

SharkMath MCP - Empowering AI with comprehensive mathematical capabilities through efficient consolidated tools 🦈📊

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选