Metadata-Version: 2.4
Name: plainfold-calendars-mcp
Version: 0.1.0
Summary: MCP server: US/NYSE/Fed business days, 9 stock exchange calendars and FX T+2 spot dates for AI assistants. Offline, MIT.
Author-email: Plainfold <plainfoldhq@proton.me>
License-Expression: MIT
Project-URL: Homepage, https://github.com/plainfoldhq/plainfold-calendars-mcp
Project-URL: Source, https://github.com/plainfoldhq/plainfold-calendars-mcp
Project-URL: Issues, https://github.com/plainfoldhq/plainfold-calendars-mcp/issues
Keywords: mcp,model context protocol,business days,market holidays,trading calendar,fx spot date,nyse,claude
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<3,>=2.3.0
Requires-Dist: usbizdays==1.0.1
Requires-Dist: exchange-trading-days==0.1.1
Requires-Dist: fx-spot-dates==0.1.1
Dynamic: license-file

# plainfold-calendars-mcp

An MCP (Model Context Protocol) server that answers business-day questions for AI assistants: is a date a trading day, what is the next business day, how many business days between two dates, which holidays fall in a year, and what is the T+2 FX spot date of a currency pair. It runs on your machine over stdio, needs no network and no API key, and is MIT licensed.

It adds no calendar data of its own. It is a thin layer over three verified, dependency-free Plainfold packages, pinned to exact versions:

- [`usbizdays`](https://pypi.org/project/usbizdays/) 1.0.1: US federal, NYSE and Federal Reserve calendars.
- [`exchange-trading-days`](https://pypi.org/project/exchange-trading-days/) 0.1.1: 9 stock exchanges, with early closes.
- [`fx-spot-dates`](https://pypi.org/project/fx-spot-dates/) 0.1.1: settlement calendars for 6 currencies and T+2 spot dates.

<!-- mcp-name: io.github.plainfoldhq/plainfold-calendars-mcp -->

## Install

```
pip install plainfold-calendars-mcp
# or run it without installing:
uvx plainfold-calendars-mcp
```

Python 3.10 or newer. The server speaks stdio; the console script is `plainfold-calendars-mcp` (also `python -m plainfold_calendars_mcp`).

### Claude Code

```
claude mcp add plainfold-calendars -- uvx plainfold-calendars-mcp
```

### Claude Desktop

Add this to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "plainfold-calendars": {
      "command": "uvx",
      "args": ["plainfold-calendars-mcp"]
    }
  }
}
```

### Any other MCP client

Run `uvx plainfold-calendars-mcp` (or `plainfold-calendars-mcp` after `pip install`) as a stdio server. The config shape is the same as above: `command` plus `args`.

## Calendar ids

One scheme, case-insensitive:

| Id | What | Covered years |
|---|---|---|
| `us-federal` | US federal holidays (5 U.S.C. 6103), observed dates | 1971-2050 |
| `nyse` | NYSE trading days incl. early closes and past unscheduled closures (rule-based) | 2000-2050 |
| `fed` | Federal Reserve Banks (Saturday holidays are not moved) | 2000-2050 |
| `XNYS` `XLON` `XTSE` `XETR` `XPAR` `XTKS` `XHKG` `XASX` `XSWX` | NYSE, London, Toronto, Xetra, Euronext Paris, Tokyo, Hong Kong, ASX, SIX Swiss (ISO 10383 MIC) | 2026-2028 |
| `USD` `EUR` `GBP` `JPY` `NZD` | Settlement business days (Fedwire, TARGET2, England and Wales, Japan, New Zealand) | 2026-2028 |
| `AUD` | New South Wales bank holidays | 2028 only (2026 and 2027 are withheld because the sources disagree on one day each) |

`nyse` and `XNYS` are two independent NYSE calendars; use `nyse` outside 2026-2028. `list_calendars` returns the live list.

Outside the covered years the tools return an error, never a guess. The error states the covered years and points to the full 2000-2050 data (`https://plainfoldhq.github.io/business-days/`, `/stock-market-holidays/` or `/fx-settlement-holidays/`).

## Tools

All dates are ISO `YYYY-MM-DD`. Results are plain JSON.

| Tool | Arguments | Returns |
|---|---|---|
| `list_calendars` | none | every id with name and covered years |
| `is_business_day` | `calendar`, `date` | `business_day`, `holiday` name or null, `early_close` ("HH:MM", NYSE and exchanges) or null |
| `add_business_days` | `calendar`, `date`, `n` (\|n\| <= 10000) | `result`, `convention` |
| `business_days_between` | `calendar`, `start`, `end` | `count`, `convention` |
| `next_business_day` | `calendar`, `date` | first business day strictly after `date` |
| `previous_business_day` | `calendar`, `date` | last business day strictly before `date` |
| `holidays` | `calendar`, `year` | `[{date, name}]`, plus `early_closes` for `nyse` and exchanges |
| `fx_spot_date` | `pair` (EURUSD or EUR/USD), `trade_date` | `spot_date`, `convention` |

### Counting conventions

These follow the underlying packages and each result repeats its own convention:

- `add_business_days`: the start date is never counted. `n = 0` returns the date if it is a business day, otherwise the next one. For currencies with `n < 0` the server steps back one business day at a time (the fx package only moves forward).
- `business_days_between` on `us-federal`, `nyse`, `fed` and currencies: start included, end excluded (`start <= d < end`); if end is before start the result is minus the count for `end <= d < start`.
- `business_days_between` on exchanges (MICs): both ends included (`start <= d <= end`), and 0 if start is after end. This is how `exchange-trading-days` counts, and it differs from the US calendars on purpose.
- FX spot (T+2): for pairs with USD, day 1 is the next business day of the non-USD currency and day 2 the next day that is a business day in both. For crosses: two business days of both currencies, then forward to the first day that is also a USD business day. Some banks use other rules; confirm with your counterparty.

## How it was checked

The test suite (`pytest`) drives the real server through the MCP SDK client (in memory and over stdio) and checks every tool, every error path and the coverage errors. It also compares answers with implementations that share no code or data with the packages:

- US calendars, 2000-2050 (federal from 1971): every day against the `holidays` package (`US`, `XNYS`, `XFED`), plus random `add_business_days` and `business_days_between` cases against NumPy `busday_offset` / `busday_count`.
- Exchanges, 2026-2028: every day and thousands of random cases against `exchange_calendars` sessions, closing times and early closes. One known difference is pinned in the tests: when Dec 24 or Dec 31 falls on a weekend, `exchange_calendars` moves ASX's 14:10 early close to the Friday before (2028-12-22 and 2028-12-29); `exchange-trading-days` keeps normal hours on those Fridays, following ASX's 2022 notice that normal hours apply from 2022 on. Check the ASX notice for those dates.
- Currencies, 2026-2028: every day against the `holidays` package and QuantLib, and random add, count and spot-date cases against QuantLib calendars.

The independent checks need Python 3.11 or newer; on 3.10 they are skipped and the server tests still run. Test dependencies are pinned in `requirements-test.txt`.

## Full data (paid)

The server covers what the free packages cover. The full 2000-2050 datasets, as CSV, JSON, SQLite and .ics files, are sold separately. Polar is the merchant of record.

- [US federal, NYSE and Fed calendar 1971/2000-2050](https://buy.polar.sh/polar_cl_oW9ytw22HhxLxOnke3W8ibcgTXepc2hYuAEyl1gTqqB?utm_source=readme&utm_medium=readme&utm_campaign=B&utm_content=plainfold-calendars-mcp) ($15)
- [World stock exchange holidays and trading hours, 24 exchanges 2000-2050](https://buy.polar.sh/polar_cl_8VwWMpQhsLCYXsPRdkmYGjbJzuzlHQB9Ul3GC3dlJW7?utm_source=readme&utm_medium=readme&utm_campaign=G&utm_content=plainfold-calendars-mcp) ($15)
- [Currency settlement holidays and FX spot dates 2000-2050](https://buy.polar.sh/polar_cl_9Rkaup8QpzW7cYaFe9nRx0AEiUSxVLMzYyU1K23uuVP?utm_source=readme&utm_medium=readme&utm_campaign=Q&utm_content=plainfold-calendars-mcp) ($19)
- [All-Access: every Plainfold data pack, yearly](https://buy.polar.sh/polar_cl_xydfuofU72fdp6xSOHFtihAuniUFagYOwR9zf2M03Gl?utm_source=readme&utm_medium=readme&utm_campaign=ALLACCESS&utm_content=plainfold-calendars-mcp) ($49/year)

## Limits

Not financial or legal advice. Exchanges can add unscheduled closures and change hours, and future dates follow standing rules. Check the exchange or central bank notice before trading or settlement use. The server never touches the network.

Not affiliated with Anthropic or the MCP project. Plainfold is an AI-run business; this package was written and tested by AI agents.

## License

MIT, Copyright (c) 2026 Plainfold. Issues: https://github.com/plainfoldhq/plainfold-calendars-mcp/issues
