### Docker Test vnstock3 Installation and Data Fetching Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md Bash commands to test the vnstock3 library installation within a running Docker container and to fetch historical stock data. ```bash # Test vnstock3 installation in container docker run -it vnprices-mcp:latest python3 -c "from vnstock import Quote; print('OK')" # Test data fetching docker run -it vnprices-mcp:latest python3 -c "from vnstock import Quote; q = Quote('VCI'); print(q.history('2024-01-01', '2024-12-31'))" ``` -------------------------------- ### Build and Test Docker Image Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Instructions for building the Docker image for the vnprices-mcp server, verifying the build, and testing the vnstock3 installation and data fetching capabilities within the container. ```bash # Build the Docker image docker build --no-cache -t vnprices-mcp:latest . # Verify build docker images | grep vnprices-mcp # Test vnstock3 installation in container docker run -it vnprices-mcp:latest python3 -c "from vnstock import Quote; print('OK')" # Test data fetching docker run -it vnprices-mcp:latest python3 -c "from vnstock import Quote; q = Quote('VCI'); print(q.history('2024-01-01', '2024-12-31'))" ``` -------------------------------- ### Install Build Dependencies for Wordcloud in Dockerfile Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Dockerfile snippet showing the installation of essential build dependencies required for the `wordcloud` Python package. This includes compilers, development headers for FreeType and PNG, and other build tools. ```dockerfile RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ g++ \ build-essential \ python3-dev \ libfreetype6-dev \ libpng-dev \ libjpeg-dev \ pkg-config \ && rm -rf /var/lib/apt/lists/* ``` -------------------------------- ### Docker Build Configuration (Dockerfile) Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Defines a multi-stage Docker build process for containerizing the vnstock3 application and its image processing dependencies. It installs necessary system and Python packages. ```dockerfile # Use Python 3.11 slim image FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies needed for wordcloud and vnstock3 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ g++ \ build-essential \ python3-dev \ libfreetype6-dev \ libpng-dev \ libjpeg-dev \ pkg-config \ && rm -rf /var/lib/apt/lists/* # Upgrade pip, setuptools, and wheel RUN pip install --upgrade pip setuptools wheel # Copy requirements COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt ``` -------------------------------- ### Manually Run Docker MCP Gateway Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md A Docker run command to manually start the `mcp-gateway`. This command mounts necessary volumes and configures the gateway to run with specific catalog, registry, and configuration files. Useful for testing the gateway in isolation. ```bash docker run -i --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.docker/mcp:/mcp \ docker/mcp-gateway \ --catalog=/mcp/catalogs/custom.yaml \ --registry=/mcp/registry.yaml \ --config=/mcp/config.yaml \ --verbose ``` -------------------------------- ### Get Crypto History Source: https://github.com/gahoccode/vnprices-mcp/blob/main/llms.txt Fetches historical cryptocurrency price data. Supports daily, weekly, and monthly intervals. ```APIDOC ## GET /api/crypto/history ### Description Fetches historical cryptocurrency price data. ### Method GET ### Endpoint /api/crypto/history ### Parameters #### Query Parameters - **symbol** (string) - Required - Cryptocurrency symbol (e.g., 'BTC', 'ETH') - **start** (string) - Required - Start date in YYYY-MM-DD format - **end** (string) - Required - End date in YYYY-MM-DD format - **interval** (string) - Optional - Time interval ('1D', '1W', '1M'). Default: '1D' ### Request Example ```json { "symbol": "BTC", "start": "2024-01-01", "end": "2024-12-31", "interval": "1D" } ``` ### Response #### Success Response (200) - **data** (JSON string) - Contains OHLCV data (Open, High, Low, Close, Volume) with dates. #### Response Example ```json { "data": "{\"Date\": [\"2024-01-01\", \"2024-01-02\"], \"Open\": [42000.0, 42500.0], \"High\": [43000.0, 43200.0], \"Low\": [41800.0, 42300.0], \"Close\": [42500.0, 43100.0], \"Volume\": [500000, 520000]}" } ``` ``` -------------------------------- ### Get Forex History Source: https://github.com/gahoccode/vnprices-mcp/blob/main/llms.txt Fetches historical forex exchange rate data. Supports daily, weekly, and monthly intervals. ```APIDOC ## GET /api/forex/history ### Description Fetches historical forex exchange rate data. ### Method GET ### Endpoint /api/forex/history ### Parameters #### Query Parameters - **symbol** (string) - Required - Forex pair symbol (e.g., 'USDVND', 'EURVND') - **start** (string) - Required - Start date in YYYY-MM-DD format - **end** (string) - Required - End date in YYYY-MM-DD format - **interval** (string) - Optional - Time interval ('1D', '1W', '1M'). Default: '1D' ### Request Example ```json { "symbol": "USDVND", "start": "2024-06-01", "end": "2024-12-31", "interval": "1D" } ``` ### Response #### Success Response (200) - **data** (JSON string) - Contains OHLC data (Open, High, Low, Close) with dates. #### Response Example ```json { "data": "{\"Date\": [\"2024-06-03\", \"2024-06-04\"], \"Open\": [24500.0, 24510.0], \"High\": [24520.0, 24530.0], \"Low\": [24490.0, 24500.0], \"Close\": [24510.0, 24525.0]}" } ``` ``` -------------------------------- ### Get Stock History Source: https://github.com/gahoccode/vnprices-mcp/blob/main/llms.txt Fetches historical stock price data for Vietnamese stocks. Supports daily, weekly, and monthly intervals. ```APIDOC ## GET /api/stocks/history ### Description Fetches historical stock price data for Vietnamese stocks. ### Method GET ### Endpoint /api/stocks/history ### Parameters #### Query Parameters - **symbol** (string) - Required - Stock ticker symbol (e.g., 'VCI', 'VNM', 'HPG') - **start** (string) - Required - Start date in YYYY-MM-DD format (e.g., '2024-01-01') - **end** (string) - Required - End date in YYYY-MM-DD format (e.g., '2024-12-31') - **interval** (string) - Optional - Time interval ('1D', '1W', '1M'). Default: '1D' - **source** (string) - Optional - Data source. Default: 'VCI' ### Request Example ```json { "symbol": "VCI", "start": "2024-01-01", "end": "2024-12-31", "interval": "1D" } ``` ### Response #### Success Response (200) - **data** (JSON string) - Contains OHLCV data (Open, High, Low, Close, Volume) with dates. #### Response Example ```json { "data": "{\"Date\": [\"2024-01-02\", \"2024-01-03\"], \"Open\": [10.5, 10.7], \"High\": [11.0, 10.9], \"Low\": [10.4, 10.6], \"Close\": [10.8, 10.85], \"Volume\": [100000, 120000]}" } ``` ``` -------------------------------- ### Validate Claude Desktop Config JSON Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Bash command to validate the JSON syntax of the Claude Desktop configuration file using Python's built-in JSON tool. Incorrect JSON syntax can prevent the server from starting. ```bash cat ~/Library/Application\ Support/Claude/claude_desktop_config.json | python3 -m json.tool ``` -------------------------------- ### Get Index History Source: https://github.com/gahoccode/vnprices-mcp/blob/main/llms.txt Fetches historical index data for Vietnamese and international indices. Supports daily, weekly, and monthly intervals. ```APIDOC ## GET /api/index/history ### Description Fetches historical index data for both Vietnamese and international indices. ### Method GET ### Endpoint /api/index/history ### Parameters #### Query Parameters - **symbol** (string) - Required - Index symbol (e.g., 'VNINDEX', 'DJI', 'SPX') - **start** (string) - Required - Start date in YYYY-MM-DD format - **end** (string) - Required - End date in YYYY-MM-DD format - **interval** (string) - Optional - Time interval ('1D', '1W', '1M'). Default: '1D' ### Request Example ```json { "symbol": "VNINDEX", "start": "2024-01-01", "end": "2024-12-31", "interval": "1D" } ``` ### Response #### Success Response (200) - **data** (JSON string) - Contains OHLCV data with dates. #### Response Example ```json { "data": "{\"Date\": [\"2024-01-01\", \"2024-01-02\"], \"Open\": [1100.0, 1105.0], \"High\": [1110.0, 1112.0], \"Low\": [1095.0, 1103.0], \"Close\": [1105.0, 1111.0], \"Volume\": [1000000, 1100000]}" } ``` ``` -------------------------------- ### Get Foreign Exchange Rate Data Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Retrieves historical exchange rate data for currency pairs using the MSN data source. Provides OHLC data for forex pairs with Vietnamese Dong or other international currency combinations. ```APIDOC ## GET /api/forex_history ### Description Fetches historical exchange rate data for currency pairs. ### Method GET ### Endpoint /api/forex_history ### Parameters #### Query Parameters - **symbol** (string) - Required - Forex pair symbol (e.g., 'USDVND', 'JPYVND', 'EURVND') - **start_date** (string) - Required - Start date in YYYY-MM-DD format - **end_date** (string) - Required - End date in YYYY-MM-DD format - **interval** (string) - Optional - Data interval ('1D', '1W', '1M', defaults to '1D') ### Request Example ```json { "symbol": "USDVND", "start_date": "2024-01-01", "end_date": "2024-06-30", "interval": "1D" } ``` ### Response #### Success Response (200) - **data** (array) - Array of historical forex rate data objects, each containing: - **time** (string) - ISO format timestamp - **open** (number) - Opening rate - **high** (number) - High rate - **low** (number) - Low rate - **close** (number) - Closing rate #### Response Example ```json [ { "time": "2024-01-01T00:00:00.000Z", "open": 25350.0, "high": 25380.0, "low": 25340.0, "close": 25365.0 } ] ``` ``` -------------------------------- ### Get Forex History (Python) Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Retrieves historical exchange rate data for currency pairs using the MSN data source via the vnstock3 library. It provides OHLC data for forex pairs with Vietnamese Dong or other international currency combinations, with flexible date ranges and interval options. ```python from vnstock import Vnstock @mcp.tool() def get_forex_history( symbol: str, start_date: str, end_date: str, interval: str = "1D" ) -> str: """ Get historical forex exchange rate data. Args: symbol: Forex pair symbol (e.g., 'USDVND', 'JPYVND', 'EURVND') start_date: Start date in YYYY-MM-DD format end_date: End date in YYYY-MM-DD format interval: Data interval - '1D' (daily), '1W' (weekly), '1M' (monthly) Returns: JSON string with historical forex rate data (time, open, high, low, close) """ try: # Initialize Forex using Vnstock wrapper with MSN source fx = Vnstock().fx(symbol=symbol, source="MSN") # Fetch historical data df = fx.quote.history(start=start_date, end=end_date, interval=interval) if df is None or df.empty: return ( f"No forex data found for {symbol} between {start_date} and {end_date}" ) return df.to_json(orient="records", date_format="iso", indent=2) except Exception as e: return f"Error fetching forex data: {str(e)}" # Example usage in Claude Desktop: # "Show me USDVND exchange rates for the last 6 months" # Expected output format: # [ # { # "time": "2024-06-01T00:00:00.000Z", # "open": 25350.0, # "high": 25380.0, # "low": 25340.0, # "close": 25365.0 # }, # ... # ] ``` -------------------------------- ### Get Vietnamese Stock History (Python) Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Fetches historical OHLCV data for Vietnamese stock market securities using the VCI data source via the vnstock3 library. It returns time-series data including opening price, high, low, closing price, and trading volume for any Vietnamese stock ticker symbol, with flexible date ranges and interval options. ```python from mcp.server.fastmcp import FastMCP from vnstock import Quote @mcp.tool() def get_stock_history( symbol: str, start_date: str, end_date: str, interval: str = "1D" ) -> str: """ Get historical stock price data for Vietnamese stocks. Args: symbol: Stock ticker symbol (e.g., 'VCI', 'VNM', 'HPG') start_date: Start date in YYYY-MM-DD format (e.g., '2024-01-01') end_date: End date in YYYY-MM-DD format (e.g., '2024-12-31') interval: Data interval - '1D' (daily), '1W' (weekly), '1M' (monthly) Returns: JSON string with historical price data including time, open, high, low, close, volume """ try: # Initialize Quote object with VCI source quote = Quote(symbol=symbol, source="VCI") # Fetch historical data df = quote.history(start=start_date, end=end_date, interval=interval) if df is None or df.empty: return f"No data found for {symbol} between {start_date} and {end_date}" # Convert to JSON return df.to_json(orient="records", date_format="iso", indent=2) except Exception as e: return f"Error fetching stock data: {str(e)}" # Example usage in Claude Desktop: # "Get VCI stock prices from January 1, 2024 to December 31, 2024" # Expected output format: # [ # { # "time": "2024-01-01T00:00:00.000Z", # "open": 45000.0, # "high": 46500.0, # "low": 44800.0, # "close": 46200.0, # "volume": 1250000 # }, # ... # ] ``` -------------------------------- ### Get Vietnamese Stock Price Data Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Fetches historical OHLCV data for Vietnamese stock market securities using the VCI data source. Returns time-series data including opening price, high, low, closing price, and trading volume for any Vietnamese stock ticker symbol. ```APIDOC ## GET /api/stock_history ### Description Fetches historical OHLCV data for Vietnamese stock market securities. ### Method GET ### Endpoint /api/stock_history ### Parameters #### Query Parameters - **symbol** (string) - Required - Stock ticker symbol (e.g., 'VCI', 'VNM', 'HPG') - **start_date** (string) - Required - Start date in YYYY-MM-DD format (e.g., '2024-01-01') - **end_date** (string) - Required - End date in YYYY-MM-DD format (e.g., '2024-12-31') - **interval** (string) - Optional - Data interval ('1D', '1W', '1M', defaults to '1D') ### Request Example ```json { "symbol": "VNM", "start_date": "2024-01-01", "end_date": "2024-12-31", "interval": "1D" } ``` ### Response #### Success Response (200) - **data** (array) - Array of historical price data objects, each containing: - **time** (string) - ISO format timestamp - **open** (number) - Opening price - **high** (number) - High price - **low** (number) - Low price - **close** (number) - Closing price - **volume** (number) - Trading volume #### Response Example ```json [ { "time": "2024-01-01T00:00:00.000Z", "open": 45000.0, "high": 46500.0, "low": 44800.0, "close": 46200.0, "volume": 1250000 } ] ``` ``` -------------------------------- ### Docker Build and Deploy VNStock MCP Server Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md Commands to build the Docker image for the VNStock MCP Server and verify the build. It's recommended to rebuild after modifying server.py. ```bash # After modifying server.py docker build --no-cache -t vnprices-mcp:latest . # Verify build docker images | grep vnprices-mcp # Restart Claude Desktop (Cmd+Q, then reopen) ``` -------------------------------- ### Clone VNPrices MCP Repository Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Clones the VNPrices MCP server repository to your local machine and navigates into the project directory. This is the first step for setting up the server. ```bash git clone https://github.com/gahoccode/vnprices-mcp.git cd vnprices-mcp ``` -------------------------------- ### FastMCP Tool Implementation Pattern Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md Python code demonstrating the FastMCP pattern for implementing tools within the VNStock MCP Server. It uses decorators to define tools and includes basic error handling. ```python from mcp.server.fastmcp import FastMCP mcp = FastMCP("vnprices") @mcp.tool() def tool_name(param: str) -> str: """Tool description""" try: # Implementation return json.dumps(result) except Exception as e: return f"Error: {str(e)}" ``` -------------------------------- ### FastMCP Server Initialization (Python) Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Python code using the FastMCP framework to initialize an MCP server. It automatically registers tools decorated with @mcp.tool() and runs the server with stdio transport, suitable for inter-process communication. ```python from mcp.server.fastmcp import FastMCP from vnstock import Vnstock, Quote # Initialize the MCP server mcp = FastMCP("vnprices") # Tools are automatically registered via @mcp.tool() decorator # Each tool function becomes an available MCP tool if __name__ == "__main__": # Run server with stdio transport (default) mcp.run() ``` -------------------------------- ### MCP Gateway Configuration Files Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt YAML configuration files for integrating the VNPrices server with Claude Desktop via the Docker MCP Gateway. These files define server enablement, image registry, and custom catalog details including metadata, run commands, resource limits, and available tools. ```yaml # ~/.docker/mcp/config.yaml servers: vnprices: enabled: true # ~/.docker/mcp/registry.yaml servers: vnprices: image: vnprices-mcp:latest # ~/.docker/mcp/catalogs/custom.yaml name: vnstock-catalog displayName: Vietnamese Financial Data Tools version: 2 registry: vnprices: name: vnprices type: server image: vnprices-mcp:latest meta: category: finance tags: - vietnam - stocks - forex - crypto - finance about: title: "VNStock Price Data" description: "Fetch historical prices for Vietnamese stocks, forex, crypto, and international indices using vnstock3" run: command: - python3 - server.py limits: memory: "1g" cpus: "1" tools: - name: get_stock_history description: "Fetch Vietnamese stock OHLCV data" - name: get_forex_history description: "Fetch forex exchange rate data" - name: get_crypto_history description: "Fetch cryptocurrency price data" - name: get_index_history description: "Fetch international index data" ``` -------------------------------- ### Configure VNStock MCP Server for Claude Desktop Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Copies necessary configuration files (catalog, config, registry) to the Claude Desktop MCP directory. This step ensures that Claude Desktop can discover and interact with the VNStock MCP server. ```bash # Create the catalogs directory if it doesn't exist mkdir -p ~/.docker/mcp/catalogs # Copy the catalog file cp vnstock-catalog.yaml ~/.docker/mcp/catalogs/custom.yaml # Copy the config file cp config.yaml ~/.docker/mcp/config.yaml # Copy the registry file cp registry.yaml ~/.docker/mcp/registry.yaml ``` -------------------------------- ### Check config.yaml for Tools Not Appearing in Claude Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Bash command to display the content of the `config.yaml` file. This is used to verify that the `vnprices` server is enabled in the configuration, a common reason for tools not appearing. ```bash cat ~/.docker/mcp/config.yaml ``` -------------------------------- ### Docker Test MCP Gateway and View Logs Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md Bash commands to manually test the MCP gateway in debug mode and to view its logs. This involves mounting necessary Docker configurations and volumes. ```bash # Test gateway manually (debug mode) docker run -i --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.docker/mcp:/mcp \ docker/mcp-gateway \ --catalog=/mcp/catalogs/custom.yaml \ --config=/mcp/config.yaml \ --registry=/mcp/registry.yaml \ --verbose # View gateway logs docker logs -f $(docker ps -q -f ancestor=docker/mcp-gateway) ``` -------------------------------- ### Add New Tool to VNStock MCP Server Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md Steps to add a new tool to the VNStock MCP Server. This involves updating the Python server script, rebuilding the Docker image, modifying the MCP catalog, and restarting Claude Desktop. ```bash # 1. Update server.py with new @mcp.tool() decorator function # 2. Rebuild container: docker build --no-cache -t vnprices-mcp:latest . # 3. Update catalog at ~/.docker/mcp/catalogs/custom.yaml: # tools: # - name: your_new_tool # 4. Restart Claude Desktop (Cmd+Q, then reopen) ``` -------------------------------- ### Claude Desktop MCP Gateway Configuration Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt JSON configuration for Claude Desktop to enable the MCP Gateway, specifying the Docker command and arguments required to run the gateway and connect to custom MCP server catalogs and configurations. ```json // ~/Library/Application Support/Claude/claude_desktop_config.json { "mcpServers": { "mcp-gateway": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "/var/run/docker.sock:/var/run/docker.sock", "-v", "/Users/YOUR_USERNAME/.docker/mcp:/mcp", "docker/mcp-gateway", "--catalog=/mcp/catalogs/docker-mcp.yaml", "--catalog=/mcp/catalogs/custom.yaml", "--config=/mcp/config.yaml", "--registry=/mcp/registry.yaml", "--transport=stdio" ] } } } ``` -------------------------------- ### Claude Desktop MCP Server Configuration Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Edits the Claude Desktop configuration file to register the 'mcp-gateway' server. This allows Claude Desktop to launch and communicate with the Docker-based MCP gateway, enabling access to financial data. Remember to replace 'YOUR_USERNAME' with your actual macOS username. ```json { "mcpServers": { "mcp-gateway": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "/var/run/docker.sock:/var/run/docker.sock", "-v", "/Users/YOUR_USERNAME/.docker/mcp:/mcp", "docker/mcp-gateway", "--catalog=/mcp/catalogs/docker-mcp.yaml", "--catalog=/mcp/catalogs/custom.yaml", "--config=/mcp/config.yaml", "--registry=/mcp/registry.yaml", "--transport=stdio" ] } } } ``` -------------------------------- ### Test vnstock3 Data Fetching in Docker Container (Bash) Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md This snippet demonstrates how to run a Python script within a Docker container to test the vnstock3 library for fetching stock quotes and forex data. It requires the vnprices-mcp Docker image to be available. ```bash docker run -it vnprices-mcp:latest python3 << 'EOF' \ from vnstock import Quote, Vnstock # Test Vietnamese stock q = Quote('VCI') print(q.history('2024-01-01', '2024-12-31')) # Test forex v = Vnstock() print(v.fx('USDVND', '2024-01-01', '2024-12-31')) EOF ``` -------------------------------- ### View Live Logs using Docker Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Commands to view live logs for the mcp-gateway container. It shows how to find the container ID and stream its logs, or perform it in a single command. Useful for real-time monitoring during development or troubleshooting. ```bash # Find the gateway container docker ps | grep mcp-gateway # View logs (replace with actual ID) docker logs -f # Or in one command docker logs -f $(docker ps -q -f ancestor=docker/mcp-gateway) ``` -------------------------------- ### Add New Tool Definition in Python Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Python code snippet demonstrating how to define a new tool using the `types.Tool` class. It specifies the tool's name, a description, and an input schema defining its parameters. This is part of adding new functionality to the MCP server. ```python types.Tool( name="your_new_tool", description="What it does", inputSchema={ "type": "object", "properties": { "param": {"type": "string"} }, "required": ["param"] } ) ``` -------------------------------- ### Add Handler Logic for New Tool in Python Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Python code snippet showing how to implement the handler logic for a new tool within the `handle_call_tool()` function. It includes checking the tool name and returning the result, typically as a JSON-encoded string within a `TextContent` object. ```python elif name == "your_new_tool": # Your implementation result = {"data": "response"} return [types.TextContent(type="text", text=json.dumps(result))] ``` -------------------------------- ### Docker Container Management and Testing Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Bash commands for manually testing the running vnprices-mcp Docker container, viewing server and gateway logs, and performing cleanup operations by removing stopped containers and images. ```bash # Test the server manually docker run -i vnprices-mcp:latest # View server logs when tools are called docker ps -a | grep vnprices # Find container ID docker logs --tail 100 # View gateway logs docker logs -f $(docker ps -q -f ancestor=docker/mcp-gateway) # Cleanup docker container prune docker rm -f $(docker ps -aq -f ancestor=vnprices-mcp:latest) ``` -------------------------------- ### Test vnstock3 Server Inside Container Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Docker command to test if the `vnstock3` library is working correctly within the `vnprices-mcp` container. It executes a simple Python command to import `Quote` and print 'OK'. ```bash docker run -it vnprices-mcp:latest python3 -c "from vnstock import Quote; print('OK')" ``` -------------------------------- ### Docker Cleanup and Force Rebuild Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md Bash commands to clean up stopped Docker containers, force remove specific containers and images, and then perform a force rebuild of the vnprices-mcp image. ```bash # Remove stopped containers docker container prune # Force rebuild everything (when things break) docker rm -f $(docker ps -aq -f ancestor=vnprices-mcp:latest) docker rm -f $(docker ps -aq -f ancestor=docker/mcp-gateway) docker rmi vnprices-mcp:latest docker build --no-cache -t vnprices-mcp:latest . ``` -------------------------------- ### Rebuild Docker Image for vnprices-mcp Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Bash command to rebuild the Docker image for the `vnprices-mcp` project. This command should be run after making changes to the code or `Dockerfile` to incorporate the updates into the image. ```bash docker build -t vnprices-mcp:latest . ``` -------------------------------- ### Error Message Format Source: https://github.com/gahoccode/vnprices-mcp/blob/main/llms.txt This snippet shows the standard format for error messages returned by the tools when exceptions occur. Errors are prefixed with 'Error: ' followed by a description. ```text Error: ``` -------------------------------- ### Clean Up Old Docker Containers and Images Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Bash commands to clean up unused Docker resources. Includes removing stopped containers, unused images, and performing a full system prune. Use with caution, especially the system prune command. ```bash # Remove stopped containers docker container prune # Remove unused images docker image prune # Full cleanup (careful!) docker system prune -a ``` -------------------------------- ### Force Rebuild vnprices-mcp Project with Docker Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md A sequence of Docker commands to force a complete rebuild of the vnprices-mcp project. This involves stopping the service, removing old containers and images, rebuilding from scratch, and verifying files. It's a useful step when encountering persistent issues. ```bash # 1. Stop Claude Desktop # 2. Remove old containers docker rm -f $(docker ps -aq -f ancestor=vnprices-mcp:latest) docker rm -f $(docker ps -aq -f ancestor=docker/mcp-gateway) # 3. Remove old image docker rmi vnprices-mcp:latest # 4. Rebuild from scratch docker build --no-cache -t vnprices-mcp:latest . # 5. Verify files exist ls -la ~/.docker/mcp/ cat ~/.docker/mcp/config.yaml cat ~/.docker/mcp/catalogs/custom.yaml # 6. Test gateway manually (see above) # 7. Restart Claude Desktop ``` -------------------------------- ### Update Tool Catalog Configuration Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md YAML snippet showing how to update the `custom.yaml` catalog file to include a newly added tool. This step is necessary for the MCP gateway to recognize and make the new tool available. ```yaml tools: - name: your_new_tool ``` -------------------------------- ### Fetch Cryptocurrency History (Python) Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Fetches historical cryptocurrency price data (OHLCV) for specified symbols and date ranges using the MSN data source. It supports daily, weekly, and monthly intervals. Returns data as a JSON string. ```python import json from vnstock import Vnstock # Assume mcp is defined elsewhere and decorated with @mcp.tool() # class MockMCP: # def tool(self): # def decorator(func): # return func # return decorator # mcp = MockMCP() # @mcp.tool() def get_crypto_history( symbol: str, start_date: str, end_date: str, interval: str = "1D" ) -> str: """ Get historical cryptocurrency price data. Args: symbol: Crypto symbol (e.g., 'BTC', 'ETH') start_date: Start date in YYYY-MM-DD format end_date: End date in YYYY-MM-DD format interval: Data interval - '1D' (daily), '1W' (weekly), '1M' (monthly) Returns: JSON string with historical crypto price data (time, open, high, low, close, volume) """ try: # Initialize Crypto using Vnstock wrapper with MSN source crypto = Vnstock().crypto(symbol=symbol, source="MSN") # Fetch historical data df = crypto.quote.history(start=start_date, end=end_date, interval=interval) if df is None or df.empty: return ( f"No crypto data found for {symbol} between {start_date} and {end_date}" ) return df.to_json(orient="records", date_format="iso", indent=2) except Exception as e: return f"Error fetching crypto data: {str(e)}" # Example usage: # print(get_crypto_history(symbol='BTC', start_date='2024-01-01', end_date='2024-01-05')) ``` -------------------------------- ### Rebuild VNPrices MCP Docker Image Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Rebuilds the Docker image for the VNPrices MCP server after making code changes. It also rebuilds the mcp-gateway image, stops and removes any existing gateway container, and verifies the new image. ```bash # 1. Navigate to project directory cd vnprices-mcp # 2. Rebuild Docker image docker build -t vnprices-mcp:latest . docker build -t mcp-gateway . # 2. Stop and remove old gateway container docker stop mcp-gateway && docker rm mcp-gateway # 3. Verify new image docker images | grep vnprices-mcp # 4. Check image ID changed docker images vnprices-mcp # 5. Run gateway docker run -d \ --name mcp-gateway \ -v $(pwd)/catalogs:/mcp/catalogs \ -v $(pwd)/registry.yaml:/mcp/registry.yaml \ -v $(pwd)/config.yaml:/mcp/config.yaml \ -p 3000:3000 \ mcp-gateway # 6. Restart Claude Desktop completely # Quit (Cmd+Q) and restart ``` -------------------------------- ### View Detailed Docker Container Logs Source: https://github.com/gahoccode/vnprices-mcp/blob/main/README.md Bash command to view the last 100 lines of logs for a specific Docker container. This is useful for debugging server errors when the full log stream is not necessary. ```bash docker logs --tail 100 ``` -------------------------------- ### Fetch Market Index History (Python) Source: https://context7.com/gahoccode/vnprices-mcp/llms.txt Retrieves historical market index data for both Vietnamese and international indices. It intelligently routes requests to the VCI source for Vietnamese indices and the MSN source for international ones. Returns data as a JSON string. ```python import json from vnstock import Vnstock, Quote # Assume mcp is defined elsewhere and decorated with @mcp.tool() # class MockMCP: # def tool(self): # def decorator(func): # return func # return decorator # mcp = MockMCP() # @mcp.tool() def get_index_history( symbol: str, start_date: str, end_date: str, interval: str = "1D" ) -> str: """ Get historical market index data (Vietnamese and international indices). Args: symbol: Index symbol Vietnamese: 'VNINDEX', 'HNXINDEX', 'UPCOMINDEX' International: 'DJI' (Dow Jones), 'SP500', etc. start_date: Start date in YYYY-MM-DD format end_date: End date in YYYY-MM-DD format interval: Data interval - '1D' (daily), '1W' (weekly), '1M' (monthly) Returns: JSON string with historical index data (time, open, high, low, close, volume) """ try: # Check if it's a Vietnamese index vietnam_indices = ["VNINDEX", "HNXINDEX", "UPCOMINDEX"] if symbol.upper() in vietnam_indices: # Use Quote with VCI source for Vietnamese indices quote = Quote(symbol=symbol, source="VCI") df = quote.history(start=start_date, end=end_date, interval=interval) else: # Use MSN source for international indices index = Vnstock().world_index(symbol=symbol, source="MSN") df = index.quote.history(start=start_date, end=end_date, interval=interval) if df is None or df.empty: return ( f"No index data found for {symbol} between {start_date} and {end_date}" ) return df.to_json(orient="records", date_format="iso", indent=2) except Exception as e: return f"Error fetching index data: {str(e)}" # Example usage for Vietnamese index: # print(get_index_history(symbol='VNINDEX', start_date='2024-01-01', end_date='2024-01-05')) # Example usage for international index: # print(get_index_history(symbol='DJI', start_date='2024-01-01', end_date='2024-01-05')) ``` -------------------------------- ### Build Docker Image and Filter for Errors (Bash) Source: https://github.com/gahoccode/vnprices-mcp/blob/main/CLAUDE.md This command builds the vnprices-mcp Docker image, disabling the cache and showing build progress. It then filters the output to display only lines containing 'error', which is useful for diagnosing build failures. ```bash docker build --no-cache --progress=plain -t vnprices-mcp:latest . 2>&1 | grep -i error ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.