Skip to content

taskcrew/forecasting-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forecasting MCP

An MCP (Model Context Protocol) server for time series forecasting powered by Nixtla's TimeGPT foundation model.

Quick Start

Connect to Hosted Server

Add to your Claude Code settings (~/.claude.json) or MCP client:

{
  "mcpServers": {
    "forecasting": {
      "type": "http",
      "url": "https://your-deployment.vercel.app/api/mcp"
    }
  }
}

Run Locally (stdio)

npm install
npm run cli

Add to Claude Code for local usage:

{
  "mcpServers": {
    "forecasting": {
      "type": "stdio",
      "command": "npx",
      "args": ["tsx", "cli.ts"],
      "cwd": "/path/to/forecasting-mcp"
    }
  }
}

Deploy to Vercel

npm install
npx vercel

Features

  • Zero-shot forecasting - No training required, works out of the box
  • Multi-series support - Forecast multiple time series in a single request
  • Exogenous variables - Include external factors that influence your forecast
  • Prediction intervals - Quantify uncertainty with configurable confidence levels
  • Feature contributions - Understand which factors drive your predictions

Available Tools

forecast

Generate time series forecasts from CSV data.

Parameters

Parameter Type Required Description
csv_content string No* CSV content with time series data
csv_url string No* URL to fetch CSV data from (S3, HTTP). Takes priority over csv_content
h number Yes Forecast horizon (number of periods)
freq string Yes Data frequency (see below)
model string No Model selection (default: timegpt-1)
level number[] No Prediction interval percentages, e.g., [80, 95]
clean_ex_first boolean No Preprocess exogenous signals (default: true)
feature_contributions boolean No Return feature importance scores
X_future_content string No CSV content with future exogenous values
X_future_url string No URL to fetch future exogenous CSV data from
save_to_bucket boolean No Save output to Vercel Blob and return download URL (default: true)

*Either csv_content or csv_url must be provided.

Supported Frequencies

Code Frequency
H Hourly
D Daily
W Weekly
M Monthly (end)
MS Monthly (start)
Y Yearly

Models

Model Use Case
timegpt-1 Default. Best for forecasts within one seasonal period
timegpt-1-long-horizon Extended forecasts beyond one seasonal period

Input Format

The CSV content must contain these columns:

Column Required Description
unique_id Yes Series identifier
ds Yes Timestamp (ISO 8601 format)
y Yes Target values to forecast
additional No Exogenous features

Example:

unique_id,ds,y,temperature,is_holiday
store_NYC,2024-01-01,1520,32,1
store_NYC,2024-01-02,1340,35,0
store_NYC,2024-01-03,1425,33,0
store_LA,2024-01-01,2100,68,1
store_LA,2024-01-02,1890,71,0
store_LA,2024-01-03,1950,69,0

Output Format

The forecast is returned as CSV:

unique_id,ds,forecast,lo_90,hi_90
store_NYC,2024-01-04,1467.3,1389.2,1545.4
store_NYC,2024-01-05,1502.8,1411.6,1594.0
store_LA,2024-01-04,1978.5,1856.3,2100.7
store_LA,2024-01-05,2015.2,1879.8,2150.6

Usage Examples

Basic Forecast

Forecast the next 7 days with daily frequency using this data:
unique_id,ds,y
sales,2024-01-01,100
sales,2024-01-02,120
...

With Prediction Intervals

Generate a 12-month forecast with 80% and 95% prediction intervals for monthly sales data

With Exogenous Variables

Forecast energy demand for 24 hours including temperature as an exogenous variable

From URL (S3, HTTP)

Forecast the next 30 days using data from https://my-bucket.s3.amazonaws.com/sales.csv with daily frequency

Output Storage

By default, forecast output is saved to Vercel Blob and a download URL is returned.

To get raw CSV content instead, set save_to_bucket: false.

Environment Variables

Variable Required Description
NIXTLA_API_KEY No* Nixtla API key (has default)
BLOB_READ_WRITE_TOKEN No Required for save_to_blob feature

Local Development

# Install dependencies
npm install

# Run development server (HTTP mode)
npm run dev

# Run CLI mode (stdio)
npm run cli

Error Handling

Error Cause Solution
CSV file is empty No data provided Ensure CSV content is not empty
Missing required columns CSV missing unique_id, ds, or y Ensure CSV has required columns
Invalid frequency Unsupported frequency code Use one of: H, D, W, M, MS, Y
Exogenous mismatch Future exogenous columns don't match input Ensure same exogenous columns in both CSVs

Rate Limits

Limits depend on your Nixtla API plan. See Nixtla pricing for details.

Tech Stack

Links

License

MIT

About

MCP server for time series forecasting powered by Nixtla TimeGPT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •