tddt stock info mcp

tddt stock info mcp avatar

by tddt

获取股票各类信息

What is tddt stock info mcp

Stock Info Service

这是一个基于 FastMCP 的股票数据服务,提供了股票历史数据、基本面信息、新闻资讯等功能。

项目结构

stock-info/
├── src/
│   ├── config/           # 配置管理
│   │   └── settings.py
│   ├── core/            # 核心功能
│   │   └── exceptions.py
│   ├── models/          # 数据模型
│   │   └── stock.py
│   ├── repository/      # 数据访问层
│   │   └── stock_repository.py
│   ├── service/         # 业务逻辑层
│   │   └── stock_service.py
│   └── server.py        # 服务入口
├── pyproject.toml       # 项目配置
└── README.md           # 项目文档

功能特性

  • 获取股票历史数据
  • 查询股票基本信息
  • 获取风险警示股票列表
  • 查看个股新闻
  • 获取财经新闻(支持分页)
  • 获取股票主营业务信息
  • .....后续逐渐增加

MCP客户端配置步骤

    1. 拉取代码
    1. 使用uv建立虚拟环境 python 1.10+
    1. 使用本地目录方式配置MCP服务
{
  "mcpServers": {
     "stock-info": {
      "isActive": true,
      "command": "uv",
      "args": [
        "--directory",
        "\\path\\to\\sock_info\\src",
        "run",
        "server.py"
      ]
    }
  }

环境要求

  • Python >= 3.10
  • 依赖包:
    • fastmcp
    • akshare
    • pandas
    • pydantic
    • pydantic-settings

安装部署

  1. 创建虚拟环境:
python -m venv .venv
  1. 激活虚拟环境:
# Windows
.venv\Scripts\activate
# Linux/macOS
source .venv`/bin/activate`
  1. 安装依赖:
pip install -e .

启动服务

# 使用默认配置启动
python src/server.py

# 使用 HTTP 传输协议启动
python src/server.py --transport http --port 8080

# 设置日志级别
python src/server.py --log-level debug

工具说明

  1. get_stock_info: 获取指定股票代码、指定日期范围的股价信息
  2. get_stock_price_monthly: 获取指定股票最近30天的股价信息
  3. stock_individual_basic_info: 获取指定股票的基本信息
  4. risk_stocks: 获取风险警示板股票列表
  5. stock_merito_data: 获取指定股票的主营业务信息
  6. get_stock_news: 获取指定股票的新闻资讯
  7. get_finance_news: 获取财经精选新闻(支持分页)

项目特点

  1. 模块化设计:采用清晰的分层架构,便于维护和扩展
  2. 统一异常处理:使用自定义异常体系,提供友好的错误提示
  3. 配置集中管理:使用 pydantic-settings 进行配置管理
  4. 类型提示:全面使用 Python 类型注解,提高代码可读性
  5. 数据验证:使用 Pydantic 模型进行数据验证和序列化

开发规范

  1. 使用 ruff 进行代码格式化和 lint
  2. 遵循 PEP 8 编码规范
  3. 保持完整的类型注解
  4. 编写清晰的文档字符串

错误处理

服务统一返回以下格式的错误信息:

{
    "error": "错误代码",
    "message": "错误描述",
    "details": {
        "额外信息": "值"
    }
}

主要错误代码

  • STOCK_NOT_FOUND: 股票代码不存在
  • INVALID_DATE_FORMAT: 日期格式错误
  • DATA_FETCH_ERROR: 数据获取失败
  • INVALID_PAGINATION: 分页参数错误
  • SYSTEM_ERROR: 系统内部错误

Leave a Comment

Frequently Asked Questions

What is MCP?

MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.

What are MCP Servers?

MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.

How do MCP Servers work?

MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.

Are MCP Servers secure?

Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.

Related MCP Servers

chrisdoc hevy mcp avatar

chrisdoc hevy mcp

mcp
sylphlab pdf reader mcp avatar

sylphlab pdf reader mcp

An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.

pdf-parsetypescriptnodejs
aashari mcp server atlassian bitbucket avatar

aashari mcp server atlassian bitbucket

Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.

atlassianrepositorymcp
aashari mcp server atlassian confluence avatar

aashari mcp server atlassian confluence

Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.

atlassianmcpconfluence
prisma prisma avatar

prisma prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

cockroachdbgomcp
Zzzccs123 mcp sentry avatar

Zzzccs123 mcp sentry

mcp sentry for typescript sdk

mcptypescript
zhuzhoulin dify mcp server avatar

zhuzhoulin dify mcp server

mcp
zhongmingyuan mcp my mac avatar

zhongmingyuan mcp my mac

mcp
zhixiaoqiang desktop image manager mcp avatar

zhixiaoqiang desktop image manager mcp

MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)

mcp
zhixiaoqiang antd components mcp avatar

zhixiaoqiang antd components mcp

An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询

designantdapi

Submit Your MCP Server

Share your MCP server with the community

Submit Now