TCMB MCP
土耳其中央银行(TCMB)汇率的生产就绪MCP(模型上下文协议)服务器。
](https://smithery.ai/server/@ofurkanuygur/tcmb_mcp)
特性
- 当前汇率:从TCMB获取今天的汇率
- 历史价格:1996年以来任何日期的查询率
- 货币兑换:在任何货币之间转换(包括土耳其里拉)
- 产量变化情况:获取带有统计信息的速率历史记录(最小值、最大值、平均值、变化百分比)
- 多币种比较:随时间比较多种货币
- 智能缓存:基于SQLite的缓存,具有可配置的TTL
- 假期支持:自动回退到前一个工作日
- 土耳其假期:包括所有官方和宗教节日
安装
使用Smithery(推荐)
直接通过安装 铁匠铺:
npx -y @smithery/cli install @ofurkanuygur/tcmb_mcp --client claude利用紫外线(地方发展)
git clone https://github.com/ofurkanuygur/tcmb_mcp.git
cd tcmb_mcp
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv pip install -e .使用pip
pip install tcmb-mcp用法
Claude桌面配置
添加到您的Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"tcmb": {
"command": "python",
"args": ["-m", "tcmb_mcp"],
"env": {
"TCMB_CACHE_ENABLED": "true",
"TCMB_DEBUG": "false"
}
}
}
}手动运行
# stdio mode (default, for Claude Desktop)
python -m tcmb_mcp
# HTTP mode (for Smithery deployment)
MCP_TRANSPORT=http python -m tcmb_mcpMCP检验员测试
npx @modelcontextprotocol/inspector python -m tcmb_mcp可用工具
1.tcmb_get_current_rates
从TCMB获取当前汇率。
Dolar ve Euro kurunu göster
→ tcmb_get_current_rates(currencies=["USD", "EUR"])2.tcmb_get_历史汇率
获取特定日期的汇率。
15 Ocak 2024 kurlarını getir
→ tcmb_get_historical_rates(date="2024-01-15")3.tcmb_list_货币
列出所有可用货币。
Hangi para birimleri var?
→ tcmb_list_currencies()4.tcmb_convert_currency
在货币之间转换。
1000 Dolar kaç TL?
→ tcmb_convert_currency(amount=1000, from_currency="USD", to_currency="TRY")5.tcmb_get_rate历史
使用统计数据获取费率历史记录。
Son 30 günde Dolar nasıl değişti?
→ tcmb_get_rate_history(currency="USD", start_date="2024-11-01", end_date="2024-11-30")6.tcmb_compare_currents
比较多种货币。
Dolar, Euro ve Sterlin'i karşılaştır
→ tcmb_compare_currencies(target_currencies=["USD", "EUR", "GBP"])配置
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
TCMB_CACHE_ENABLED | true | 启用SQLite缓存 |
TCMB_CACHE_DB_PATH | ~/.cache/tcmb-mcp/tcmb_cache.db | 缓存数据库路径 |
TCMB_CACHE_TTL_TODAY | 3600 | 缓存今天的TTL(秒) |
TCMB_CACHE_TTL_HISTORICAL | 31536000 | 缓存历史TTL(秒) |
TCMB_TIMEOUT | 10 | API超时(秒) |
TCMB_MAX_RETRIES | 3 | 最大重试次数 |
TCMB_DEBUG | false | 启用调试日志记录 |
TCMB_LOG_LEVEL | INFO | 日志级别 |
MCP_TRANSPORT | stdio | 运输方式(stdio 或 http) |
PORT | 8080 | HTTP服务器端口(使用HTTP传输时) |
发展
设置
git clone https://github.com/ofurkanuygur/tcmb_mcp.git
cd tcmb_mcp
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"运行测试
# All tests
pytest
# With coverage
pytest --cov=src/tcmb_mcp --cov-report=term-missing
# Unit tests only
pytest tests/unit/代码质量
# Linting
ruff check src/
# Type checking
mypy src/本地HTTP服务器测试
# Start server in HTTP mode
MCP_TRANSPORT=http python -m tcmb_mcp
# Test with Smithery playground
npx -y @smithery/cli playground --port 8080码头工人
构建
docker build -t tcmb-mcp .跑
docker run -p 8080:8080 tcmb-mcpapi参考
TCMB URL格式
- 今天的价格:
https://www.tcmb.gov.tr/kurlar/today.xml - 历史:
https://www.tcmb.gov.tr/kurlar/YYYYMM/DDMMYYYY.xml
- 示例:2024年1月15日→ /kurlar/202401/15012024.xml
费率类型
| 类型 | 土耳其语 | 描述 |
|---|---|---|
forex_buying | Döviz Alış | 电子转账购买率 |
forex_selling 电子转账销售率 Electronic Transfer Selling Rate | ||
banknote_buying | Efektif Alış | 现金购买率 |
banknote_selling 现金销售率 Cash Selling Rate |
作者
Oktay Furkan 维吾尔
- github: @维吾尔语
