Metadata-Version: 2.4
Name: mstodo-mcp
Version: 0.1.0
Summary: A Microsoft To Do MCP server built for agents: cross-list queries, bulk edits, short task IDs
Author: GEORGE-Ta
Author-email: GEORGE-Ta <gaivrt@outlook.com>
License-Expression: MIT
Requires-Dist: httpx>=0.29.0
Requires-Dist: mcp>=2.3,<3
Requires-Dist: msal>=1.39.0
Requires-Dist: msal-extensions>=1.3.1
Requires-Dist: pydantic>=2.14.4
Requires-Dist: tzlocal>=5.4.5
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# mstodo-mcp

[中文说明](README.zh-CN.md)

A Microsoft To Do MCP server built for AI agents. It runs locally over stdio by default, can also run over HTTP on your own server, and talks to Microsoft Graph directly. It targets personal Microsoft accounts.

> Built by Claude Fable 5.2 (max effort) with Claude Code.

## Why another To Do server

Most To Do MCP servers expose the Graph API one endpoint per tool, which is hard work for an agent. This one is designed around how agents use it:

- **No client secret.** Sign-in is a public client with PKCE in your own browser. Tokens are stored encrypted by the operating system (DPAPI on Windows), never in plain text by default.
- **Queries across lists.** `find_tasks` searches every list in one call: due today, overdue, upcoming, important, completed, filtered by words or category. The agent does not need to know which list a task is in.
- **Short task handles.** Every task gets a five-character handle. No 150-character Graph ids in the conversation.
- **Batches.** Create, update, complete, delete or move up to 50 tasks in one call, with one result line per task that says what happened and why.
- **Dates in your time zone.** Due dates and reminders are read and shown in your zone, so nothing is off by one day.
- **Repeating tasks done right.** The request shapes were checked against a real account rule by rule. Graph has several undocumented behaviours here; see "Known limits".
- **Read-only mode.** With `MSTODO_READ_ONLY=1` only the reading tools are registered and only read permission is requested.
- **Honest failures.** Every result is one of three kinds: done, not done (the task is as it was, safe to retry), or to check (the request may have arrived, or the task was changed in part). A batch answer starts with a count of each.

## Requirements

- Windows (PowerShell) is the tested platform. Linux works for the HTTP mode described below, with less testing.
- [uv](https://docs.astral.sh/uv/). It installs Python 3.12 for you.
- A client ID, which you get once in the next step.

## Step 1: register an app and get a client ID

Microsoft requires every program that reads your data to be registered. The GUID you get is the client ID. It is not a password: with it alone nobody can read your tasks, because sign-in still happens in your browser. Registration is free.

An app has to live in a directory (tenant). A purely personal account has none, which is what the error "the selected user account does not exist in tenant Microsoft Services" on `entra.microsoft.com` means. Opening an Azure account gives you one; then use `portal.azure.com`.

1. Open <https://portal.azure.com>, search for `App registrations`, choose **New registration**.
2. Give it any name, for example `mstodo-mcp`.
3. For supported account types choose **Any Entra ID Tenant + Personal Microsoft accounts**.
4. Choose **Register** and copy the **Application (client) ID** from the overview page.
5. Under **Authentication** → **Add a platform** → **Mobile and desktop applications**, enter the redirect URI `http://localhost`.
6. On the same page, under **Advanced settings**, set **Allow public client flows** to Yes and save.

Do not create a client secret, and do not add API permissions.

## Step 2: install and sign in

```powershell
git clone https://github.com/gaivrt/mstodo-mcp
```

```powershell
cd mstodo-mcp; uv sync
```

Sign in. A browser window opens; the client ID is remembered for later runs:

```powershell
uv run mstodo-mcp login --client-id <client-id>
```

Other commands: `uv run mstodo-mcp status` shows the account, time zone and mode; `logout` signs out; `login --device` signs in with a device code when the machine has no browser.

## Step 3: add it to an MCP client

```json
{
  "mcpServers": {
    "mstodo": {
      "command": "uv",
      "args": ["--directory", "C:/path/to/mstodo-mcp", "run", "mstodo-mcp"]
    }
  }
}
```

The client starts the server when it needs it. If the first sign-in happened after the client had already started the server, reconnect the server once in the client.

## Remote use (HTTP mode)

The claude.ai web and mobile apps cannot reach a program on your computer; they only connect to MCP servers on the public internet. To use this server there, run it on a machine of your own:

```bash
mstodo-mcp serve --http 8765
```

It listens only on `http://127.0.0.1:8765/mcp` and **has no access control of its own**: whoever can reach it can read, change and permanently delete all your tasks. Never open the port to the internet. Put an HTTPS reverse proxy in front and forward only a path nobody can guess. An nginx example (make `<random>` with `openssl rand -hex 24`):

```nginx
location ^~ /mstodo-<random>/ {
    proxy_pass http://127.0.0.1:8765/;
    proxy_set_header Host 127.0.0.1:8765;
    proxy_http_version 1.1;
    proxy_buffering off;
    access_log off;
}
```

The `Host` line is required: the server only accepts requests addressed to the local machine. `access_log off` keeps the path out of the logs.

On the server:

- Sign in with `mstodo-mcp login --client-id <client-id> --device`.
- A Linux server usually has no system keyring: set `MSTODO_ALLOW_PLAINTEXT_CACHE=1`, and the token is stored in a file only its user can read.
- Set `MSTODO_TIMEZONE`; the server's own zone is probably not yours.
- Use the same `MSTODO_DATA_DIR` for `login` and for the running server.

Then add a custom connector in claude.ai (Settings → Connectors) with the address `https://<your domain>/mstodo-<random>/mcp`. That address is the password: if it leaks, change the random part.

## Tools

13 tools. Tasks are named by the short handle `find_tasks` shows; lists by their display name (case, and emoji or punctuation around the name, do not matter).

| Tool | What it does |
|---|---|
| `list_lists` | Every list, marked when it is the default list, the flagged-emails list, shared, or owned by someone else |
| `find_tasks` | Find tasks across all lists or in one. `view`: `open`, `today`, `overdue`, `upcoming`, `important`, `completed`; plus `query` and `category`. Paged |
| `get_tasks` | Everything about up to 50 tasks: the full note, numbered steps, links, attachments, timestamps |
| `create_tasks` | Up to 50 tasks, each with its own list, note, due date, reminder, importance, categories, steps, links and repetition |
| `update_tasks` | Up to 50 tasks; only the given fields change |
| `complete_tasks` | Up to 50 tasks; `reopen=true` reopens them. A repeating task moves on to its next due date |
| `move_tasks` | Up to 50 tasks to another list: copy, check, then delete the original. The handle keeps naming the task |
| `delete_tasks` | Up to 50 tasks, permanently |
| `edit_steps` | Add, check, uncheck, rename and remove the steps of one task in one call |
| `create_list`, `rename_list`, `delete_list` | Manage lists. Deleting a list that holds tasks or is shared needs `force=true` |
| `account` | `status`, `login`, `logout` |

Each item of a batch succeeds or fails on its own; nothing is rolled back. `create_tasks` and `move_tasks` work in order and stop at a lost connection or sign-in: later items are reported as not attempted.

Dates: `YYYY-MM-DD`, `today`, `tomorrow`, `+3d`; a reminder adds a time, as in `tomorrow 09:00`. Repetition: `daily`, `weekdays`, `weekly on mon, thu`, `monthly`, `yearly`, `every 2 weeks`. In `update_tasks`, `none` removes a due date, a reminder or a repetition.

## Settings

All optional environment variables.

| Variable | Meaning | Default |
|---|---|---|
| `MSTODO_TIMEZONE` | Your IANA time zone, e.g. `Asia/Shanghai` | the system's |
| `MSTODO_READ_ONLY` | Register only the reading tools and request only `Tasks.Read` | off |
| `MSTODO_CLIENT_ID` | Client ID; wins over the remembered one | the remembered one |
| `MSTODO_DATA_DIR` | Where the client ID, the token cache and the handle table live | `%LOCALAPPDATA%\mstodo-mcp` on Windows |
| `MSTODO_AUTHORITY` | Sign-in endpoint | `https://login.microsoftonline.com/common` |
| `MSTODO_ALLOW_PLAINTEXT_CACHE` | Allow an unencrypted token file where no keyring exists | off |

## Known limits

- **Completion dates can be a day off.** Graph records only the UTC date of a completion. The server restores your local date from the task's last-modified time, which is exact unless the task was changed after it was completed.
- **Repeating tasks.** Supported rules are every N days, weeks, months or years, with weekdays for weekly rules, and no end. Graph answers "success" to a direct change of a repeating task's due date or rule and may store another date, so such changes are sent as a clear followed by a write. Rules made by other apps that end, or that follow a pattern such as "the first Friday of every month", can be read, completed and deleted, but not rewritten or moved.
- **A move is a copy and a delete.** Graph cannot move a task. The copy is read back and compared with the original before the original is deleted. Not kept: the creation time, the times steps were checked, the repetition of a completed task, the time left on a reminder that is switched off, data other apps stored on the task, My Day, the position in the list, and whom the task is assigned to. Not moved: tasks with attachments, tasks of the flagged-emails list, and tasks whose copy comes out different, such as one with a formatted (HTML) note. A change another app makes to the original during the move is lost.
- **Attachments are read-only.** They are listed, not uploaded or downloaded.
- **The completed view has a window.** 7 days by default; widen it with `days`.
- **Deleting is permanent.**
- **Handles are local.** Another machine or data directory gives the same task another handle.
- **HTTP mode has no sign-in of its own.** See "Remote use".
- **Tested on personal Microsoft accounts only.**

## Development

```powershell
uv run pytest
```

```powershell
uv run ruff check
```

The tests run against `tests/fake_graph.py`, a fake Graph written from what the real service was observed to do; they touch neither the network nor a real account. `scripts/live_probe.py` is what made those observations: it **does use the signed-in real account**, working only inside a temporary list it creates and deletes.

## License

MIT
