@gabriel3615/chart-img-mcp
v1.0.8
Published
MCP for generating chart images
Downloads
28
Readme
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.comAPI for image generation.
Setup
Clone the repository:
git clone https://github.com/your-username/chart-img-mcp.git cd chart-img-mcpInstall dependencies:
npm installEnvironment Variables: Create a
.envfile in the root of the project and add yourchart-img.comAPI key:CHART_IMG_API_KEY=YOUR_ACTUAL_CHART_IMG_API_KEYReplace
YOUR_ACTUAL_CHART_IMG_API_KEYwith your API key obtained from chart-img.com.
Usage
Running the MCP Server
To start the MCP server in development mode:
npm run devTo inspect the MCP server using the MCP Inspector UI:
npm run inspectBuilding the Project
To compile the TypeScript code to JavaScript:
npm run buildThis 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 inchartConfigsshould have:interval(string, required): Chart interval (e.g.,'1D','4h','1h').studies(array of objects, optional): Array of technical indicators. Each object should have anameproperty (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:
{
"tool": "generateChartImages",
"arguments": {
"symbol": "BINANCE:ETHUSDT"
}
}To generate a daily chart with 'RSI' and 'SMA' studies, and a 4-hour chart with 'Volume' study:
{
"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.
{
"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.
{
"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:
npm publish --access publicThe prepublishOnly script will automatically run npm run build before publishing.
