Skip to main content

A Model Context Protocol server for Financial Analysis

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

myshare_mcp-0.1.10.tar.gz (104.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

myshare_mcp-0.1.10-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file myshare_mcp-0.1.10.tar.gz.

File metadata

  • Download URL: myshare_mcp-0.1.10.tar.gz
  • Upload date:
  • Size: 104.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for myshare_mcp-0.1.10.tar.gz
Algorithm Hash digest
SHA256 3152df0c45c9783e3c6c1fc6ac2bf58e9e2a0bfd8e269774ef164675e70753de
MD5 0f0b6b64b5b4f53297de7f1325faab62
BLAKE2b-256 f9a66c7ed8f38165ee3444bb96ac8adc6c5fb52ef1ae0dba248d6eecec22c1e9

See more details on using hashes here.

File details

Details for the file myshare_mcp-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for myshare_mcp-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d2096c8b61d24506feffe40001958224997d2a8a8708c875df9142b0de025577
MD5 b0640c84aa13f4f4b4e71669392f7aec
BLAKE2b-256 cb8adb3f3594e12bf9e3112314270df4cf408d19b3c8fedc7a86b35f7ba97f71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page