Skip to main content
Glama
kjpou1

ForexFactory MCP Server

by kjpou1
README.md
# ๐Ÿ“… ForexFactory MCP Server

![Python](https://img.shields.io/badge/python-3.12+-blue.svg)
![License](https://img.shields.io/badge/license-MIT-green.svg)
![MCP](https://img.shields.io/badge/MCP-Server-orange)
![uv](https://img.shields.io/badge/packaging-uv-purple)

![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)
![Status](https://img.shields.io/badge/status-active-success.svg)
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)
![Made with Love](https://img.shields.io/badge/made%20with-%E2%9D%A4-red.svg)

An MCP (Model Context Protocol) server that exposes **ForexFactory economic calendar data** as resources and tools.

Designed for use in **agentic workflows**, LLMs, and trading assistants.

<a href="https://glama.ai/mcp/servers/@kjpou1/forexfactory-mcp">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/@kjpou1/forexfactory-mcp/badge" alt="ForexFactory Server MCP server" />
</a>

---

<details>
<summary>๐Ÿ“‚ <strong>Table of contents (click to expand)</strong></summary>
  
- [๐Ÿ“… ForexFactory MCP Server](#-forexfactory-mcp-server)
  - [๐Ÿš€ Features](#-features)
    - [๐Ÿ“Œ Development Status](#-development-status)
  - [๐Ÿ”ง Installation](#-installation)
    - [Requirements](#requirements)
    - [Setup](#setup)
  - [โ–ถ๏ธ Usage](#๏ธ-usage)
    - [โšก Quickstart](#-quickstart)
    - [SSE transport (โš ๏ธ deprecated)](#sse-transport-๏ธ-deprecated)
    - [Environment variable defaults](#environment-variable-defaults)
  - [๐Ÿท๏ธ Namespace](#๏ธ-namespace)
  - [๐Ÿ“ฆ Resources](#-resources)
  - [๐Ÿ› ๏ธ Tools](#๏ธ-tools)
  - [๐Ÿ“ Prompts](#-prompts)
    - [๐Ÿงฉ Prompt Styles](#-prompt-styles)
  - [๐Ÿ’ป Client Examples](#-client-examples)
    - [Example: Using MCP CLI](#example-using-mcp-cli)
    - [Example: Using in Python](#example-using-in-python)
    - [Example: LangChain Integration](#example-langchain-integration)
    - [๐Ÿ“˜ Client Configuration Reference](#-client-configuration-reference)
  - [โš™๏ธ Configuration](#๏ธ-configuration)
    - [Example `.env`](#example-env)
  - [๐Ÿณ Docker Integration](#-docker-integration)
    - [๐Ÿ 1. `uv` or dependency install fails](#-1-uv-or-dependency-install-fails)
    - [โšก 2. Server exits immediately](#-2-server-exits-immediately)
    - [๐ŸŒ 3. Port in use](#-3-port-in-use)
    - [๐Ÿ” 4. Browser fails](#-4-browser-fails)
  - [๐Ÿงช Testing](#-testing)
  - [๐Ÿ“Š Roadmap](#-roadmap)
  - [๐Ÿค Contributing](#-contributing)
  - [๐Ÿ“œ License](#-license)

</details>

---

## ๐Ÿš€ Features

* โœ… Retrieve **economic calendar events** by time period (`today`, `this_week`, `custom`, etc.)
* โœ… Access via **MCP resources** (for subscription-style access)
* โœ… Access via **MCP tools** (direct calls from clients/agents)
* โœ… JSON-first responses for easy integration
* โšก Integrates with LangChain, n8n, or any MCP-compatible client

---

### ๐Ÿ“Œ Development Status

This project is **actively developed**.
The **core functionality is stable** (retrieving ForexFactory economic calendar events via MCP tools and resources), but we are still:

* Expanding features (prompts, deployment options)
* Improving documentation and examples

We welcome feedback and contributions while we continue building out the ecosystem.

---

<details>
<summary>๐Ÿ“‚ <strong>Project Structure (click to expand)</strong></summary>

```
forexfactory-mcp/
โ”‚โ”€โ”€ src/forexfactory_mcp/   # Main package
โ”‚   โ”œโ”€โ”€ models/             # Schemas & enums
โ”‚   โ”œโ”€โ”€ services/           # Scraper + data normalization
โ”‚   โ”œโ”€โ”€ tools/              # MCP tool definitions
โ”‚   โ”œโ”€โ”€ resources/          # MCP resource definitions
โ”‚   โ”œโ”€โ”€ prompts/            # Prompt templates (optional MCP prompts)
โ”‚   โ”œโ”€โ”€ utils/              # Shared helpers & config
โ”‚   โ””โ”€โ”€ server.py           # FastMCP server entrypoint
โ”‚
โ”‚โ”€โ”€ examples/               # Example clients
โ”‚โ”€โ”€ tests/                  # Unit tests
โ”‚โ”€โ”€ .env.example            # Copy to .env for config
โ”‚โ”€โ”€ pyproject.toml          # Dependencies & metadata
โ”‚โ”€โ”€ README.md               # Documentation
โ”‚โ”€โ”€ .python-version         # Python version pin (3.12)
```

*(See repo for full details โ€” this is a high-level layout for contributors.)*

</details>

---

## ๐Ÿ”ง Installation

### Requirements

* Python 3.12+
* [uv](https://github.com/astral-sh/uv) or pip
* A modern terminal or MCP-compatible client

### Setup

```bash
# Clone repo
git clone https://github.com/kjpou1/forexfactory-mcp.git
cd forexfactory-mcp

# Install dependencies
uv sync   # or: pip install -e .

# Install Playwright browser binaries
uv run playwright install chromium
# or, if using pip/venv:
playwright install chromium

# Copy example environment and adjust if needed
cp .env.example .env
```

---

## โ–ถ๏ธ Usage

### โšก Quickstart

Start the server with default settings (`stdio` transport):

```bash
uv run ffcal-server
```

Run with HTTP transport:

```bash
uv run ffcal-server --transport http --host 0.0.0.0 --port 8080
```

---

### SSE transport (โš ๏ธ deprecated)

```bash
uv run ffcal-server --transport sse --host 127.0.0.1 --port 8001
```

---

### Environment variable defaults

```env
MCP_TRANSPORT=http
MCP_HOST=0.0.0.0
MCP_PORT=8080
```

---

## ๐Ÿท๏ธ Namespace

Default namespace:

```
ffcal
```

Override via `.env`:

```env
NAMESPACE=ffcal
```

---

## ๐Ÿ“ฆ Resources

| Name           | Path                                 | Description          |
| -------------- | ------------------------------------ | -------------------- |
| `events_today` | `ffcal://events/today`               | Today's events       |
| `events_week`  | `ffcal://events/week`                | All events this week |
| `events_range` | `ffcal://events/range/{start}/{end}` | Custom date range    |

---

## ๐Ÿ› ๏ธ Tools

| Name                        | Type | Description                        |
| --------------------------- | ---- | ---------------------------------- |
| `ffcal_get_calendar_events` | Tool | Retrieve events for a given period |

Supported values:

```
today, tomorrow, yesterday, this_week, next_week, last_week, this_month, next_month, last_month, custom
```

---

## ๐Ÿ“ Prompts

| Name                        | Description                      |
| --------------------------- | -------------------------------- |
| `ffcal_daily_prep`          | Trader prep note for today       |
| `ffcal_weekly_outlook`      | Weekly macro event summary       |
| `ffcal_volatility_grid`     | Weekly event-risk heatmap        |
| `ffcal_trade_map_scenarios` | Scenario map for specific events |

---

### ๐Ÿงฉ Prompt Styles

All prompts support a **`style`** parameter to control formatting.
Default:

```python
style: str = "bullet points"
```

See the [Output Style Reference](docs/OUTPUT_STYLE_REFERENCE.md) for available formats.

---

## ๐Ÿ’ป Client Examples

### Example: Using MCP CLI

```bash
mcp call ffcal:get_calendar_events time_period=this_week
```

### Example: Using in Python

```python
from mcp.client.session import Session
async with Session("ws://localhost:8000") as session:
    result = await session.call_tool("ffcal:get_calendar_events", {"time_period": "today"})
    print(result)
```

### Example: LangChain Integration

```python
from langchain.agents import initialize_agent
from langchain_mcp import MCPToolkit

toolkit = MCPToolkit.from_server_url("ws://localhost:8000", namespace="ffcal")
agent = initialize_agent(toolkit.tools)
response = agent.run("What are today's USD-related high impact events?")
print(response)
```

---

### ๐Ÿ“˜ Client Configuration Reference

> [๐Ÿ“– docs/CLIENT_CONFIG_REFERENCE.md](docs/CLIENT_CONFIG_REFERENCE.md)

Includes:

* โœ… Example configs for **Claude Desktop (local + Docker)**
* ๐Ÿณ Docker build and setup
* ๐Ÿงฉ VS Code MCP integration (future)
* ๐Ÿงช Testing + troubleshooting checklist
* ๐Ÿ” Inspector setup for visual debugging

---

<details>
<summary>โš™๏ธ <strong>Configuration Reference (click to expand)</strong></summary>

## โš™๏ธ Configuration

| Variable             | Default      | Description                             |
| -------------------- | ------------ | --------------------------------------- |
| `NAMESPACE`          | `ffcal`      | Namespace prefix                        |
| `MCP_TRANSPORT`      | `stdio`      | Transport type (`stdio`, `http`, `sse`) |
| `MCP_HOST`           | `127.0.0.1`  | Host for HTTP/SSE                       |
| `MCP_PORT`           | `8000`       | Port for HTTP/SSE                       |
| `SCRAPER_TIMEOUT_MS` | `5000`       | Playwright timeout                      |
| `LOCAL_TIMEZONE`     | System local | Timezone override                       |

---

### Example `.env`

```env
MCP_TRANSPORT=http
MCP_HOST=0.0.0.0
MCP_PORT=8080
NAMESPACE=ffcal
```

</details>

---

<details>
<summary>๐Ÿณ <strong>Docker Integration (click to expand)</strong></summary>

## ๐Ÿณ Docker Integration

Supports both **stdio** (default) and **HTTP/SSE**.

```bash
docker compose build
docker compose up forexfactory_mcp
```

Runs MCP server and exposes it on **port 8000**.

</details>

---

<details>
<summary>๐Ÿงฐ <strong>Makefile Targets (click to expand)</strong></summary>

| Target           | Description               |
| ---------------- | ------------------------- |
| `make build`     | Build Docker image        |
| `make run-http`  | Run server in HTTP mode   |
| `make run-stdio` | Run in stdio mode         |
| `make dev-http`  | Inspect via MCP Inspector |
| `make stop`      | Stop containers           |

</details>

---

<details>
<summary>๐Ÿงฉ <strong>Troubleshooting Docker (click to expand)</strong></summary>

### ๐Ÿ 1. `uv` or dependency install fails

Run:

```bash
docker compose build --no-cache forexfactory_mcp
```

### โšก 2. Server exits immediately

Switch to:

```bash
make run-http
```

### ๐ŸŒ 3. Port in use

Change port:

```bash
docker compose run --rm -e MCP_PORT=8080 forexfactory_mcp
```

### ๐Ÿ” 4. Browser fails

Install Chromium:

```bash
docker compose run forexfactory_mcp playwright install chromium
```

</details>

---

<details>
<summary>๐Ÿงช <strong>Testing & Roadmap (click to expand)</strong></summary>

## ๐Ÿงช Testing

```bash
pytest -v
```

## ๐Ÿ“Š Roadmap

* [ ] Event filters by **currency** and **impact**
* [ ] Historical backfill
* [ ] MCP prompt expansions
* [ ] Cloud-ready deployment

</details>

---

## ๐Ÿค Contributing

1. Fork the repo
2. Create a feature branch
3. Commit with a clear message
4. Push and open a PR

---

## ๐Ÿ“œ License

MIT License โ€“ see [LICENSE](./LICENSE) for details.

TDQS

B3.1/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear and distinct purpose: retrieving ForexFactory calendar events.

Naming Consistency5/5

Since there is only one tool, naming consistency is inherently perfect. The tool name 'my-ffcal_get_calendar_events' follows a verb_noun pattern, which is consistent with itself.

Tool Count2/5

A single tool is generally too few for a server's purpose, as it limits functionality and scope. For a ForexFactory calendar server, one might expect additional tools for filtering, sorting, or managing events, making this count feel thin and under-scoped.

Completeness2/5

The server only provides retrieval of calendar events, with no tools for creating, updating, deleting, or otherwise managing events. This is a significant gap, as it lacks basic CRUD operations and limits the server's utility to read-only access.

Maintenance

ActivityInactive
ResponsivenessSlow