Skip to main content
Glama
UniRate MCP

UniRate MCP

Official
by UniRate-API

UniRate MCP 服务器

npm License

这是一个用于 UniRate API 的 Model Context Protocol 服务器 —— 让 Claude、Cursor、Continue 以及任何兼容 MCP 的 AI 助手能够直接获取货币转换和汇率信息。

  • 🔄 170 多种货币(法币 + 主流加密货币)之间的实时转换

  • 📈 历史汇率可追溯至 1999 年(Pro 计划)

  • 🆓 免费层级,无需信用卡 —— 请在 unirateapi.com 获取密钥

  • 🧩 四个工具,完全类型化的输入(Zod 模式),结构化输出

  • 🌐 Stdio + 可流式传输的 HTTP/SSE 传输 —— 可本地运行或作为远程 MCP 端点托管

  • ⚡ 纯 Node 18+,仅依赖 @modelcontextprotocol/sdk

为什么需要这个

目前大多数“AI 货币”工作流要么涉及在自定义工具中手动编写 fetch 包装器,要么使用将原始 JSON 传给模型的通用 HTTP MCP 服务器。本服务器为模型提供了一个紧凑、类型化且具备货币感知能力的工具界面 —— 它们可以询问“2020-03-15 的 100 美元是多少欧元?”,并获得格式化的答案以及可链接到其他工具调用的结构化负载。

Related MCP server: Currency Exchange MCP Server

快速开始

1. 安装

npm install -g @unirate/mcp

或者使用 npx @unirate/mcp 按需运行(无需安装)。

2. 获取 UniRate API 密钥

免费层级涵盖 convert、latest_rate 和 list_currencies。请在 unirateapi.com 注册 —— 无需信用卡。

3. 将其接入你的 MCP 客户端

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) 或 %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "unirate": {
      "command": "npx",
      "args": ["-y", "@unirate/mcp"],
      "env": {
        "UNIRATE_API_KEY": "your-api-key-here"
      }
    }
  }
}

重启 Claude Desktop。四个 UniRate 工具将出现在工具选择器中。

Cursor / Continue / Cline

添加到你的 MCP 配置中(.cursor/mcp.json、~/.continue/config.json 等):

{
  "mcpServers": {
    "unirate": {
      "command": "npx",
      "args": ["-y", "@unirate/mcp"],
      "env": { "UNIRATE_API_KEY": "your-api-key-here" }
    }
  }
}

从源码运行

git clone https://github.com/UniRate-API/unirate-mcp.git
cd unirate-mcp
npm install && npm run build
UNIRATE_API_KEY=your-key node dist/index.js

4. 作为远程端点运行(可流式传输的 HTTP / SSE)

默认情况下,服务器使用 stdio,这是 Claude Desktop 和大多数 MCP 客户端所需要的。若要将其作为远程端点托管(用于共享使用、多用户部署或基于浏览器的客户端),请以 HTTP 模式启动:

UNIRATE_API_KEY=your-key unirate-mcp --http 3001
# or via env:
UNIRATE_API_KEY=your-key UNIRATE_MCP_HTTP_PORT=3001 unirate-mcp

这将暴露:

  • POST /mcp — 可流式传输的 HTTP 端点(支持 SSE)。无状态:每个请求都会构建一个新的服务器,因此同一个进程可以服务多个并发客户端。

  • GET /healthz — JSON 存活探针 ({ "status": "ok", "server": "unirate-mcp", "version": "..." })。

将任何支持可流式传输 HTTP 的 MCP 客户端(支持远程服务器的 Claude Desktop、Cursor 远程 MCP 等)指向 http://your-host:3001/mcp。在生产环境中,请将其置于反向代理 + TLS 之后。

编程方式 / Edge 运行时(Cloudflare Workers、Deno、Bun)

该包导出了 buildServer(client),因此你可以将其连接到你的运行时所偏好的任何传输方式。对于 Workers / Deno / Bun,请使用 SDK 的 webStandardStreamableHttp 传输方式配合导出的 buildServer 实例。

import { UnirateClient } from "@unirate/mcp/dist/client.js";
import { buildServer } from "@unirate/mcp";
// → connect to your runtime's preferred transport

工具

convert

按最新汇率将金额从一种货币转换为另一种货币。

参数

类型

必填

说明

from

string

是

ISO 4217 代码 (例如 USD)

to

string

是

ISO 4217 代码 (例如 EUR)

amount

number

是

from 的正数金额

调用示例:

{ "name": "convert", "arguments": { "from": "USD", "to": "EUR", "amount": 100 } }

响应: 人类可读的文本加上结构化的 { from, to, amount, result }。

latest_rate

获取当前汇率。

参数

类型

必填

说明

from

string

是

基础货币

to

string

否

目标货币。省略以获取所有货币的汇率

historical_rate (Pro 计划)

获取特定日期生效的汇率。主要法币对的历史数据可追溯至 1999-01-04。

参数

类型

必填

说明

date

string

是

YYYY-MM-DD (例如 2020-03-15)

from

string

是

源货币

to

string

是

目标货币

amount

number

否

默认为 1

免费层级密钥会收到明确的错误提示,引导用户前往 unirateapi.com 进行升级。

list_currencies

返回支持的货币代码数组(170+),无需参数。适用于自动补全或验证用户提供的代码。

错误处理

所有 UniRate API 故障都会映射为友好的工具错误:

HTTP

错误类

模型看到的错误信息

400

InvalidRequestError

"Invalid request parameters"

401

AuthenticationError

"Missing or invalid API key"

403

ProPlanRequiredError

"…requires Pro… upgrade at https://unirateapi.com"

404

InvalidCurrencyError

"Currency not found or no data available"

429

RateLimitError

"Rate limit exceeded"

503

APIError

"Service unavailable"

网络/超时错误会被封装在 UnirateError 中。工具调用总是返回带有 isError: true 的响应对象,而不是抛出协议级别的错误,以便模型能够优雅地恢复。

开发

npm install
npm run build       # compile TypeScript to dist/
npm test            # 24 mock tests
UNIRATE_LIVE=1 UNIRATE_API_KEY=... npm run test:live  # +4 live free-tier tests

相关项目

UniRate 提供 9 种语言的官方客户端库:

以及一个 n8n 社区节点。

许可证

MIT — 详见 LICENSE。

Available Tools

4 tools
convertConvert currencyA
Read-only

Convert an amount from one currency to another using the latest exchange rate. Codes are ISO 4217 (e.g. USD, EUR, GBP). Supports 170+ fiat currencies and major cryptocurrencies.

Inputs: from (required), to (required), amount (required).

historical_rateGet historical exchange rate (Pro plan required)A
Read-only

Fetch the exchange rate that was in effect on a specific date. Date format YYYY-MM-DD. Coverage goes back to 1999-01-04 for major fiat pairs. Requires UniRate Pro — free-tier keys will receive a clear upgrade-required error.

Inputs: date (required), from (required), to (required), amount.

latest_rateGet latest exchange rate(s)A
Read-only

Fetch the latest exchange rate for a base currency. If 'to' is provided, returns a single rate; otherwise returns rates for all supported currencies relative to the base.

Inputs: from (required), to.

list_currenciesList supported currenciesA
Read-only

Return the list of currency codes supported by the UniRate API (170+ fiat plus major crypto).

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool serves a distinct purpose: converting amounts, fetching historical rates, getting latest rates, and listing supported currencies. No overlaps.

    Naming Consistency5/5

    All tool names use consistent snake_case and follow a verb_noun or adjective_noun pattern, making them predictable.

    Tool Count5/5

    4 tools is well-scoped for a currency conversion API, covering essential operations without unnecessary complexity.

    Completeness5/5

    The tool set covers conversion, latest rates, historical rates, and currency listing—no obvious gaps for the domain.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides real-time foreign-exchange rates, historical data, and multi-currency lookups to MCP-compatible AI coding assistants like Claude Code and Cursor.
      4
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables real-time currency exchange rate retrieval and conversion for over 200 currencies. Supports operations like getting rates, converting amounts, and comparing currencies through natural language.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to retrieve live buy and sell exchange rates from 1,219 commercial banks across 124 countries, compare banks, check spreads against central bank official rates, and look up past daily rates.
      7
      179 npm
      MIT