npm package: @gabriel3615/chart-img-mcp
Description: MCP for generating chart images
Author: Your Name
Latest version: 1.0.8

# chart-img-mcp

This project is an MCP (Model Context Protocol) server designed for generating chart images using the chart-img.com API.

## Features

- Generates daily, 4-hour, and 1-hour stock chart images.
- Supports configurable technical indicators for each chart interval.
- Integrates with `chart-img.com` API for image generation.

## Setup

1.  **Clone the repository:**
    ```bash
    git clone https://github.com/your-username/chart-img-mcp.git
    cd chart-img-mcp
    ```

2.  **Install dependencies:**
    ```bash
    npm install
    ```

3.  **Environment Variables:**
    Create a `.env` file in the root of the project and add your `chart-img.com` API key:
    ```
    CHART_IMG_API_KEY=YOUR_ACTUAL_CHART_IMG_API_KEY
    ```
    Replace `YOUR_ACTUAL_CHART_IMG_API_KEY` with your API key obtained from [chart-img.com](https://chart-img.com/).

## Usage

### Running the MCP Server

To start the MCP server in development mode:

```bash
npm run dev
```

To inspect the MCP server using the MCP Inspector UI:

```bash
npm run inspect
```

### Building the Project

To compile the TypeScript code to JavaScript:

```bash
npm run build
```

This command will clean the `dist` directory and then compile the TypeScript files.

### Using the `generateChartImages` Tool

The `generateChartImages` tool allows you to generate stock chart images with specified intervals and technical indicators.

**Tool Name:** `generateChartImages`

**Parameters:**

-   `symbol` (string, required): The stock symbol (e.g., `'BINANCE:ETHUSDT'`).
-   `chartConfigs` (array of objects, optional): Configuration for different chart intervals and studies. If not provided, it defaults to 1D, 4h, 1h intervals with 'Volume' and 'MACD' studies.
    Each object in `chartConfigs` should have:
    -   `interval` (string, required): Chart interval (e.g., `'1D'`, `'4h'`, `'1h'`).
    -   `studies` (array of objects, optional): Array of technical indicators. Each object should have a `name` property (e.g., `[{ name: 'Volume' }, { name: 'MACD' }]`).

**Example Usage (from a MCP client):**

To generate daily, 4-hour, and 1-hour charts for `BINANCE:ETHUSDT` with default studies:

```json
{
  "tool": "generateChartImages",
  "arguments": {
    "symbol": "BINANCE:ETHUSDT"
  }
}
```

To generate a daily chart with 'RSI' and 'SMA' studies, and a 4-hour chart with 'Volume' study:

```json
{
  "tool": "generateChartImages",
  "arguments": {
    "symbol": "BINANCE:ETHUSDT",
    "chartConfigs": [
      {
        "interval": "1D",
        "studies": [
          { "name": "RSI" },
          { "name": "SMA" }
        ]
      },
      {
        "interval": "4h",
        "studies": [
          { "name": "Volume" }
        ]
      }
    ]
  }
}
```

**Return Value:**

The tool returns a JSON object where keys are the chart intervals and values are the URLs of the generated images.

```json
{
  "1D": "https://example.com/daily_chart.png",
  "4h": "https://example.com/4h_chart.png",
  "1h": "https://example.com/1h_chart.png"
}
```

## Config MCP tool

To configure the MCP tool, you can specify the default chart configurations in the `config.json` file located in the root directory. This file allows you to set default intervals and studies for the `generateChartImages` tool.
```json
{
  "mcpServers": {
    "chart-img-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@gabriel3615/chart-img-mcp@latest"
      ],
      "env": {
        "CHART_IMG_API_KEY": "KEY_HERE"
      }
    }
  }
}
```

## Publishing to npmjs

To publish this package to npmjs, ensure your `package.json` `name` and `version` are unique and updated. Then run:

```bash
npm publish --access public
```

The `prepublishOnly` script will automatically run `npm run build` before publishing.