Stock Info (AKShare) MCP server

Provides real-time financial market data from Chinese and global markets through AKShare API integration for traders and financial analysts
Back to servers
Provider
tddt
Release date
Mar 30, 2025
Language
Python
Stats
4 stars

The Stock Info Service is a FastMCP-based service that provides comprehensive stock data including historical prices, fundamental information, and news updates. It offers multiple functionalities for accessing and analyzing stock market information through a simple API interface.

Installation Requirements

  • Python 3.10 or higher
  • Required packages:
    • fastmcp
    • akshare
    • pandas
    • pydantic
    • pydantic-settings

Installation Steps

1. Set Up Virtual Environment

Create and activate a Python virtual environment:

# Create virtual environment
python -m venv .venv

# Activate on Windows
.venv\Scripts\activate

# Activate on Linux/macOS
source .venv/bin/activate

2. Install Dependencies

Install the package in development mode:

pip install -e .

Server Configuration

Starting the Server

You can start the server with different configuration options:

# Start with default configuration
python src/server.py

# Start with HTTP transport protocol
python src/server.py --transport http --port 8080

# Set log level
python src/server.py --log-level debug

MCP Client Configuration

To set up the Stock Info Service as an MCP client:

  1. Clone the repository
  2. Create a virtual environment with Python 3.10+
  3. Configure the MCP service using the local directory:
{
  "mcpServers": {
     "stock-info": {
      "isActive": true,
      "command": "uv",
      "args": [
        "--directory",
        "\\path\\to\\sock_info\\src",
        "run",
        "server.py"
      ]
    }
  }
}

Available Tools

Stock Information Tools

  • get_stock_info: Retrieve stock price information for a specific stock code within a date range
  • get_stock_price_monthly: Get the last 30 days of price information for a specified stock
  • stock_individual_basic_info: Retrieve basic information for a specific stock
  • risk_stocks: Get a list of stocks with risk warnings
  • stock_merito_data: Retrieve main business information for a specific stock

News Tools

  • get_stock_news: Retrieve news related to a specific stock
  • get_finance_news: Get curated financial news (with pagination support)

Error Handling

The service returns error information in a standardized format:

{
    "error": "ERROR_CODE",
    "message": "Error description",
    "details": {
        "additional_info": "value"
    }
}

Common Error Codes

  • STOCK_NOT_FOUND: Stock code does not exist
  • INVALID_DATE_FORMAT: Date format error
  • DATA_FETCH_ERROR: Failed to fetch data
  • INVALID_PAGINATION: Pagination parameter error
  • SYSTEM_ERROR: Internal system error

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later