calculator-server is an MCP (Model Context Protocol) server built with the Go language, designed to provide comprehensive mathematical calculation capabilities for AI applications. It implements 13 mathematical tools, covering a variety of calculation needs from basic arithmetic to advanced financial modeling.
Purpose
This server serves as the backend of the MCP protocol, providing mathematical calculation functionality for AI assistants or development tools, enabling them to perform precise arithmetic operations, scientific calculations, statistical analysis, unit conversion, and financial calculations.
Main Capabilities
- Basic Mathematical Operations: Supports addition, subtraction, multiplication, and division, with configurable decimal precision (0-15 digits), and supports multiple operands.
- Advanced Mathematical Functions: Includes trigonometric functions (sin, cos, tan, asin, acos, atan), logarithmic functions (log, log10, ln), and other functions (sqrt, abs, factorial, exp, pow); trigonometric functions support degree and radian units.
- Expression Evaluation: Supports variable substitution, mathematical constants (π, e), nested parentheses, and function calls.
- Statistical Analysis: Provides descriptive statistics (mean, median, mode), variability (standard deviation, variance), percentile calculation, and includes data validation and error handling.
- Unit Conversion: Supports conversion among multiple categories of units such as length, weight, temperature, volume, and area, and can perform batch conversion.
- Financial Calculations: Includes simple and compound interest, loan repayment, return on investment (ROI), present value/future value, net present value (NPV), and internal rate of return (IRR).
- Specialized Tools: Statistical summary, percentile calculation, batch unit conversion, NPV, IRR, loan comparison, and investment scenario comparison.
Usage
The server can be run via the command line and supports standard input/output (stdio) and HTTP transport. Configuration can be done through command-line options, YAML/JSON configuration files, or environment variables. Environment variables include CALCULATOR_TRANSPORT, CALCULATOR_HTTP_HOST, CALCULATOR_HTTP_PORT, etc. The MCP protocol supports initialization, tool listing, and tool invocation.
Applicable Scenarios
Suitable for AI applications that require mathematical calculation capabilities, such as intelligent assistants, data analysis tools, financial modeling applications, etc.
Limitations
Requires a Go 1.21+ environment. For specific installation steps and deployment details, please refer to the project documentation.