🚀 OpenDart MCP サーバー
OpenDartのクローリングとキャッシュを行うMCPサーバーです。
株式情報をOpenDartから銘柄の基本情報(ファンダメンタル)を取得します。
モデルコンテキストプロトコル(Model Context Protocol, MCP)サーバーを構築し、配布します。
MCPサーバーはLLMに外部ツールやサービスへのアクセス権を提供します。
FastMCPを使用することで、MCPサーバーとクライアントを迅速かつPythonicな方法で構築できます。
- Gemini 3.0 Pro
- Gemini 3.0 Flash
参考ドキュメント
✨ 主な機能
- 株式情報を
OpenDartから取得する。
- MCPサーバーを構築し、LLMに外部ツールやサービスへのアクセス権を提供する。
- FastMCPを使用して、MCPサーバーとクライアントを迅速かつPythonicな方法で構築する。
📦 インストール
パッケージ構造
├── opendart/
│ ├── __init__.py # 公開APIの定義
│ ├── client.py # OpenDART HTTPクライアント
│ ├── models.py # データクラス (DTO)
│ ├── utils.py # ユーティリティ関数 & 定数
│ ├── crawler.py # 統合インターフェース (Facade)
│ ├── examples.py # 使用例
│ └── parsers/
│ ├── __init__.py
│ ├── document.py # 文書APIパーサー
│ ├── document_viewer.py # 文書ビューアーAPIパーサー
│ ├── disclosure.py # 公開情報APIパーサー
│ ├── finance.py # 定期報告書財務情報APIパーサー
│ ├── material_facts.py # 主要事項報告書主要情報APIパーサー
│ ├── ownership.py # 持分公開総合情報APIパーサー
│ ├── registration.py # 証券申告書主要情報APIパーサー
│ └── reports.py # 定期報告書主要情報APIパーサー
├── tests/
│ ├── test_opendart.py # OpenDARTテスト (ローカルソース)
│ └── test_opendart_.py # OpenDARTテスト (sayou-stock)
├── __init__.py
├── .gitignore
├── Dockerfile
├── LICENSE
├── opendarts.py
├── pyproject.toml
├── README.md
├── requirements.txt
└── server.py
配布 (Cloud Run)
MCP_SERVER_NAME=opendart-mcp-server
export GOOGLE_CLOUD_PROJECT=sayouzone-ai
GCP設定 (1回のみ)
サービスの有効化
gcloud services enable \
run.googleapis.com \
artifactregistry.googleapis.com \
cloudbuild.googleapis.com
サービスアカウントの作成
gcloud iam service-accounts create mcp-server-sa --display-name="MCP Server Service Account"
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member=user:$(gcloud config get-value account) \
--role='roles/run.invoker'
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member=serviceAccount:mcp-server-sa@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com \
--role="roles/secretmanager.secretAccessor"
配布
パッケージソースでのテスト
gcloud run deploy $MCP_SERVER_NAME \
--service-account=mcp-server-sa@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com \
--no-allow-unauthenticated \
--region=us-central1 \
--source=. \
--labels=dev-tutorial=stocks-mcp
パッケージソースとアクセス権のテスト
gcloud run deploy $MCP_SERVER_NAME \
--region=us-central1 \
--source=. \
--labels=dev-tutorial=stocks-mcp
sayou-stockのインストールとテスト
gcloud run deploy $MCP_SERVER_NAME \
--service-account=mcp-server-sa@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com \
--no-allow-unauthenticated \
--region=us-central1 \
--source=. \
--labels=dev-tutorial=stocks-mcp
sayou-stockのインストールとアクセス権のテスト
gcloud run deploy $MCP_SERVER_NAME \
--region=us-central1 \
--source=. \
--labels=dev-tutorial=stocks-mcp
💻 使用例
基本的な使用法
export PROJECT_NUMBER=$(gcloud projects describe $GOOGLE_CLOUD_PROJECT --format="value(projectNumber)")
export ID_TOKEN=$(gcloud auth print-identity-token)
settings.json
{
"ide": {
"hasSeenNudge": true
},
"mcpServers": {
"opendart-remote": {
"httpUrl": "https://opendart-mcp-server-$PROJECT_NUMBER.us-central1.run.app/mcp",
"headers": {
"Authorization": "Bearer $ID_TOKEN"
}
}
},
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}
settings.jsonファイルを~/.gemini/ディレクトリにコピーします。
cp settings.json ~/.gemini/
gemini
- 三星電子
- 三星電子の財務諸表を表示して
- 三星電子の財務状況を表示して
- 三星電子の財務諸表を表示して
- 2024年の三星電子の財務諸表を表示して
- 2025年第3四半期の三星電子の財務諸表を表示して
- 三星電子の配当情報を表示して
- 三星電子の配当について教えて
- 三星電子の配当はどうなっているの?
- 2025年の三星電子の配当はどうなっているの?
- 三星電子の最近の配当傾向について教えて
- 三星電子が支払う報酬について教えて
Loaded cached credentials.
███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████
░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███
░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███
░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███
███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███
███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███
███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████
░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
Tips for getting started:
1. Ask questions, edit files, or run commands.
2. Be specific for the best results.
3. Create GEMINI.md files to customize your interactions with Gemini.
4. /help for more information.
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Gemini CLI update available! 0.14.0 → 0.15.0 │
│ Installed via Homebrew. Please update with "brew upgrade". │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
⠋ Connecting to MCP servers... (1/2)
Using: 2 MCP servers
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Type your message or @path/to/file │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
~/.../src/sayou/mcp/stocks_mcp (main*) no sandbox (see /docs) auto
sayou-stockの配布
git push origin main
git tag sayou-stock-v0.1.1
git push origin sayou-stock-v0.1.1
🔧 エラー
> /mcp
Configured MCP servers:
🟢 stocks-remote - Ready (4 tools)
Tools:
- find_fnguide_data
- find_yahoofinance_data
- get_yahoofinance_fundamentals
- save_fundamentals_data_to_gcs
🟢 zoo-remote - Ready (2 tools, 1 prompt)
Tools:
- get_animal_details
- get_animals_by_species
Prompts:
- find
ℹ Gemini CLI update available! 0.14.0 → 0.15.0
Installed via Homebrew. Please update with "brew upgrade".
Using: 2 MCP servers
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Type your message or @path/to/file │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
~/.../src/sayou/mcp/stocks_mcp (main*) no sandbox (see /docs) auto
> 三星電子
ℹ Gemini CLI update available! 0.14.0 → 0.15.0
Installed via Homebrew. Please update with "brew upgrade".
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ x find_fnguide_data (stocks-remote MCP Server) {"stock":"三星電子"} │
│ │
│ MCP tool 'find_fnguide_data' reported tool error for function call: {"name":"find_fnguide_data","args":{"stock":"三星電子"}} with │
│ response: [{"functionResponse":{"name":"find_fnguide_data","response":{"error":{"content":[{"type":"text","text":"Error calling tool │
│ 'find_fnguide_data': BrowserType.launch: Executable doesn't exist at │
│ /root/.cache/ms-playwright/chromium_headless_shell-1194/chrome-linux/headless_shell\n╔══════════════════════════════════════════════════ │
│ ══════════╗\n║ Looks like Playwright was just installed or updated. ║\n║ Please run the following command to download new │
│ browsers: ║\n║ ║\n║ playwright install │
│ ║\n║ ║\n║ <3 Playwright Team │
│ ║\n╚════════════════════════════════════════════════════════════╝"}],"isError":true}}}}] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ - Shell playwright install [current working directory /Users/seongjungkim/Development/sayouzone/base-framework/src/sayou/mcp/stocks_mcp] … │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
📚 ドキュメント