Skip to main content

MyShare MCP

Financial data analysis assistant based on AKShare with local SQLite caching.

Setup

  1. Create and activate virtual environment:

    uv add "mcp[cli]"
    uv init myshare-mcp
    cd myshare-mcp
    uv venv
    .venv/Scripts/activate  # Windows
    source .venv/bin/activate  # Linux/Mac
    
  2. Install dependencies:

    pip install -e .
    

API and MCP Endpoints

Testing MCP

To test mcp, please use the following command:

C:\>myshare-mcp>uv run mcp

 Usage: mcp [OPTIONS] COMMAND [ARGS]...

 MCP development tools

╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ version   Show the MCP version.                                                                                   │
│ dev       Run a MCP server with the MCP Inspector.                                                                │
│ run       Run a MCP server.                                                                                       │
│ install   Install a MCP server in the Claude desktop app.                                                         │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

To debug using MCP inspector:

C:\>myshare-mcp>uv run mcp dev main.py
Starting MCP inspector...
⚙️ Proxy server listening on port 6277
New SSE connection
Query parameters: [Object: null prototype] {
  transportType: 'stdio',
  command: 'uv',
  args: 'run --with mcp mcp run main.py',
...

Testing FastAPI

C:\>myshare-mcp>uv run main.py

API implementation

1. Real-time Stock Data

GET /spot/{symbol}

Gets real-time stock data for a given symbol (e.g., "SH600000").

Example response:

{
    "symbol": "SH600000",
    "name": "浦发银行",
    "current_price": 7.21,
    "open_price": 7.19,
    "high_price": 7.25,
    "low_price": 7.18,
    "pe_ratio": 4.85,
    "pb_ratio": 0.41,
    "market_cap": 211731000000,
    "timestamp": "2025-04-26T10:30:00",
    "source": "akshare"
}

2. Historical Stock Data

GET /history/{symbol}?start_date={YYYYMMDD}&end_date={YYYYMMDD}&period={daily|weekly|monthly}&adjust={qfq|hfq}

Gets historical stock data for a given symbol and date range.

Parameters:

  • start_date: Start date in YYYYMMDD format
  • end_date: End date in YYYYMMDD format
  • period: Data frequency (daily, weekly, monthly)
  • adjust: Price adjustment (qfq for forward-adjusted, hfq for backward-adjusted)

Example response:

[
    {
        "date": "2025-04-26T00:00:00",
        "open": 7.19,
        "close": 7.21,
        "high": 7.25,
        "low": 7.18,
        "volume": 123456,
        "source": "akshare"
    }
]

Caching

All data is automatically cached in a local SQLite database (finance.db). The cache is checked before making requests to AKShare.

Symbol

The following table is the format of stock symbol for different markets. Please refer to symbol.md.

Database

We can use sqlite_web to navigate the database.

coleifer/sqlite-web: Web-based SQLite database browser written in Python

sqlite_web .\finance.db

Metadata

Release files for myshare_mcp 0.1.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 myshare_mcp 0.1.10
File Size Uploaded
myshare_mcp-0.1.10.tar.gz 104.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for myshare_mcp 0.1.10
File Interpreter ABI Platform
myshare_mcp-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 115.1 kB

Release files / myshare_mcp-0.1.10.tar.gz

Download URL myshare_mcp-0.1.10.tar.gz
Size 104.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3152df0c45c9783e3c6c1fc6ac2bf58e9e2a0bfd8e269774ef164675e70753de
BLAKE2b-256 checksum
How to use checksums
f9a66c7ed8f38165ee3444bb96ac8adc6c5fb52ef1ae0dba248d6eecec22c1e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Release files / myshare_mcp-0.1.10-py3-none-any.whl

Download URL myshare_mcp-0.1.10-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2096c8b61d24506feffe40001958224997d2a8a8708c875df9142b0de025577
BLAKE2b-256 checksum
How to use checksums
cb8adb3f3594e12bf9e3112314270df4cf408d19b3c8fedc7a86b35f7ba97f71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

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