金融市场数据服务

Finnhub MCP Server是一个封装Finnhub API的模型上下文协议服务器,提供金融市场数据服务,包括收益日历等功能,适用于金融分析和投资决策。

  • by ach968
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 ach968/finnhub-mcp

使用说明

Finnhub MCP服务器

模型上下文协议(MCP)服务器封装了 芬兰API 金融市场数据。

特性

  • 收益日历:获取即将发布的和历史的收益公告,包括每股收益估计、实际值和收入数据
  • API密钥验证:通过CLI或环境变量进行简单的基于API密钥的身份验证
  • 类型安全:通过Zod验证完全支持TypeScript
  • Bun原住民:针对Bun运行时进行了优化

安装

在GitHub上使用npx(推荐)

直接从GitHub运行,无需克隆或安装:

npx github:ach968/finnhub-mcp --api-key YOUR_FINNHUB_API_KEY

本地开发

# Clone the repository
git clone https://github.com/ach968/finnhub-mcp.git
cd finnhub-mcp

# Install dependencies
bun install

# Run in development mode
bun run dev -- --api-key YOUR_FINNHUB_API_KEY

OpenCode配置

添加到您的OpenCode配置(~/.config/opencode/opencode.json):

在GitHub上使用npx

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "finnhub": {
      "type": "local",
      "command": [
        "npx",
        "github:ach968/finnhub-mcp",
        "--api-key",
        "YOUR_FINNHUB_API_KEY"
      ],
      "enabled": true
    }
  }
}

使用环境变量

{
  "mcp": {
    "finnhub": {
      "type": "local",
      "command": [
        "npx",
        "github:ach968/finnhub-mcp"
      ],
      "environment": {
        "FINNHUB_API_KEY": "YOUR_API_KEY"
      },
      "enabled": true
    }
  }
}

可用工具

finnhub.calendar.earnings

获取某个日期范围的收益日历。

参数:

  • from (可选):开始日期 YYYY-MM-DD 格式(默认为今天)
  • to (可选):结束日期 YYYY-MM-DD 格式(默认为从开始算起7天)
  • symbol (可选):按股票代码过滤(例如“AAPL”)

示例响应:

{
  "data": [
    {
      "date": "2024-01-25",
      "symbol": "AAPL",
      "quarter": "Q1",
      "fiscalYear": 2024,
      "time": "amc",
      "eps": {
        "estimate": 2.11,
        "actual": 2.18,
        "surprise": 0.07,
        "surprisePercent": 3.32
      },
      "revenue": {
        "estimate": 117900000000,
        "actual": 119580000000,
        "surprise": 1680000000,
        "surprisePercent": 1.42
      }
    }
  ],
  "count": 1,
  "dateRange": {
    "from": "2024-01-25",
    "to": "2024-01-25"
  }
}

时间值:

  • bmo:开市前
  • amc:市场收盘后
  • dmh:市场营业时间

CLI参数

参数 环境变量 描述
--api-key FINNHUB_API_KEY Finnhub API密钥(必需)

CLI参数优先于环境变量。

发展

脚本

# Development with hot reload
bun run dev

# Build for production
bun run build

# Type checking
bun run typecheck

# Run the built version
bun run start -- --api-key YOUR_KEY

项目结构

src/
├── index.ts           # Main MCP server entry point
├── finnhub-client.ts  # Finnhub API client
└── types.ts           # TypeScript types and Zod schemas

API密钥

从获取您的免费API密钥 Finnhub.

许可证

麻省理工学院

免责声明

该项目使用 芬兰API 但与Finnhub没有任何关联、背书或联系。使用此软件的风险由您自行承担。