
A comprehensive Go-based MCP server for mathematical computations with 13+ tools
A comprehensive Go-based MCP server for mathematical computations with 13+ tools
·
A comprehensive Go-based MCP (Model Context Protocol) server for mathematical computations, implementing 13 mathematical tools with advanced features and high precision calculations.
Owner & Maintainer: Avinash Sangle ([email protected])
Basic Math Operations - Precision arithmetic with configurable decimal places
Advanced Mathematical Functions - Scientific calculations
sin, cos, tan, asin, acos, atanlog, log10, lnsqrt, abs, factorial, exp, powExpression Evaluation - Complex mathematical expressions
π, e)Statistical Analysis - Comprehensive data analysis
Unit Conversion - Multi-category unit conversion
Financial Calculations - Comprehensive financial modeling
Statistics Summary - Comprehensive statistical summary of datasets
Percentile Calculation - Calculate specific percentiles (0-100)
Batch Unit Conversion - Convert multiple values between units at once
Net Present Value (NPV) - Advanced NPV calculations with cash flows
Internal Rate of Return (IRR) - IRR calculations for investment analysis
Loan Comparison - Compare multiple loan scenarios
Investment Scenarios - Compare multiple investment scenarios
shopspring/decimal for financial calculationsgonum.org/v1/gonumgovaluate# Clone the repository
git clone <repository-url>
cd calculator-server
# Install dependencies
make deps
# Build the server
make build
# Run the server
make run# Initialize Go module
go mod init calculator-server
go mod tidy
# Build and run
go build -o calculator-server ./cmd/server
./calculator-server -transport=stdio{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "basic_math",
"arguments": {
"operation": "add",
"operands": [15.5, 20.3, 10.2],
"precision": 2
}
}
}Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"result\": 46.0}"
}
]
}
}{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "advanced_math",
"arguments": {
"function": "pow",
"value": 2,
"exponent": 8
}
}
}{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "stats_summary",
"arguments": {
"data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
}
}{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "percentile",
"arguments": {
"data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"percentile": 90
}
}
}{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "npv",
"arguments": {
"cashFlows": [-50000, 15000, 20000, 25000, 30000],
"discountRate": 8
}
}
}{
"jsonrpc": "2.0",
"id": 6,
"method": "tools/call",
"params": {
"name": "batch_conversion",
"arguments": {
"values": [100, 200, 300],
"fromUnit": "cm",
"toUnit": "m",
"category": "length"
}
}
}The server implements MCP-compliant streamable HTTP transport according to the official MCP specification, providing real-time communication with Server-Sent Events (SSE) streaming support.
✅ Single Endpoint: /mcp only (per MCP specification)
✅ Required Headers: MCP-Protocol-Version, Accept
✅ Session Management: Cryptographically secure session IDs
✅ SSE Streaming: Server-Sent Events for real-time responses
✅ CORS Support: Origin validation and security headers
# Start MCP-compliant HTTP server
./calculator-server -transport=http -port=8080
# Basic JSON-RPC request
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "MCP-Protocol-Version: 2024-11-05" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "basic_math",
"arguments": {
"operation": "add",
"operands": [15, 25],
"precision": 2
}
}
}'
# SSE streaming request (for real-time responses)
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-H "MCP-Protocol-Version: 2024-11-05" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "stats_summary",
"arguments": {"data": [1,2,3,4,5]}
}
}'calculator-server/
├── cmd/
│ └── server/
│ └── main.go # Main server entry point
├── internal/
│ ├── calculator/
│ │ ├── basic.go # Basic math operations
│ │ ├── advanced.go # Advanced mathematical functions
│ │ ├── expression.go # Expression evaluation
│ │ ├── statistics.go # Statistical analysis
│ │ ├── units.go # Unit conversion
│ │ └── financial.go # Financial calculations
│ ├── handlers/
│ │ ├── math_handler.go # Math operation handlers
│ │ ├── stats_handler.go # Statistics & specialized handlers
│ │ └── finance_handler.go # Financial handlers
│ ├── config/
│ │ ├── config.go # Configuration structures
│ │ ├── loader.go # Configuration loader
│ │ └── errors.go # Configuration errors
│ └── types/
│ └── requests.go # Request/response types
├── pkg/
│ └── mcp/
│ ├── protocol.go # MCP protocol handling
│ └── streamable_http_transport.go # HTTP transport
├── tests/
│ ├── basic_test.go # Basic math tests
│ ├── advanced_test.go # Advanced math tests
│ ├── expression_test.go # Expression evaluation tests
│ ├── integration_test.go # Integration tests
│ ├── config_test.go # Configuration tests
│ └── streamable_http_transport_test.go # HTTP transport tests
├── config.sample.yaml # Sample YAML configuration
├── config.sample.json # Sample JSON configuration
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── Makefile # Build automation
└── README.md # Project documentation# Build for current platform
make build
# Build for all platforms
make build-all
# Install to $GOPATH/bin
make install# Run all tests
make test
# Run tests with coverage
make coverage
# Run tests with race detection
make test-race
# Run benchmarks
make benchmark# Format code
make fmt
# Run linter
make lint
# Run vet
make vet
# Run all quality checks
make quality
# Pre-commit checks
make pre-commit
# CI pipeline
make ci# Run without building (development)
make run-dev
# Run with rebuild
make runbasic_mathPurpose: Basic arithmetic operations with precision control
Parameters:
operation (string): "add", "subtract", "multiply", "divide"operands (array of numbers): Numbers to operate on (minimum 2)precision (integer, optional): Decimal places (0-15, default: 2)advanced_mathPurpose: Advanced mathematical functions
Parameters:
function (string): Function name (sin, cos, tan, asin, acos, atan, log, log10, ln, sqrt, abs, factorial, pow, exp)value (number): Input value (base for pow function)exponent (number, optional): Exponent for pow function (required for pow)unit (string, optional): "radians" or "degrees" for trig functionsexpression_evalPurpose: Evaluate mathematical expressions with variables
Parameters:
expression (string): Mathematical expression to evaluatevariables (object, optional): Variable name-value pairsstatisticsPurpose: Statistical analysis of datasets
Parameters:
data (array of numbers): Dataset to analyzeoperation (string): Statistical operation (mean, median, mode, std_dev, variance, percentile)unit_conversionPurpose: Convert between measurement units
Parameters:
value (number): Value to convertfromUnit (string): Source unittoUnit (string): Target unitcategory (string): Unit category (length, weight, temperature, volume, area)financialPurpose: Financial calculations and modeling
Parameters:
operation (string): Financial operation type (compound_interest, simple_interest, loan_payment, roi, present_value, future_value)principal (number): Principal amountrate (number): Interest rate (percentage)time (number): Time period in yearsperiods (integer, optional): Compounding periods per yearfutureValue (number, optional): Future value for some calculationsstats_summaryPurpose: Comprehensive statistical summary of datasets
Parameters:
data (array of numbers): Dataset for summary statisticspercentilePurpose: Calculate specific percentiles
Parameters:
data (array of numbers): Dataset to analyzepercentile (number): Percentile to calculate (0-100)batch_conversionPurpose: Convert multiple values between units
Parameters:
values (array of numbers): Values to convertfromUnit (string): Source unittoUnit (string): Target unitcategory (string): Unit categorynpvPurpose: Calculate Net Present Value
Parameters:
cashFlows (array of numbers): Cash flows (negative for outflows, positive for inflows)discountRate (number): Discount rate as percentageirrPurpose: Calculate Internal Rate of Return
Parameters:
cashFlows (array of numbers): Cash flows (minimum 2 values)loan_comparisonPurpose: Compare multiple loan scenarios
Parameters:
loans (array of objects): Loan scenarios with principal, rate, and timeinvestment_scenariosPurpose: Compare multiple investment scenarios
Parameters:
scenarios (array of objects): Investment scenarios with principal, rate, and time./calculator-server [OPTIONS]
Options:
-transport string
Transport method (stdio, http) (default "stdio")
-port int
Port for HTTP transport (default 8080)
-host string
Host for HTTP transport (default "127.0.0.1")
-config string
Path to configuration file (YAML or JSON)
Examples:
./calculator-server # Run with stdio transport (default)
./calculator-server -transport=http # Run with HTTP transport on port 8080
./calculator-server -transport=http -port=9000 -host=localhost # Custom host/port
./calculator-server -config=config.yaml # Load configuration from fileThe server supports configuration files in YAML and JSON formats. Configuration files are searched in the following locations:
./config.yaml, ./config.json)./config/ directory/etc/calculator-server/$HOME/.calculator-server/server:
transport: "http"
http:
host: "127.0.0.1" # Localhost for security
port: 8080
session_timeout: "5m"
max_connections: 100
cors:
enabled: true
origins: ["http://localhost:3000", "http://127.0.0.1:3000"] # Never use "*" in production
logging:
level: "info"
format: "json"
output: "stdout"
tools:
precision:
max_decimal_places: 15
default_decimal_places: 2
expression_eval:
timeout: "10s"
max_variables: 100
statistics:
max_data_points: 10000
financial:
currency_default: "USD"
security:
rate_limiting:
enabled: true
requests_per_minute: 100
request_size_limit: "1MB"Environment variables override configuration file settings:
CALCULATOR_TRANSPORT: Transport method (stdio, http)CALCULATOR_HTTP_HOST: HTTP server hostCALCULATOR_HTTP_PORT: HTTP server portCALCULATOR_LOG_LEVEL: Set logging level (debug, info, warn, error)CALCULATOR_LOG_FORMAT: Log format (json, text)CALCULATOR_LOG_OUTPUT: Log output (stdout, stderr)The project includes comprehensive tests with >95% coverage:
# Run specific test suites
go test ./tests/basic_test.go -v
go test ./tests/advanced_test.go -v
go test ./tests/integration_test.go -v
# Generate coverage report
make coverage# Build Docker image
make docker-build
# Run in Docker
make docker-run
# Push to registry
make docker-push# Create release build
make release
# Binaries will be in ./dist/release/
ls -la ./dist/release/The server implements the full MCP (Model Context Protocol) specification:
All tools include comprehensive JSON Schema definitions for parameter validation and documentation. Schemas are automatically generated and include:
| Unit | Abbreviation | Conversion to Meters |
|---|---|---|
| Millimeter | mm | 0.001 |
| Centimeter | cm | 0.01 |
| Meter | m | 1.0 |
| Kilometer | km | 1000.0 |
| Inch | in | 0.0254 |
| Foot | ft | 0.3048 |
| Yard | yd | 0.9144 |
| Mile | mi | 1609.344 |
| Mil | mil | 0.0000254 |
| Micrometer | μm | 0.000001 |
| Nanometer | nm | 0.000000001 |
| Unit | Abbreviation | Conversion to Grams |
|---|---|---|
| Milligram | mg | 0.001 |
| Gram | g | 1.0 |
| Kilogram | kg | 1000.0 |
| Metric Ton | t | 1000000.0 |
| Ounce | oz | 28.3495 |
| Pound | lb | 453.592 |
| Stone | st | 6350.29 |
| US Ton | ton | 907185 |
| Unit | Abbreviation | Description |
|---|---|---|
| Celsius | C | Degrees Celsius |
| Fahrenheit | F | Degrees Fahrenheit |
| Kelvin | K | Kelvin (absolute) |
| Rankine | R | Degrees Rankine |
| Unit | Abbreviation | Conversion to Liters |
|---|---|---|
| Milliliter | ml | 0.001 |
| Centiliter | cl | 0.01 |
| Deciliter | dl | 0.1 |
| Liter | l | 1.0 |
| Kiloliter | kl | 1000.0 |
| US Fluid Ounce | fl_oz | 0.0295735 |
| US Cup | cup | 0.236588 |
| US Pint | pt | 0.473176 |
| US Quart | qt | 0.946353 |
| US Gallon | gal | 3.78541 |
| Teaspoon | tsp | 0.00492892 |
| Tablespoon | tbsp | 0.0147868 |
| Barrel | bbl | 158.987 |
| Unit | Abbreviation | Conversion to m² |
|---|---|---|
| Square Millimeter | mm2 | 0.000001 |
| Square Centimeter | cm2 | 0.0001 |
| Square Meter | m2 | 1.0 |
| Square Kilometer | km2 | 1000000.0 |
| Square Inch | in2 | 0.00064516 |
| Square Foot | ft2 | 0.092903 |
| Square Yard | yd2 | 0.836127 |
| Square Mile | mi2 | 2589988.11 |
| Acre | acre | 4046.86 |
| Hectare | ha | 10000.0 |
| Function | Syntax | Description | Example |
|---|---|---|---|
| Sine | sin(x) | Sine of x (radians) | sin(pi/2) → 1.0 |
| Cosine | cos(x) | Cosine of x (radians) | cos(0) → 1.0 |
| Tangent | tan(x) | Tangent of x (radians) | tan(pi/4) → 1.0 |
| Arcsine | asin(x) | Inverse sine | asin(1) → 1.5708 |
| Arccosine | acos(x) | Inverse cosine | acos(1) → 0.0 |
| Arctangent | atan(x) | Inverse tangent | atan(1) → 0.7854 |
| Function | Syntax | Description | Example |
|---|---|---|---|
| Common Log | log(x) | Base-10 logarithm | log(100) → 2.0 |
| Natural Log | ln(x) | Natural logarithm (base e) | ln(e) → 1.0 |
| Function | Syntax | Description | Example |
|---|---|---|---|
| Square Root | sqrt(x) | Square root of x | sqrt(16) → 4.0 |
| Power | pow(x, y) | x raised to power y | pow(2, 3) → 8.0 |
| Exponential | exp(x) | e raised to power x | exp(1) → 2.7183 |
| Function | Syntax | Description | Example |
|---|---|---|---|
| Absolute Value | abs(x) | Absolute value of x | abs(-5) → 5.0 |
| Factorial | factorial(x) | Factorial of x | factorial(5) → 120.0 |
| Constant | Value | Description |
|---|---|---|
pi | 3.14159... | Pi (π) |
e | 2.71828... | Euler's number |
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)make quality before submittingThis project is licensed under the Apache License 2.0 - see the LICENSE file for details.
shopspring/decimal: Precise decimal arithmeticKnetic/govaluate: Expression evaluationgonum: Scientific computinggopkg.in/yaml.v3: YAML configuration supportPrimary Contact:
Project Resources:
make example-* commandsGetting Help:
Built with ❤️ by Avinash Sangle for the IBM MCP Context Forge project
Connect with the Author:
For more information about MCP servers and the Context Forge project, visit the IBM MCP Context Forge repository.
This repo does not document an install step we could read. Check the README on GitHub.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/calculator-server-go-mcp-server to learn what the "Calculator Server - Go MCP Server" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
This server doesn't publish a machine-readable tool manifest, and it doesn't expose a public endpoint we could ask. Connect the server locally to see what it exposes.
We could not run this server: it ships no npx package for our sandbox and no public endpoint. The four checks that need a live server are left out, and the grade tops out at B until one exists.
Maintain this server? Claiming proves you own the listing and earns the last 4 points.
Claim this listingPaste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/calculator-server-go-mcp-server)Nothing comparable is listed yet.
No tagged releases on record.
Connect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "calculator-server-go-mcp-server" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.