通過 MCP 連接
從MCP客戶端使用相同的Narwhal密鑰和公開API架構。
Narwhal 提供一個無狀態、可流式傳輸的 HTTP MCP 端點,並與 REST 使用相同的六個數據 API、回應架構、身份驗證和配額。
連接
將遠程服務器 URL 和 Bearer 標頭添加到支援經認證 Streamable HTTP 的 MCP 客戶端。
{
"url": "https://api.narwhalapi.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_NARWHAL_API_KEY"
}
}這是欄位映射,而不是可直接複製粘貼的文件。請替換 YOUR_NARWHAL_API_KEY 通過客戶端的安全密鑰設置。JSON 不會自行展開 shell 變量,MCP 客戶端使用不同的環境變量語法。
不要將真實密鑰粘貼到共享配置文件中。
可用工具
tools/list 返回 33 個只讀工具:18 個 Economics 操作,以及 FX、Equities、SEC 申報、Palmoil 和 Calendars 各 3 個操作。
economics_get_cpieconomics_get_inflationeconomics_get_unemploymenteconomics_get_labour_force_participationeconomics_get_gdpeconomics_get_gdp_growtheconomics_get_tradeeconomics_get_trade_exportseconomics_get_trade_importseconomics_get_cpi_historyeconomics_get_inflation_historyeconomics_get_unemployment_historyeconomics_get_labour_force_participation_historyeconomics_get_gdp_historyeconomics_get_gdp_growth_historyeconomics_get_trade_historyeconomics_get_trade_exports_historyeconomics_get_trade_imports_historyfx_get_ratesfx_get_rate_historyfx_convert_currencyequities_list_instrumentsequities_get_instrumentequities_get_barscompanies_searchcompanies_getcompanies_list_filingscommodities_discover_physical_seriescommodities_get_oil_palm_ffb_pricecommodities_get_oil_palm_ffb_price_observationscalendars_list_holidayscalendars_get_holidays_on_datecalendars_get_next_holiday參數和結果
最新發布工具接受 country 以及可選項 period。歷史數據工具接受 country,可選 start 和 end,另加 limit 和 cursor 用於分頁。
{
"country": "USA",
"period": "2026-07"
}對於兩個有方向的貿易工具,MCP 使用 "product": { "classification": "HS2022", "code": "27" }。REST 將相同的篩選條件表示為獨立的 classification 和 product 查詢參數。
| 工具 | 期間 | 其他參數 |
|---|---|---|
economics_get_cpi | YYYY-MM | 無 |
economics_get_inflation | YYYY-MM | 無 |
economics_get_unemployment | YYYY, YYYY-MM, or YYYY-QN | 無 |
economics_get_labour_force_participation | YYYY, YYYY-MM, or YYYY-QN | 無 |
economics_get_gdp | YYYY-QN | 無 |
economics_get_gdp_growth | YYYY-QN | 無 |
economics_get_trade | YYYY or YYYY-MM | 無 |
economics_get_trade_exports | YYYY or YYYY-MM | partner 以及嵌套內容 product 可以接受,但篩選後的總數尚未發布。 |
economics_get_trade_imports | YYYY or YYYY-MM | partner 以及嵌套內容 product 可以接受,但篩選後的總數尚未發布。 |
economics_get_cpi_history | YYYY-MM | start, end, limit,以及 cursor |
economics_get_inflation_history | YYYY-MM | start, end, limit,以及 cursor |
economics_get_unemployment_history | YYYY, YYYY-MM, or YYYY-QN | start, end, limit,以及 cursor |
economics_get_labour_force_participation_history | YYYY, YYYY-MM, or YYYY-QN | start, end, limit,以及 cursor |
economics_get_gdp_history | YYYY-QN | start, end, limit,以及 cursor |
economics_get_gdp_growth_history | YYYY-QN | start, end, limit,以及 cursor |
economics_get_trade_history | YYYY-MM | start, end, limit,以及 cursor |
economics_get_trade_exports_history | YYYY-MM | start, end, limit,以及 cursor |
economics_get_trade_imports_history | YYYY-MM | start, end, limit,以及 cursor |
成功的工具呼叫返回符合架構的 structuredContent 以及為客戶端兼容性而序列化為文本的相同 JSON。MCP 問題使用與 REST 相同的公開狀態和代碼詞彙。
配額行為
初始化和工具發現不會消耗數據配額。每次成功的 tools/call 恰好消耗一次請求,與一次成功的 REST 呼叫相同。
{
"method": "tools/call",
"params": {
"name": "fx_get_rates",
"arguments": { "base": "USD", "currencies": ["EUR", "JPY"] }
}
}免費測試版包括 3,000 每個 UTC 月的成功請求數,加上 30 每分鐘請求數,突發容量為 5。額度狀態返回於 X-RateLimit-Limit, X-RateLimit-Remaining,以及 X-RateLimit-Reset;短窗口狀態在 X-RateLimit-Short-Limit, X-RateLimit-Short-Remaining,以及 X-RateLimit-Short-Reset。短時窗口限流會返回 429 rate_limit_exceeded;每月額度耗盡時返回 429 quota_exhausted.
故障排查
| 症狀 | 檢查 |
|---|---|
401 invalid_api_key | 確認確切的 Bearer 標頭,並確認密鑰仍處於活動狀態。 |
| 連接會跟隨重定向 | 請準確使用 https://api.narwhalapi.com/mcp 不帶結尾斜槓。 |
| 工具缺失 | 僅可使用上面列出的公共工具。 |
| 工具返回問題 | 讀取結構化狀態、代碼、詳情和請求 ID。參見 錯誤與配額. |