Skip to main content
Glama

findata-mcp

コード作成エージェント向けのMCPサーバーを備えた統合金融データライブラリです。

エージェントがMCPにクエリ(例: "equity daily prices")を送信すると、以下を受け取ります:

  • findata ラッパー関数のシグネチャ

  • パラメータと戻り値の型に関する完全なドキュメント

  • 当社のAPIを呼び出す、コピーしてすぐ使えるコード例

MCPはライブデータを取得しません。これはドキュメントサーバーであり、エージェントがfindataライブラリへの正しい呼び出しを書けるようにするためのものです。


プロジェクト構造

data-mcp/
├── findata/                         Data library
│   ├── equity_prices.py             get_equity_prices()           yfinance wrapper
│   ├── sp500_composition.py         get_sp500_composition()       fja05680/sp500 (local git clone)
│   ├── fama_french.py               get_fama_french_factors()     Ken French Data Library
│   ├── fred.py                      get_fred_series()             FRED macroeconomic series
│   ├── cboe_volatility.py           get_cboe_volatility_indices() VIX / VVIX
│   ├── coingecko.py                 get_coingecko_ohlcv()         CoinGecko public API
│   ├── file_reader.py               get_file_data()               CSV / Parquet / Excel
│   └── bloomberg.py                 get_bloomberg_ticks()         blpapi — tick-by-tick
│                                    get_bloomberg_bars()          blpapi — intraday OHLCV
│                                    get_bloomberg_data()          blpapi — historical / reference
├── findata_mcp/
│   └── server.py                    Tool registry + MCP handlers
├── Dockerfile
├── docker-compose.yml
├── .github/workflows/docker.yml     GHCR build + push on every push to main
├── pyproject.toml
└── README.md

Related MCP server: FinData MCP

インストール

findata-mcpを実行する推奨方法はDockerです。イメージはmainへのプッシュのたびにGHCRに公開され、Codex CLIが組み込まれています。

前提条件

  • Docker

  • ホストマシンで認証済みのCodex

1. Codexを認証する(初回のみ)

codex auth login    # opens browser → saves to ~/.codex/auth.json

2. プルして実行

curl -O https://raw.githubusercontent.com/lakshya-aga/data-mcp/main/docker-compose.yml
docker compose up -d

docker-compose.ymlは~/.codexを読み取り専用でマウントするため、コンテナは対話型プロンプトなしでCodexセッションを継承します。名前付きボリュームにより、生成されたファイルとデータは再起動後も保持されます。

3. 確認

docker logs data-mcp-findata-mcp-1
# should show: findata-mcp starting on :8000

サーバーへの接続

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.jsonに追加:

{
  "mcpServers": {
    "findata": {
      "url": "http://localhost:8000/sse"
    }
  }
}

Python(生のMCPクライアント)

import asyncio
from mcp.client.sse import sse_client
from mcp.client.session import ClientSession

async def main():
    async with sse_client("http://localhost:8000/sse") as (r, w):
        async with ClientSession(r, w) as s:
            await s.initialize()
            res = await s.call_tool("search_tools", {"query": "equity daily prices", "top_k": 3})
            print(res.content[0].text)

asyncio.run(main())

OpenAI Agents SDK

from agents.mcp import MCPServerSse
mcp = MCPServerSse(url="http://localhost:8000/sse")

MCPツール

ツール

説明

search_tools

自然言語クエリ → 一致する関数ドキュメントとコード例

get_tool_doc

正確な名前による1つの関数の完全なリファレンス

list_all_tools

すべてのラッパー関数と要約およびタグ

request_data_source

新しいデータラッパーを実装して登録するようCodexに依頼

res = await s.call_tool("search_tools", {"query": "fama french factors", "top_k": 2})

get_tool_doc

res = await s.call_tool("get_tool_doc", {"tool_name": "get_equity_prices"})

request_data_source

res = await s.call_tool("request_data_source", {
    "description": "get World Bank GDP per capita using the wbdata library"
})

Codexはfindata/<module>.pyを作成し、server.pyを更新し、新しい関数をライブレジストリにホットリロードします。再起動は不要です。


環境変数

変数

説明

OPENAI_API_KEY

Codex認証 — 設定するとOAuthをスキップ(ホスト認証マウントの代替)

FRED_API_KEY

get_fred_seriesに必須。無料で取得可能: fred.stlouisfed.org

CODEX_CLI_PATH

Codexバイナリのパスを上書き(デフォルトはPATH上のcodex)

BLOOMBERG_HOST

get_bloomberg_*関数用のBloomberg APIホスト(デフォルトlocalhost)

BLOOMBERG_PORT

Bloomberg APIポート(デフォルト8194)

BLOOMBERG_TIMEOUT_MS

Bloombergリクエストが放棄されるまでのイベントごとの待機時間(デフォルト30000)

BLOOMBERG_AUTH

Server API / B-PIPE用のsetAuthenticationOptions文字列(例: AuthenticationType=OS_LOGON)。デスクトップターミナルの場合は未設定のままにしてください


findataクイックリファレンス

get_equity_prices

from findata.equity_prices import get_equity_prices

df = get_equity_prices(
    tickers=["AAPL", "MSFT"],
    start_date="2024-01-01",
    end_date="2024-12-31",
    fields=["Close"],
    frequency="1d",         # 1d 5d 1wk 1mo 3mo
)

get_fama_french_factors

from findata.fama_french import get_fama_french_factors

df = get_fama_french_factors(factor_model="5", start_date="2010-01-01", end_date="2020-12-31")
# columns: Mkt-RF, SMB, HML, RMW, CMA, RF

get_fred_series

from findata.fred import get_fred_series

df = get_fred_series(["CPIAUCSL", "UNRATE"], start_date="2015-01-01", end_date="2024-12-31")

get_coingecko_ohlcv

from findata.coingecko import get_coingecko_ohlcv

df = get_coingecko_ohlcv("bitcoin", vs_currency="usd", days=90)
# columns: open, high, low, close, volume

get_cboe_volatility_indices

from findata.cboe_volatility import get_cboe_volatility_indices

df = get_cboe_volatility_indices(symbols=["^VIX", "^VVIX"], start_date="2020-01-01", end_date="2024-12-31")

get_sp500_composition

from findata.sp500_composition import get_sp500_composition

members = get_sp500_composition("2024-12-31")   # list[str], ~503 tickers

get_bloomberg_ticks — あらゆる証券のティックレベルデータ

Bloomberg Terminal、SAPIまたはB-PIPEの権限、およびSDKが必要です:

pip install blpapi --index-url https://bcms.bloomberg.com/pip/simple/
from findata.bloomberg import get_bloomberg_ticks

# Every trade print in one US cash session, in New York time
ticks = get_bloomberg_ticks(
    "AAPL US Equity",
    "2024-06-03 09:30:00",
    "2024-06-03 16:00:00",
    tz="America/New_York",
)
# index = time (tz-aware)
# columns: security, type, value, size, conditionCodes, exchangeCode

# Trades AND top-of-book quotes, one hour per sub-request
book = get_bloomberg_ticks(
    "ESZ5 Index",
    "2024-06-03 13:30:00",
    "2024-06-03 20:00:00",
    event_types=["TRADE", "BID", "ASK"],
    chunk="1h",
)

# VWAP straight from the prints
trades = ticks[ticks["type"] == "TRADE"]
vwap = (trades["value"] * trades["size"]).sum() / trades["size"].sum()

証券文字列はそのままBloombergに渡されるため、ターミナルで引用できるものはすべて機能します — "AAPL US Equity"、"ESZ5 Index"、"EURUSD Curncy"、"TY1 Comdty"、"US912810TW33 Govt"。

長いウィンドウはchunkサイズのサブリクエスト(デフォルトは1日)に分割され、連結されます。Bloombergは過大な日内レスポンスをエラーにせずに静かに切り詰めるためです。Bloomberg自身の制限は引き続き適用されます: 日内ティック履歴は約140日まで遡れ、日次ボリューム上限は権限に紐づいています。

ユニバースをループするときは1つのセッションを再利用してください。名前ごとに接続ハンドシェイクを回避できます:

from findata.bloomberg import BloombergSession, get_bloomberg_ticks

with BloombergSession() as bbg:
    frames = {
        sym: get_bloomberg_ticks(sym, start, end, session=bbg)
        for sym in universe
    }

ティックをローカルで任意のpandasオフセットでバーに集約:

from findata.bloomberg import ticks_to_bars

bars = ticks_to_bars(ticks, rule="5min")
# columns: open, high, low, close, ticks, volume, vwap

get_bloomberg_bars

from findata.bloomberg import get_bloomberg_bars

# 5-minute bars, aggregated server-side (much lighter than raw ticks)
bars = get_bloomberg_bars(
    "AAPL US Equity",
    "2024-06-03 09:30:00",
    "2024-06-03 16:00:00",
    interval=5,                 # minutes, 1-1440
    tz="America/New_York",
)
# columns: security, open, high, low, close, volume, numEvents, value

get_bloomberg_data

from findata.bloomberg import get_bloomberg_data

# Historical daily series -> MultiIndex columns (field, security)
df = get_bloomberg_data(
    tickers=["AAPL US Equity", "MSFT US Equity"],
    fields=["PX_LAST", "VOLUME"],
    start_date="2024-01-01",
    end_date="2024-12-31",
)
close = df["PX_LAST"]

# Reference data -> rows=securities, cols=fields
ref = get_bloomberg_data(
    tickers=["AAPL US Equity"],
    fields=["CUR_MKT_CAP", "GICS_SECTOR_NAME"],
    request_type="ReferenceDataRequest",
    overrides={"BEST_FPERIOD_OVERRIDE": "1BF"},
)

get_file_data

from findata.file_reader import get_file_data

df = get_file_data("data/prices.parquet", tickers=["AAPL"], start_date="2023-01-01", end_date="2023-12-31")

テスト

pytest tests/ -v

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A specialized MCP server that provides institutional-grade financial data and market research via the Finnhub API. It enables AI agents to function as equity researchers, generating professional market reports and high-fidelity analysis for stock tickers.
      ISC
    • A
      license
      A
      quality
      D
      maintenance
      FinData MCP gives AI agents access to market data, company fundamentals, and macroeconomic indicators via MCP. It covers stocks, ETFs, crypto, forex, commodities, and economic time series.
      5
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that provides AI agents with financial tools including real-time quotes, backtesting, technical analysis, and multi-exchange data via a simple CLI interface.
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI agents to query real-time financial data including stock quotes, market indices, company fundamentals, and portfolio tracking.
      MIT