使用说明
彭博MCP服务器
FastMCP使用Bloomberg API市场数据获取服务器。
🚀 服务器启动方式
方法1:stdio (建议-进程间通信
# デフォルト - Claude Desktop等での標準的な使用方法
python server.py
# または明示的にstdio指定
python server_http.py --stdio
- 无需主机端口
- Claude Desktop设定例 (
claude_desktop_config.json):
{
"mcpServers": {
"bloomberg-server": {
"command": "python",
"args": ["/path/to/your/server.py"],
"env": {
"PYTHONPATH": "/path/to/your/project"
}
}
}
}
方法2:HTTP/SSE - 通过网络
# HTTPサーバーとして起動 (デフォルト: localhost:8080)
python server_http.py
# カスタムホスト・ポート指定
python server_http.py --host 0.0.0.0 --port 3000
- 访问权限URL:
http://localhost:8080/sse - 其他计算机也可访问
- Web UI适用于或自定义客户端
📊 机能
市场数据获取工具
- 搜索_安全 -证券检索(从公司名称、提克等中检索候补)
- 搜索字段 -字段搜索(可用)Bloomberg查找字段)
- 获取引用数据 -获取当前市场数据(相当于BDP功能)
- 获取历史数据 -获取历史数据(相当于BDH功能)
- get_bulk_data -批量数据获取(相当于BDS功能)
使用例
# 証券検索
search_securities("Apple", max_results=10)
# フィールド検索
search_fields("price", max_results=20)
# 現在の株価取得
get_reference_data("AAPL US Equity", ["PX_LAST", "VOLUME"])
# 過去データ取得
get_historical_data(
"AAPL US Equity",
["PX_LAST", "PX_VOLUME"],
"2024-01-01",
"2024-12-31"
)
# インデックス構成銘柄取得
get_bulk_data("SPX Index", "INDX_MEMBERS")
🔧 安装,安装
前提条件
- Bloomberg Terminal合同和登录
- Bloomberg Desktop API访问权限
- Python 3.8以上
1.安装相关性
# pip使用の場合
pip install -r requirements.txt
# uv使用の場合(推奨)
uv sync
2. Bloomberg Terminal启动
Bloomberg Terminal在工作空间的边缘API将条目添加到文档注册表。
3.服务器启动
# stdio方式(Claude Desktop用)
python server.py
# HTTP方式(Web UI等用)
python server_http.py --host 0.0.0.0 --port 8080
🌐 网络连接详细信息
stdio方式的结构
[Claude Desktop] ←→ [MCPサーバープロセス]
↑ ↓
JSON-RPC Bloomberg API
(stdin/stdout) (localhost:8194)
HTTP/SSE方式的结构
[Webクライアント] ←→ [HTTPサーバー:8080] ←→ [Bloomberg API]
↑ ↓ ↓
HTTP/SSE FastMCP localhost:8194
📡 Bloomberg API接続
服务器使用以下服务:
- 彭博终端:
localhost:8194(桌面API) - //blp/refdata -参考数据服务(价格、卷等)
- //blp/apiflds -字段搜索服务
🔍 常用字段
PX_LAST-最终似格PX_VOLUME- 出来高SECURITY_NAME-证券名GICS_SECTOR_NAME- GICS 部门MARKET_CAP-时似総額DVD_HIST_ALL- 配当履歴INDX_MEMBERS-索引配置品牌
📈 证券代码格式
- 株式:
AAPL US Equity - 索引:
SPX Index - 债券:
T 4.75 05/15/25 Govt - 通货:
USDJPY Curncy - 公用:
CL1 Comdty
🛠 故障排除
连接错误
# Bloomberg Terminal起動確認
# Windows: Ctrl+Alt+T でターミナル起動
# Bloomberg API状態確認: API <GO>
端口冲突(HTTP方式)
# 別ポートで起動
python server_http.py --port 3001
# プロセス確認
netstat -an | grep :8080
调试模式
# 詳細ログ出力
python server.py --debug
# 接続テスト
python examples.py
🎯 使用方法
Claude Desktop统合
claude_desktop_config.json添加服务器设置- Claude Desktop再起动
- 聊天请求市场数据分析
定制客户端开发
import requests
# HTTP API呼び出し例
response = requests.post(
"http://localhost:8080/mcp",
json={
"method": "tools/call",
"params": {
"name": "get_reference_data",
"arguments": {
"securities": "AAPL US Equity",
"fields": "PX_LAST"
}
}
}
)
📄 许可证
此项目设想为个人使用。Bloomberg API的规格化距离的幂函数。
🔗 相关文件
server.py- stdio版主服务器server_http.py- HTTP/SSE版本服务器utils.py-实用程序函数examples.py-示例演示