Skip to main content

stock-mcp

股票数据 MCP (Model Context Protocol) 服务,提供股票代码和日 K 线数据的查询功能。

功能特性

  • 股票基本信息查询
  • 按行业搜索股票
  • 股票日 K 线数据查询
  • 股票代码列表获取
  • 基于 HTTP 的 MCP 服务接口
  • 简单易用的 Python 客户端

快速开始

安装

pip install stock-mcp

启动服务器

# 使用默认配置启动
stock-mcp-server

# 自定义配置启动
stock-mcp-server --port 30815 --host 42.51.40.70 --user xx --password xxx --db xx --db-port 3306

使用客户端

from stock_mcp import StockMCPClient

# 初始化客户端
client = StockMCPClient(
    host="42.51.40.70",
    port=30815,
    username="user001",
    token="token"  # 替换为实际生成的Token
)

# 纯业务调用(无任何冗余)
stock_info = client.get_stock_info("SZ300750")
print("宁德时代信息:", stock_info)

命令行客户端

# 获取股票信息
stock-mcp-client info --code SZ300750

# 获取日 K 线数据
stock-mcp-client kline --code SZ300750 --limit 10

# 健康检查
stock-mcp-client health

API 接口

健康检查

  • 端点: GET /health
  • 功能: 检查服务和数据库连接状态

工具列表

  • 端点: GET /tools
  • 功能: 获取所有可用工具的定义

工具调用

  • 端点: POST /invoke
  • 功能: 调用具体的工具执行操作
  • 请求格式:
    {
      "tool": "工具名称",
      "args": {
        "参数1": "值1",
        "参数2": "值2"
      }
    }
    

依赖项

  • Python 3.8+
  • PyMySQL 1.1.2+

许可证

MIT

Metadata

Release files for stock-mcp 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stock-mcp 1.0.10
File Size Uploaded Provenance
stock_mcp-1.0.10.tar.gz 13.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for stock-mcp 1.0.10
File Interpreter ABI Platform
stock_mcp-1.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / stock_mcp-1.0.10.tar.gz

Download URL stock_mcp-1.0.10.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
65b38eb549d10495f082e1e5ce53539fe93b7c0994e38a28f548bd20bb925154
BLAKE2b-256 checksum
How to use checksums
b2151651d0b03d12cd6b9e836911ccb97f29689d742db417854d55708ed0dfb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release files / stock_mcp-1.0.10-py3-none-any.whl

Download URL stock_mcp-1.0.10-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e72a8321a9e084b7dcc84a98a8032ed2e46e62a1f6701b18705dd2dc23045903
BLAKE2b-256 checksum
How to use checksums
42d0ebbb506078e2852ca8af4fa9b1b2b3670207f97856f7e9225201d76d5183
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Security for stock-mcp 1.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page