Sponsored by Deepsite.site

VNStock MCP Server

Created By
gahoccode9 months ago
MCP server for fetching historical stock prices using vnstock
Content

VNStock MCP Server

An MCP (Message Communication Protocol) server that fetches historical stock prices for multiple companies using the vnstock library. The server reads a configuration file and allows clients (e.g., Claude Desktop) to request stock data within a specific date range.

Features

  • Fetch historical stock data for multiple Vietnamese companies
  • Configure stocks to track via a JSON configuration file
  • Request stock data within a specific date range
  • MCP protocol support for integration with Claude Desktop
  • Direct API endpoint for stock data retrieval

Requirements

  • Python 3.10 or higher
  • vnstock 3.2.2
  • fastapi 0.115.12
  • uvicorn 0.34.0
  • pydantic 2.10.6
  • python-dotenv 1.0.1

Installation

# Create virtual environment
python -m venv venv

# Activate virtual environment (Windows)
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Using Poetry

# Install poetry if not already installed
pip install poetry

# Install dependencies
poetry install

Using UV

# Install uv if not already installed
pip install uv

# Install dependencies
uv pip install -r requirements.txt

Configuration

The application uses two separate configuration files:

1. Stock Configuration (stock_config.json)

This file contains the configuration for the stock data service, including which stocks to track and server settings:

{
  "stocks": [
    {
      "symbol": "VNM",
      "name": "Vietnam Dairy Products Joint Stock Company"
    },
    {
      "symbol": "VHM",
      "name": "Vinhomes Joint Stock Company"
    }
  ],
  "server": {
    "host": "0.0.0.0",
    "port": 8000
  },
  "default_days": 30,
  "max_days": 365
}

2. Claude Desktop Configuration (claude_desktop_config.json)

This file is used by Claude Desktop to register and communicate with the MCP server:

{
  "mcpServers": {
    "stock_prices": {
      "command": "python",
      "args": [
        "path/to/vnstock_mcp_server/main.py"
      ]
    }
  }
}

You should place this file in the Claude Desktop configuration directory, typically:

  • Windows: %APPDATA%\Claude Desktop\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude Desktop/claude_desktop_config.json
  • Linux: ~/.config/Claude Desktop/claude_desktop_config.json

Usage

Starting the Server

# Activate virtual environment (if using)
venv\Scripts\activate

# Start the server with default configuration
python main.py

# Start the server with custom configuration
python main.py --config path/to/config.json

# Override host and port
python main.py --host 127.0.0.1 --port 8080

API Endpoints

MCP Protocol Endpoints

  • GET /get-tools: Get available tools for the MCP protocol
  • POST /tool-call: Call a tool in the MCP protocol

Direct Endpoints

  • GET /: Health check endpoint
  • GET /stock-data: Get historical stock data for one or more symbols

Example Requests

Using the MCP Protocol

// POST /tool-call
{
  "tool": "vnstock",
  "method": "get_stock_data",
  "parameters": {
    "symbols": ["VNM", "VHM"],
    "start_date": "2023-01-01",
    "end_date": "2023-01-31"
  }
}

Using the Direct Endpoint

GET /stock-data?symbols=VNM&symbols=VHM&start_date=2023-01-01&end_date=2023-01-31

License

This project is licensed under the MIT License - see the LICENSE file for details.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
WindsurfThe new purpose-built IDE to harness magic
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
DeepChatYour AI Partner on Desktop