# Unit & FX Calculator MCP

> Unit & FX Calculator provides deterministic math for unit conversion and real-time currency rates. Stop LLMs from guessing exchange rates or mixing metric/imperial units. This server uses exact mathematical engines to convert length, mass, volume, temperature, and speed; it also pulls live rates directly from the European Central Bank.

## Overview
- **Category:** productivity
- **Price:** Free
- **Tags:** currency-exchange, fx-rates, unit-conversion, financial-data, real-time-rates

## Description

Listen up, because when your AI client needs math that's actually right—not some educated guess—you don't trust a standard LLM. Those things are notorious for messing up conversions, whether it's mixing metric and imperial units or hallucinating exchange rates based on data from last year. This server fixes that. It hooks your agent into a dedicated mathematical engine and a live financial feed, giving you the numbers you need, period.

When you use this toolset, you get deterministic math for every physical conversion imaginable: length, mass, volume, temperature, and speed. You'll never have to worry about approximation again.

If you just gotta convert one thing—say, taking a value like 65 miles per hour and turning it into kilometers per hour—you call **`convert_unit`**. It uses precise math logic that guarantees the correct equivalent every single time. You give it a starting value and two units, and it spits out the mathematically exact answer. That's how you get reliable unit conversions.

But what if you got a spreadsheet full of numbers? Maybe you gotta convert a dozen different volumes or temperatures all at once. Don't run twelve separate calls; just hit **`batch_convert`**. This tool accepts an array of values and processes them in one deterministic pass, making quick batch processing painless. It handles the whole bulk conversion for you.

When it comes to money, forget those historical rates your agent might pull from its training data. For real currency exchange, you'll use **`get_rate`**. You tell it two three-letter currency codes—like USD and JPY—and it pulls the current market rate directly from the European Central Bank. This isn't old info; it's what the global market is using right now.

We built this whole system to avoid guesswork. The math engines handle conversions for things like Celsius to Fahrenheit or kilometers per hour to miles per hour with surgical precision. And when you need a rate, **`get_rate`** uses an hourly local cache on the European Central Bank data source, so if you're running massive conversion jobs, it doesn't bog down or hit rate limits.

Here’s how it plays out: You tell your agent to calculate something complex. It recognizes that it needs a reliable math toolset and executes the steps automatically. Whether you need **`convert_unit`** for a single measurement, **`batch_convert`** for twenty measurements, or **`get_rate`** because you're dealing with foreign currency, the results are always mathematically solid.

It’s about getting accurate data when your workflow depends on it. You'll stop spending time verifying if that number is right and start using the numbers to get work done.

## Tools

### batch_convert
Converts multiple physical units (like volume or temperature) in one deterministic pass for quick batch processing.

### convert_unit
Deterministically converts a single physical unit, such as converting kilometers per hour to miles per hour using precise math logic.

### get_rate
Retrieves the current foreign exchange rate between two currencies using the European Central Bank data source with an hourly local cache.

## Prompt Examples

**Prompt:** 
```
Convert 120 km/h into miles per hour (mph) and round strictly to 2 decimals.
```

**Response:** 
```
✅ **Converted Unit:** `74.56 mph`
```

**Prompt:** 
```
Fetch the live exchange rate to convert `USD` to `BRL`.
```

**Response:** 
```
✅ **Live FX Rate:** `5.21` (Fetched from European Central Bank, cached locally).
```

**Prompt:** 
```
Batch convert this array of 5 temperatures from Celsius to Fahrenheit deterministically.
```

**Response:** 
```
✅ **Batch Completed:** Processed 5 units instantly with 0 loss in float precision.
```

## Capabilities

### Perform single unit conversion
You give it a value and two units (e.g., Celsius to Fahrenheit), and the tool returns the mathematically precise equivalent.

### Process multiple unit conversions in bulk
The system accepts an array of values and converts them all at once using one deterministic calculation pass.

### Fetch live currency exchange rates
You specify two three-letter currency codes (e.g., USD to JPY), and the tool returns the current, precise market rate from the European Central Bank.

## Use Cases

### Standardizing international project specs
A civil engineer needs to update a spec sheet that mixes metric measurements for volume and imperial measurements for length. Instead of manually checking the conversion factors, they ask their agent to run `convert_unit` multiple times until all units match the target standard (e.g., converting cubic meters to gallons). The process is guaranteed accurate.

### Validating a multi-currency investment portfolio
A financial analyst needs to check the current conversion value of several holdings across different currencies (USD, EUR, GBP). They run `get_rate` for each pair. The agent pulls the live rates from the ECB and gives them a consolidated report, preventing old data errors.

### Processing sensor data logs in bulk
A scientist collects 50 temperature readings over an hour, some recorded in Celsius and others in Kelvin. Rather than running 50 individual conversions, they use `batch_convert` to process the entire list instantly with guaranteed float precision.

### Calculating speed differences across borders
A logistics manager is comparing vehicle speeds recorded from different regions—some in km/h and some in mph. They instruct their agent to use `convert_unit` to standardize every single entry into a consistent unit (e.g., always report in MPH).

## Benefits

- Eliminate math errors when converting units. Instead of risking an LLM guessing the conversion factor, use `convert_unit` for guaranteed accuracy on single values (e.g., Fahrenheit to Celsius).
- Handle large datasets instantly. If you have a list of 100 volumes or speeds to check, run them through `batch_convert`. It processes everything deterministically in one go.
- Use today's actual currency rates. Don't rely on outdated training data for finance. Call `get_rate` to pull live FX feeds from the European Central Bank.
- Save time with local caching. Because we cache FX rates locally for an hour, running repetitive batch conversions is fast and won't hit external rate limits.
- Support complex units. This tool handles more than just length; it deals with speed (km/h to mph) and temperature, making it useful across engineering domains.

## How It Works

The bottom line is: you stop relying on general LLM knowledge for math that needs to be perfectly accurate right now.

1. Tell your agent exactly what you need: a conversion or an exchange rate.
2. The server executes the appropriate tool (`convert_unit`, `batch_convert`, or `get_rate`) using its external math and finance APIs.
3. You get back a deterministic, precise answer—either the converted number or the live market rate.

## Frequently Asked Questions

**How do I use the batch_convert tool?**
You pass an array containing the value, source unit, and target unit to `batch_convert`. It handles multiple conversions at once in a single deterministic pass.

**Is the currency rate from get_rate always up-to-date?**
Yes. The tool pulls rates directly from the European Central Bank (Frankfurter API). Plus, it caches these rates locally for one hour, making subsequent calls fast.

**Can convert_unit handle complex units like speed?**
Yep. `convert_unit` is built to handle multiple physical dimensions, so you can accurately switch between speed units (like km/h and mph) or temperature scales.

**What if I run get_rate repeatedly in a short time?**
You won't. The tool caches the rate locally for one hour, so repeated calls within that window are instant and don't stress external APIs.

**How long is the cache duration when using get_rate?**
The exchange rate data is cached for one hour. This means if you run multiple conversions within that window, subsequent calls are instantaneous and won't trigger rate limits, which speeds up large batch jobs.

**What happens when convert_unit receives bad input?**
The tool validates all inputs against known units. If you give it a non-standard unit or an invalid format, the engine throws a specific error message telling you exactly what needs correcting.

**What data types can batch_convert process efficiently?**
It accepts arrays containing values, source units, and target units. The underlying mathematical model processes standard numeric inputs across all dimensions reliably.

**Is the data from get_rate secure and traceable to me?**
No, the rates come directly from the European Central Bank. We only fetch public reference rates; your specific conversion history is managed by your AI client's session, not stored on our end.

**How often are currency rates updated?**
Rates are fetched live and cached for exactly 1 hour.

**What physical units are supported?**
Length, mass, volume, temperature, and speed are fully supported via mathjs.

**Can it batch convert an array of data?**
Yes, the batch processor can handle large JSON arrays instantly.