瀏覽全部文件

讓 GitHub Copilot MCP 取得經濟數據

GitHub Copilot 可以在 VS Code 或 Copilot CLI 中透過 MCP 呼叫 Narwhal,工具為唯讀,REST 和 MCP 共用一份額度。VS Code 可以提示輸入金鑰並安全儲存。Copilot CLI 會把金鑰寫入其設定檔,因此請保持該檔案私密。

快速開始

  1. 請至 https://narwhalapi.com/signup 取得免費的 Narwhal 金鑰,並避免把金鑰放進提示詞與網址中。
  2. 若使用 Business 或 Enterprise,連線前請讓管理員在 Copilot 政策中啟用 MCP 伺服器。
  3. VS Code 請使用 1.99 版或更新版本,並將伺服器設定加入 .vscode/mcp.json。
  4. 透過 MCP: List Servers 啟動 Narwhal,並在密碼提示中輸入你的金鑰。
  5. 若使用 Copilot CLI,請用另外的新增指令,並以 /mcp show narwhal 檢查項目。

MCP 設定

VS Code 設定使用含有 HTTP 項目的 servers 物件,以及標頭用的密碼輸入欄位。另外的 CLI 指令則在 Copilot CLI 中註冊同一個託管端點。

.vscode/mcp.json
{
  "inputs": [
    {
      "type": "promptString",
      "id": "NARWHAL_API_KEY",
      "description": "Narwhal API Bearer key",
      "password": true
    }
  ],
  "servers": {
    "narwhal": {
      "type": "http",
      "url": "https://api.narwhalapi.com/mcp",
      "headers": {
        "Authorization": "Bearer ${input:NARWHAL_API_KEY}"
      }
    }
  }
}
Copilot CLI
copilot mcp add --transport http \ --header "Authorization: Bearer YOUR_NARWHAL_API_KEY" \ narwhal https://api.narwhalapi.com/mcp

VS Code 會在伺服器第一次啟動時詢問金鑰,並安全地儲存。CLI 則會將金鑰寫入 ~/.copilot/mcp-config.json;請保持該檔案私有,不要納入版本控制。

可用的工具

GitHub Copilot 透過一個 Narwhal 連線即可使用所有唯讀工具組。初始化和探索免費,每次成功的工具呼叫計為一次呼叫,從與 REST 共用的額度中扣費。

群組可查詢的內容工具
經濟指標可依國家查詢 CPI、通貨膨脹、失業率、勞動力參與率、GDP、GDP 成長率與貿易資料;各指標的涵蓋範圍不同。economics_get_cpi economics_get_inflation economics_get_unemployment economics_get_labour_force_participation economics_get_gdp economics_get_gdp_growth economics_get_trade economics_get_cpi_history economics_get_inflation_history economics_get_unemployment_history economics_get_labour_force_participation_history economics_get_gdp_history economics_get_gdp_growth_history economics_get_trade_history economics_read_series_observations economics_search_catalogue economics_read_catalogue_series economics_read_catalogue_observations economics_read_catalogue_latest_batch economics_get_policy_rate economics_get_policy_rate_history economics_get_central_bank_reserves economics_get_central_bank_balance_sheet
貨幣匯率可查詢貨幣對的即時匯率、歷史匯率、貨幣換算與匯率 K 線。fx_get_rates fx_get_rate_history fx_convert_currency fx_get_rate_bars
大宗商品價格可查詢黃金、白銀、白金、鈀金、銅、WTI原油與布蘭特原油的現貨價格及歷史價格,以及實體棕櫚油價格(粗棕櫚油與棕櫚鮮果串)。commodities_get_spot_price commodities_get_price_history commodities_list_palmoil_physical_series commodities_get_palmoil_physical_price commodities_get_palmoil_physical_observations commodities_list_physical_series commodities_get_physical_series commodities_get_physical_latest commodities_get_physical_observations
公布時程與事件在規劃國家簡報之前,可先查詢官方經濟資料的公布日期與事件詳情。economics_list_releases economics_get_release events_list events_get
國定假日可依國家查詢國定假日、特定日期的假日,或下一個假日。calendars_list_holidays calendars_get_holidays_on_date calendars_get_next_holiday
預測市場機率可查詢預測市場的主題與事件(包含數值、極值、時間與二元結果)、其歷史資料,以及各主管機關的政策路徑。predictions_list_topics predictions_get_topic predictions_list_events predictions_get_scalar predictions_get_extreme predictions_get_timing predictions_get_binary predictions_get_scalar_history predictions_get_extreme_history predictions_get_timing_history predictions_get_binary_history predictions_get_policy_path predictions_get_policy_path_history
政府公債殖利率透過同一個 Narwhal 連線,可查詢美國、英國、德國、日本、加拿大、瑞典、挪威、澳洲與歐元區的公債殖利率曲線。economics_get_yield_curve economics_get_yield_curve_history

提示詞範例

  • 取得德國最新的失業率。
  • 顯示可用的 GBP/USD 匯率歷史。
  • 請取得現有的棕櫚油價格歷史資料。
  • 查詢英國下一個公共假期。
  • 取得美國最新的 GDP 成長率。

常見工作流程

查看德國最新的 GDP 觀測值

要取得德國最新的 GDP 觀測值,請選擇德國並呼叫 economics 工具 economics_get_gdp。

檢視貨幣對的匯率

GBP/USD 的歷史資料來自 fx_get_rate_history,以 GBP 作為基準貨幣,並以 ["USD"] 作為報價貨幣清單。將 start_date 設為 2026-09-08,end_date 設為 2026-09-14。

在 Copilot 中查看棕櫚油資料

你需要哪個新鮮果串數列?請透過 commodities_list_palmoil_physical_series 選擇一個,再將其數列 ID 提供給 commodities_get_palmoil_physical_observations,即可依原生期間取得價格。

圍繞英國公共假期規劃行程

將英國與起始日期傳給 calendars_get_next_holiday,即可找出該日期當天或之後的下一個已公布假期。

使用提示

  • 在 VS Code 中使用 promptString 類型的輸入,並設定 "password": true,然後在 Authorization 標頭中以 ${input:NARWHAL_API_KEY} 參照。
  • 從命令選擇區開啟 MCP: List Servers,即可啟動、停止或重新啟動 Narwhal,並檢視其輸出。
  • 若需要在工作階段之外檢視已註冊的伺服器,可用 copilot mcp get narwhal 檢查 CLI 項目。
  • Business 與 Enterprise 的 MCP 政策預設為關閉;Copilot Free、Pro、Pro+ 與 Max 不受該政策管理。

常見問題

如何在 VS Code 中將 Narwhal 加入 GitHub Copilot?

建立 .vscode/mcp.json,包含 HTTP 伺服器項目、Narwhal 網址,以及以密碼輸入欄位支援的 Authorization 標頭。從 MCP: List Servers 啟動伺服器,並在 VS Code 詢問時提供你的金鑰。

Copilot CLI 把我的 Narwhal 金鑰存在哪裡?

執行新增指令後,Copilot CLI 會將金鑰存放在 ~/.copilot/mcp-config.json。請保持該檔案私有,不要納入版本控制,也切勿將金鑰貼進提示詞或網址。

Copilot 需要管理員啟用 MCP 嗎?

Business 與 Enterprise 需要管理員在 Copilot 政策中啟用 MCP 伺服器。此政策預設為關閉,且不適用於 Copilot Free、Pro、Pro+ 或 Max。

故障排查

症狀檢查
Narwhal 沒有顯示在 VS Code 中檢查 .vscode/mcp.json 是否有 servers 物件,以及含有 "type": "http" 的項目,然後開啟 MCP: List Servers。
呼叫回傳 401 invalid_api_key請確認所提供的金鑰有效,且 Authorization 的值包含 Bearer、一個空格與金鑰。
Business 或 Enterprise 帳戶封鎖了 MCP請管理員在 Copilot 政策中檢查 MCP 伺服器,並為你的帳戶啟用。
CLI 項目遺失或使用了錯誤的網址用 copilot mcp get narwhal 檢查,並使用確切的 https://api.narwhalapi.com/mcp,結尾不要加斜線。

此頁面對你有幫助嗎?