Forex Factory Calendar MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Forex Factory Calendar MCPWhat high-impact Forex events are scheduled this week?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π Forex Factory Calendar MCP
A Python-based Forex Factory economic calendar collector and MCP server that transforms Forex Factory's weekly calendar data into structured, enriched event data for AI agents.
π Overview
Forex Factory Calendar MCP collects economic calendar data from Forex Factory, enriches events with detailed information, stores the resulting dataset as JSON, and exposes the data through the Model Context Protocol (MCP).
The project combines:
π₯ Forex Factory weekly JSON data
π Forex Factory calendar HTML
π Event ID extraction
π§© Event matching and enrichment
π° Event detail information
πΎ Structured JSON output
π MCP tools
π MCP resources
β‘ FastAPI HTTP transport
The goal is to make Forex Factory economic-calendar data easily consumable by AI agents and MCP-compatible applications.
ποΈ Architecture
ββββββββββββββββββββββββ
β Forex Factory β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
β β
βΌ βΌ
Weekly Calendar JSON Calendar HTML
β β
βΌ βΌ
Basic Events Event IDs / Metadata
β β
ββββββββββββββββββ¬βββββββββββββββββ
βΌ
Event Matching
β
βΌ
Event Detail Endpoint
β
βΌ
Enriched Event Dataset
β
βΌ
ββββββββββββββββββββββ
β JSON Store β
β /data β
βββββββββββ¬βββββββββββ
β
ββββββββββββββββ΄βββββββββββββββ
β β
βΌ βΌ
FastMCP Tools MCP Resource
β β
β β
βΌ βΌ
get_forex_calendar() events://all
get_calendar_stats()
β β
ββββββββββββββββ¬βββββββββββββββ
βΌ
MCP Client
β
βΌ
AI Agent⨠Features
Feature | Description |
π Weekly Calendar | Fetches Forex Factory's current-week calendar |
π HTML Parsing | Extracts event IDs and additional metadata |
π Event Matching | Matches JSON events with HTML calendar rows |
π° Event Details | Fetches detailed information for identified events |
πΎ JSON Storage | Saves the enriched calendar locally |
π§ Configurable | Supports detail-impact filtering and request delays |
π MCP Tools | Exposes calendar operations as MCP tools |
π MCP Resource | Exposes calendar data through |
β‘ FastAPI | Makes the MCP server available over HTTP |
π§ͺ Inspectable | Supports FastMCP inspection and CLI testing |
π Data Collection Pipeline
The collector currently follows this pipeline:
1. Fetch Weekly JSON
β
βΌ
2. Normalize Calendar Events
β
βΌ
3. Fetch Calendar HTML
β
βΌ
4. Parse Calendar Rows
β
βΌ
5. Extract Event IDs
β
βΌ
6. Match HTML β JSON Events
β
βΌ
7. Fetch Event Details
β
βΌ
8. Enrich Events
β
βΌ
9. Save JSON Datasetπ‘ Data Sources
Related MCP server: mcp-server-fxmacrodata
1. Forex Factory Weekly JSON
The initial calendar data is fetched from:
https://nfs.faireconomy.media/ff_calendar_thisweek.jsonThe feed provides fields such as:
Date / time
Currency
Impact
Event title
Actual
Forecast
Previous
2. Forex Factory Calendar HTML
The collector also requests:
https://www.forexfactory.com/calendarThe HTML is required because the weekly JSON feed does not currently provide the Forex Factory event_id.
The parser looks for calendar rows containing:
<tr class="calendar__row" data-event-id="..."></tr>The extracted event ID is then associated with the normalized calendar event.
3. Event Details
Once an event ID has been identified, the collector requests:
https://www.forexfactory.com/calendar/details/1-{event_id}The response can contain information such as:
Event specifications
Description
Source
Speaker
Usual Effect
FF Notes
Why Traders Care
Historical information
Linked discussion threads
The current implementation stores the raw detail response under the event's news field.
π¦ Output
Generated calendar files are stored inside:
data/The current tool generates files using:
forex_calendar_YYYY-MM-DD.jsonExample:
data/
βββ forex_calendar_2026-09-04.jsonA typical top-level response looks like:
{
"source": "Forex Factory",
"fetched_at": "...",
"total_events": 0,
"events_with_event_id": 0,
"events_with_news": 0,
"events": []
}Event Structure
{
"event_id": "146911",
"datetime": "2026-09-04T12:30:00-04:00",
"timestamp": "2026-09-04T16:30:00+00:00",
"currency": "USD",
"impact": "High",
"event": "Non-Farm Employment Change",
"actual": null,
"forecast": "75K",
"previous": "73K",
"event_url": null,
"graph_url": null,
"news": {}
}π MCP Integration
The project now exposes the collector through FastMCP.
The MCP layer currently provides:
π οΈ Tools
get_forex_calendar
Fetches the complete current-week Forex Factory calendar.
Parameters:
save_to_file: bool = True
output_filename: str | None = NoneExample:
get_forex_calendar(save_to_file=true)get_calendar_stats
Returns summary statistics for the current calendar.
Example response:
{
"total_events": 113,
"high_impact": 25,
"medium_impact": 41,
"low_impact": 47,
"events_with_news": 45,
"fetched_at": "..."
}π MCP Resources
The server currently exposes one MCP resource:
events://allThis resource provides the calendar dataset as JSON.
Conceptually:
MCP Client
β
β resources/list
βΌ
events://all
β
β resources/read
βΌ
Calendar JSONThe resource is declared using:
@mcp.resource(
"events://all",
name="Forex Factory Events",
description="Forex Factory economic calendar events for the current week",
mime_type="application/json",
)
def get_events() -> str:
...Note: The current test implementation reads
data/test_output.json, whileget_forex_calendar()currently generatesforex_calendar_YYYY-MM-DD.json. These should be unified soevents://allalways exposes the latest generated dataset.
β‘ FastAPI Integration
FastMCP is exposed through FastAPI using Streamable HTTP.
The architecture is:
FastAPI
β
ββββββββββββββ΄βββββββββββββ
β β
βΌ βΌ
/health /mcp
β
βΌ
FastMCP
βββββββ΄ββββββ
β β
βΌ βΌ
Tools ResourcesThe MCP HTTP application is mounted under:
/mcpResulting endpoint:
http://127.0.0.1:8000/mcpπ§° Installation
Clone the project and create a virtual environment:
python -m venv .venvActivate it on Windows:
.venv\Scripts\activateInstall dependencies:
pip install requests beautifulsoup4 tqdm fastmcp fastapi uvicornβΆοΈ Running the Server
Run FastAPI + MCP
Start the HTTP server with:
uvicorn server:app --reloadThe API will be available at:
http://127.0.0.1:8000Health check:
http://127.0.0.1:8000/healthMCP endpoint:
http://127.0.0.1:8000/mcp
/mcpis an MCP protocol endpoint and should be accessed by an MCP client rather than treated as a normal browser page.
π§ͺ Testing
Inspect the local MCP server
fastmcp inspect server.pyFor the complete FastMCP representation:
fastmcp inspect server.py --format fastmcpList MCP tools
fastmcp list http://127.0.0.1:8000/mcpExpected:
Tools (2)
get_forex_calendar(...)
get_calendar_stats()List tools + resources
Use:
fastmcp list http://127.0.0.1:8000/mcp --resourcesExpected resources include:
events://allFor machine-readable output:
fastmcp list http://127.0.0.1:8000/mcp --resources --jsonπ Project Structure
Forex-Factory-MCP/
β
βββ server.py
β βββ FastMCP server
β βββ MCP tools
β βββ MCP resources
β βββ FastAPI application
β
βββ scrapper.py
β βββ Calendar JSON collection
β βββ Calendar HTML parsing
β βββ Event matching
β βββ Event detail enrichment
β
βββ config.py
β βββ URLs
β βββ Request delay
β βββ Detail impact configuration
β βββ HTTP headers
β βββ Output directory
β
βββ data/
β βββ Generated calendar JSON files
β
βββ README.md
β
βββ .venv/βοΈ Configuration
Configuration is centralized in config.py.
Request Delay
REQUEST_DELAY = 1.5This introduces a delay between requests to avoid making requests too aggressively.
Detail Impact Filter
DETAIL_IMPACTS = NoneCurrent behavior:
None
β
Fetch details for every event with an event_idYou can restrict detail fetching:
DETAIL_IMPACTS = {"High"}or:
DETAIL_IMPACTS = {"High", "Medium"}β οΈ Current Limitations
Event ID Matching
The biggest current limitation is matching the weekly JSON events against the HTML calendar.
The pipeline currently relies on:
Weekly JSON
β
Calendar HTMLA typical run can produce:
Fetched 113 events from JSON feed
Found 121 calendar HTML rows
Extracted 45 events with event IDs
Matched: 45
Unmatched: 68Events without an event_id cannot currently receive detailed event information.
Improving event-ID resolution is therefore a major priority.
Fixed Weekly Source
The current JSON source is:
ff_calendar_thisweek.jsonTherefore, the collector currently relies on Forex Factory's definition of "this week" rather than accepting arbitrary date ranges.
Calendar URL
The HTML collector currently uses:
https://www.forexfactory.com/calendarA future implementation should use an explicit date-range URL.
Timezone Handling
Timezone handling is not yet exposed as an input to the MCP tools.
Future versions are expected to support IANA timezone names such as:
Asia/Kolkata
America/New_York
Europe/London
Asia/Tokyo
UTCResource/Data Synchronization
The current MCP resource reads:
data/test_output.jsonwhile the calendar tool generates:
data/forex_calendar_YYYY-MM-DD.jsonThis is temporary and should be changed so the resource always points to the latest generated weekly dataset.
πΊοΈ Roadmap
π΄ High Priority
Improve JSON β HTML event matching
Make event IDs the primary downstream identifier
Use explicit Forex Factory date-range URLs
Unify MCP resource with the latest generated JSON
Improve timezone-aware date handling
Improve HTTP error handling
Add retry/backoff behavior
Handle malformed Forex Factory responses gracefully
π‘ MCP Layer
Implement FastMCP
Add
get_forex_calendarAdd
get_calendar_statsAdd
events://allresourceExpose MCP through FastAPI
Improve resource/data synchronization
Add timezone-aware inputs
Add date-range support
Improve LLM-friendly response structures
π’ Data Layer
Weekly JSON collection
Calendar HTML collection
Event ID extraction
Event matching
Event detail collection
JSON persistence
Cleaner normalized event-detail schema
π§ Design Principles
The long-term architecture separates the system into three layers:
βββββββββββββββββββββββββββββββββββββββββββ
β MCP Layer β
β β
β Tools β
β Resources β
β Input validation β
β Agent-facing responses β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Domain / Collector Layer β
β β
β Date handling β
β Timezone handling β
β Calendar collection β
β Event matching β
β Event enrichment β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Forex Factory β
β β
β Weekly JSON β
β Calendar HTML β
β Event detail endpoint β
βββββββββββββββββββββββββββββββββββββββββββThis keeps the scraping and data-collection logic independent from the MCP protocol.
The collector should remain reusable even when the data is consumed outside an AI-agent environment.
π Responsible Usage
This project relies on publicly accessible Forex Factory pages/endpoints and scraping behavior rather than an official Forex Factory developer API.
The collector should therefore:
Respect Forex Factory's terms and policies.
Use reasonable request rates.
Avoid unnecessary repeated requests.
Handle changes to the site's HTML structure gracefully.
Avoid excessive requests to the service.
HTML selectors and endpoint behavior may change over time.
π― Project Goal
The long-term goal is to build a reliable, timezone-aware Forex Factory economic-calendar service that provides high-quality structured data to AI agents through MCP.
The project is evolving toward:
Forex Factory
β
βΌ
Data Collection
β
βΌ
Event Enrichment
β
βΌ
Structured Dataset
β
βΌ
FastMCP
β
βββββββββββββββββ
βΌ βΌ
Tools Resources
β β
βββββββββ¬ββββββββ
βΌ
AI AgentsThe current focus is improving data quality, event-ID resolution, MCP resource consistency, and timezone-aware calendar handling.
This server cannot be deployed
Maintenance
Related MCP Connectors
Macroeconomic and FX time-series data for AI agents: indicators, calendars, COT, forex, commodities.
Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.
The financial MCP for AI agents - 90+ financial tables, SEC filings, signals, alt-data.
Real-time market events, sentiment, and technical analysis as MCP tools, backed by real data.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables access to ForexFactory economic calendar data through MCP resources and tools. Supports retrieving economic events by time periods for integration with trading assistants and agentic workflows.111MIT
- AlicenseAqualityCmaintenanceProvides access to macroeconomic indicators, FX rates, COT data, commodities, and release calendars through the FXMacroData API for AI agents.8MIT
- AlicenseNot gradedqualityDmaintenanceProvides 10 financial data tools (market data, economic indicators, news, insider trades, and calendars) via a single MCP layer, enabling any MCP-compatible LLM to access diverse financial data through a unified interface.MIT
- AlicenseNot gradedqualityCmaintenanceProvides macro-economic event data, earnings reports, and market overviews as MCP tools, enabling AI agents to query calendars, check event proximity, and assess trade safety.2MIT