Token导航 LogoToken导航TokenDH.com
Finbert MCP Server Prod logo
金融服务stdio官方级别未说明来源级核验

Finbert MCP Server Prod

MCP Server

一个轻量级的MCP服务器,提供FinBERT模型用于金融文本的情感分析,支持批量处理和异步操作。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
批量处理Python金融数据

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Traia-IO

提供方

Traia-IO

最后核验

2026/5/17 20:23

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run python -m server

详细介绍

FinBERT MCP服务器

这是一个轻量级的MCP(模型上下文协议)服务器,提供对FinBERT模型的访问,用于金融情绪分析。它使AI代理和LLM能够使用专门的BERT模型分析财务文本,该模型对财务数据进行了微调,并针对生产使用进行了优化。

特性

  • 🔧 MCP协议:基于模型上下文协议构建,实现无缝的人工智能集成
  • 🤖 轻量级FinBERT模型:专注于情绪分析以获得最佳性能
  • 🚀 懒加载:模型按需加载,以实现高效的内存使用
  • 📊 批处理:通过批量情感操作高效分析多个文本
  • 🐳 Docker支持:使用Docker和Docker Compose轻松部署
  • 异步操作:内置FastMCP,实现高效异步处理
  • 🎯 生产就绪:针对生产环境进行了优化,资源使用率最低

模型信息

此服务器提供对轻量级FinBERT模型的访问:

  • 进程AI/finbert:用于金融情绪分析的原始FinBERT模型-针对生产用途进行了优化

可用工具

此轻量级服务器提供以下工具:

1. finbert_sentiment_analysis

使用FinBERT模型分析金融文本的情绪。

参数:

  • text (string):用于分析情绪的金融文本

退货:

  • sentiment:预测情绪(积极、消极、中性)
  • confidence:置信度得分(0-1)
  • all_scores:所有带有分数的情绪预测数组
  • model_used:用于分析的模型名称
  • timestamp:分析时间戳

2. analyze_financial_text_batch

批量分析多个财务文本,提高情绪分析效率。

参数:

  • texts (array):要分析的财务文本列表(最多50个)
  • analysis_type (string):分析类型(仅支持“情绪”)

退货:

  • results:每个文本的情绪分析结果数组
  • analysis_type:分析类型(“情绪”)
  • model_used:用于分析的模型名称
  • total_texts:处理的文本数量

3. get_finbert_model_info

获取有关FinBERT模型及其当前状态的信息。

退货:

  • models:有关可用型号的信息
  • supported_operations:可用工具列表
  • limitations:型号限制(文本长度、批量大小)
  • documentation:相关文件的链接

安装

使用Docker(推荐)

  1. 克隆此存储库:
   git clone https://github.com/Traia-IO/finbert-mcp-server.git
   cd finbert-mcp-server
  1. 使用Docker运行:
   ./run_local_docker.sh

使用Docker Compose

  1. 创建一个 .env 使用您的配置文件:
   PORT=8000
   LOG_LEVEL=INFO
  1. 启动服务器:
   docker-compose up

手动安装

  1. 使用安装依赖项 uv:
   uv pip install -e .
  1. 运行服务器:
   uv run python -m server

用法

健康检查

测试服务器是否正在运行:

python mcp_health_check.py

使用CrewAI

from traia_iatp.mcp.traia_mcp_adapter import create_mcp_adapter

# Connect to the MCP server
with create_mcp_adapter(
    url="http://localhost:8000/mcp/"
) as tools:
    # Use the tools
    for tool in tools:
        print(f"Available tool: {tool.name}")
        
    # Example: Analyze sentiment of financial text
    result = await tool.finbert_sentiment_analysis(
        text="The company reported strong quarterly earnings, exceeding expectations."
    )
    print(f"Sentiment: {result['sentiment']}, Confidence: {result['confidence']}")
    
    # Example: Batch sentiment analysis
    texts = [
        "Revenue growth exceeded forecasts this quarter.",
        "The company faces regulatory challenges ahead.",
        "Investment in new technology platforms shows promise."
    ]
    result = await tool.analyze_financial_text_batch(
        texts=texts,
        analysis_type="sentiment"
    )
    print(f"Batch sentiment analysis completed for {result['total_texts']} texts")
    
    # Example: Get model information
    result = await tool.get_finbert_model_info()
    print(f"Available models: {list(result['models'].keys())}")

示例响应

情感分析

{
  "status": "success",
  "sentiment": "positive",
  "confidence": 0.8945,
  "all_scores": [
    {"label": "positive", "score": 0.8945},
    {"label": "neutral", "score": 0.0892},
    {"label": "negative", "score": 0.0163}
  ],
  "text_length": 67,
  "model_used": "ProsusAI/finbert",
  "timestamp": "2024-01-15T10:30:00Z"
}

批次分析

{
  "status": "success",
  "analysis_type": "sentiment",
  "model_used": "ProsusAI/finbert",
  "total_texts": 3,
  "results": [
    {
      "index": 0,
      "text": "Revenue growth exceeded forecasts this quarter.",
      "prediction": "positive",
      "confidence": 0.9234,
      "all_scores": [...]
    },
    // ... more results
  ],
  "timestamp": "2024-01-15T10:30:00Z"
}

发展

测试服务器

  1. 在本地启动服务器
  2. 运行健康检查: python mcp_health_check.py
  3. 使用CrewAI适配器测试单个工具

模型加载

模型在首次使用时延迟加载,并缓存以备后续请求。服务器在启动后启动一个后台线程来预加载模型,以获得更好的性能。

添加新工具

要添加新工具,请编辑 server.py 以及:

  1. 如果需要,创建新的模型初始化函数
  2. 添加 @mcp.tool() 装饰功能
  3. 使用新工具更新此README
  4. 更新 deployment_params.json 工具名称位于功能数组中

部署

部署配置

deployment_params.json 文件包含此MCP服务器的部署配置:

{
  "github_url": "https://github.com/Traia-IO/finbert-mcp-server",
  "mcp_server": {
    "name": "finbert-mcp",
    "description": "Lightweight pre-trained BERT-based model fine‑tuned on financial text for sentiment analysis (positive/negative/neutral), optimized for production use.",
    "server_type": "streamable-http",
    "requires_api_key": false,
    "capabilities": [
      "finbert_sentiment_analysis",
      "analyze_financial_text_batch",
      "get_finbert_model_info"
    ]
  },
  "deployment_method": "cloud_run",
  "gcp_project_id": "traia-mcp-servers",
  "gcp_region": "us-central1",
  "tags": ["finbert", "financial", "sentiment", "analysis", "bert", "nlp", "ai", "text-processing", "lightweight", "production-ready"],
  "ref": "main"
}

重要:始终更新 capabilities 添加或删除工具时使用数组!

谷歌云运行

此服务器旨在部署在Google Cloud Run上。部署将:

  1. 从Dockerfile构建一个容器
  2. 使用指定配置部署到Cloud Run
  3. 暴露 /mcp 客户端连接的端点

环境变量

  • PORT:服务器端口(默认值:8000)
  • STAGE:环境阶段(默认:MAINNET,选项:MAINNET、TESTNET)
  • LOG_LEVEL:日志记录级别(默认值:INFO)

型号规格

文本限制

  • 最大文本长度:512个字符(文本会自动截断)
  • 批量大小限制:每批请求50条文本
  • 支持的语言:仅限英语

演出

  • 模型按需加载(延迟加载)
  • 后台预加载以获得更好的性能
  • 为后续请求缓存模型
  • 高效的批处理

故障排除

  1. 服务器未启动:使用以下命令检查Docker日志 docker logs
  2. 连接错误:确保服务器在预期端口上运行
  3. 工具错误:检查服务器日志以获取详细的错误消息
  4. 模型加载问题:确保有足够的内存和磁盘空间用于模型下载
  5. CUDA错误:GPU支持是可选的;如果CUDA不可用,模型将在CPU上运行

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 实施新工具或改进
  4. 更新README和deployment_params.json
  5. 提交拉取请求

许可证

MIT许可证

目录标签

目录标签

批量处理Python金融数据金融情感分析本地部署BERT模型轻量级服务器异步操作

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP