mstodo-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mstodo_mcp-0.1.0/PKG-INFO +184 -0
- mstodo_mcp-0.1.0/README.md +168 -0
- mstodo_mcp-0.1.0/pyproject.toml +51 -0
- mstodo_mcp-0.1.0/pyproject.toml.orig +41 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/__init__.py +1 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/account.py +116 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/auth.py +200 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/bodies.py +140 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/cli.py +99 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/config.py +114 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/copies.py +93 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/dates.py +164 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/delete_tools.py +82 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/deletes.py +108 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/graph.py +156 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/ids.py +143 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/items.py +133 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/list_writes.py +59 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/model.py +195 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/moves.py +191 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/query.py +134 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/render.py +200 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/repeat.py +110 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/report.py +189 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/schedule.py +123 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/schedule_report.py +93 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/server.py +141 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/step_tools.py +103 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/step_writes.py +96 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/steps.py +142 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/todo.py +176 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/tools.py +176 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/write_tools.py +186 -0
- mstodo_mcp-0.1.0/src/mstodo_mcp/writes.py +190 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mstodo-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Microsoft To Do MCP server built for agents: cross-list queries, bulk edits, short task IDs
|
|
5
|
+
Author: GEORGE-Ta
|
|
6
|
+
Author-email: GEORGE-Ta <gaivrt@outlook.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Requires-Dist: httpx>=0.29.0
|
|
9
|
+
Requires-Dist: mcp>=2.3,<3
|
|
10
|
+
Requires-Dist: msal>=1.39.0
|
|
11
|
+
Requires-Dist: msal-extensions>=1.3.1
|
|
12
|
+
Requires-Dist: pydantic>=2.14.4
|
|
13
|
+
Requires-Dist: tzlocal>=5.4.5
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# mstodo-mcp
|
|
18
|
+
|
|
19
|
+
[中文说明](README.zh-CN.md)
|
|
20
|
+
|
|
21
|
+
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.
|
|
22
|
+
|
|
23
|
+
> Built by Claude Fable 5.2 (max effort) with Claude Code.
|
|
24
|
+
|
|
25
|
+
## Why another To Do server
|
|
26
|
+
|
|
27
|
+
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:
|
|
28
|
+
|
|
29
|
+
- **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.
|
|
30
|
+
- **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.
|
|
31
|
+
- **Short task handles.** Every task gets a five-character handle. No 150-character Graph ids in the conversation.
|
|
32
|
+
- **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.
|
|
33
|
+
- **Dates in your time zone.** Due dates and reminders are read and shown in your zone, so nothing is off by one day.
|
|
34
|
+
- **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".
|
|
35
|
+
- **Read-only mode.** With `MSTODO_READ_ONLY=1` only the reading tools are registered and only read permission is requested.
|
|
36
|
+
- **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.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- Windows (PowerShell) is the tested platform. Linux works for the HTTP mode described below, with less testing.
|
|
41
|
+
- [uv](https://docs.astral.sh/uv/). It installs Python 3.12 for you.
|
|
42
|
+
- A client ID, which you get once in the next step.
|
|
43
|
+
|
|
44
|
+
## Step 1: register an app and get a client ID
|
|
45
|
+
|
|
46
|
+
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.
|
|
47
|
+
|
|
48
|
+
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`.
|
|
49
|
+
|
|
50
|
+
1. Open <https://portal.azure.com>, search for `App registrations`, choose **New registration**.
|
|
51
|
+
2. Give it any name, for example `mstodo-mcp`.
|
|
52
|
+
3. For supported account types choose **Any Entra ID Tenant + Personal Microsoft accounts**.
|
|
53
|
+
4. Choose **Register** and copy the **Application (client) ID** from the overview page.
|
|
54
|
+
5. Under **Authentication** → **Add a platform** → **Mobile and desktop applications**, enter the redirect URI `http://localhost`.
|
|
55
|
+
6. On the same page, under **Advanced settings**, set **Allow public client flows** to Yes and save.
|
|
56
|
+
|
|
57
|
+
Do not create a client secret, and do not add API permissions.
|
|
58
|
+
|
|
59
|
+
## Step 2: install and sign in
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
git clone https://github.com/gaivrt/mstodo-mcp
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
cd mstodo-mcp; uv sync
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Sign in. A browser window opens; the client ID is remembered for later runs:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
uv run mstodo-mcp login --client-id <client-id>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
## Step 3: add it to an MCP client
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"mcpServers": {
|
|
82
|
+
"mstodo": {
|
|
83
|
+
"command": "uv",
|
|
84
|
+
"args": ["--directory", "C:/path/to/mstodo-mcp", "run", "mstodo-mcp"]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
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.
|
|
91
|
+
|
|
92
|
+
## Remote use (HTTP mode)
|
|
93
|
+
|
|
94
|
+
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:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
mstodo-mcp serve --http 8765
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
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`):
|
|
101
|
+
|
|
102
|
+
```nginx
|
|
103
|
+
location ^~ /mstodo-<random>/ {
|
|
104
|
+
proxy_pass http://127.0.0.1:8765/;
|
|
105
|
+
proxy_set_header Host 127.0.0.1:8765;
|
|
106
|
+
proxy_http_version 1.1;
|
|
107
|
+
proxy_buffering off;
|
|
108
|
+
access_log off;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
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.
|
|
113
|
+
|
|
114
|
+
On the server:
|
|
115
|
+
|
|
116
|
+
- Sign in with `mstodo-mcp login --client-id <client-id> --device`.
|
|
117
|
+
- 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.
|
|
118
|
+
- Set `MSTODO_TIMEZONE`; the server's own zone is probably not yours.
|
|
119
|
+
- Use the same `MSTODO_DATA_DIR` for `login` and for the running server.
|
|
120
|
+
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
## Tools
|
|
124
|
+
|
|
125
|
+
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).
|
|
126
|
+
|
|
127
|
+
| Tool | What it does |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `list_lists` | Every list, marked when it is the default list, the flagged-emails list, shared, or owned by someone else |
|
|
130
|
+
| `find_tasks` | Find tasks across all lists or in one. `view`: `open`, `today`, `overdue`, `upcoming`, `important`, `completed`; plus `query` and `category`. Paged |
|
|
131
|
+
| `get_tasks` | Everything about up to 50 tasks: the full note, numbered steps, links, attachments, timestamps |
|
|
132
|
+
| `create_tasks` | Up to 50 tasks, each with its own list, note, due date, reminder, importance, categories, steps, links and repetition |
|
|
133
|
+
| `update_tasks` | Up to 50 tasks; only the given fields change |
|
|
134
|
+
| `complete_tasks` | Up to 50 tasks; `reopen=true` reopens them. A repeating task moves on to its next due date |
|
|
135
|
+
| `move_tasks` | Up to 50 tasks to another list: copy, check, then delete the original. The handle keeps naming the task |
|
|
136
|
+
| `delete_tasks` | Up to 50 tasks, permanently |
|
|
137
|
+
| `edit_steps` | Add, check, uncheck, rename and remove the steps of one task in one call |
|
|
138
|
+
| `create_list`, `rename_list`, `delete_list` | Manage lists. Deleting a list that holds tasks or is shared needs `force=true` |
|
|
139
|
+
| `account` | `status`, `login`, `logout` |
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
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.
|
|
144
|
+
|
|
145
|
+
## Settings
|
|
146
|
+
|
|
147
|
+
All optional environment variables.
|
|
148
|
+
|
|
149
|
+
| Variable | Meaning | Default |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| `MSTODO_TIMEZONE` | Your IANA time zone, e.g. `Asia/Shanghai` | the system's |
|
|
152
|
+
| `MSTODO_READ_ONLY` | Register only the reading tools and request only `Tasks.Read` | off |
|
|
153
|
+
| `MSTODO_CLIENT_ID` | Client ID; wins over the remembered one | the remembered one |
|
|
154
|
+
| `MSTODO_DATA_DIR` | Where the client ID, the token cache and the handle table live | `%LOCALAPPDATA%\mstodo-mcp` on Windows |
|
|
155
|
+
| `MSTODO_AUTHORITY` | Sign-in endpoint | `https://login.microsoftonline.com/common` |
|
|
156
|
+
| `MSTODO_ALLOW_PLAINTEXT_CACHE` | Allow an unencrypted token file where no keyring exists | off |
|
|
157
|
+
|
|
158
|
+
## Known limits
|
|
159
|
+
|
|
160
|
+
- **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.
|
|
161
|
+
- **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.
|
|
162
|
+
- **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.
|
|
163
|
+
- **Attachments are read-only.** They are listed, not uploaded or downloaded.
|
|
164
|
+
- **The completed view has a window.** 7 days by default; widen it with `days`.
|
|
165
|
+
- **Deleting is permanent.**
|
|
166
|
+
- **Handles are local.** Another machine or data directory gives the same task another handle.
|
|
167
|
+
- **HTTP mode has no sign-in of its own.** See "Remote use".
|
|
168
|
+
- **Tested on personal Microsoft accounts only.**
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
```powershell
|
|
173
|
+
uv run pytest
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```powershell
|
|
177
|
+
uv run ruff check
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
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.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# mstodo-mcp
|
|
2
|
+
|
|
3
|
+
[中文说明](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
> Built by Claude Fable 5.2 (max effort) with Claude Code.
|
|
8
|
+
|
|
9
|
+
## Why another To Do server
|
|
10
|
+
|
|
11
|
+
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:
|
|
12
|
+
|
|
13
|
+
- **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.
|
|
14
|
+
- **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.
|
|
15
|
+
- **Short task handles.** Every task gets a five-character handle. No 150-character Graph ids in the conversation.
|
|
16
|
+
- **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.
|
|
17
|
+
- **Dates in your time zone.** Due dates and reminders are read and shown in your zone, so nothing is off by one day.
|
|
18
|
+
- **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".
|
|
19
|
+
- **Read-only mode.** With `MSTODO_READ_ONLY=1` only the reading tools are registered and only read permission is requested.
|
|
20
|
+
- **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.
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- Windows (PowerShell) is the tested platform. Linux works for the HTTP mode described below, with less testing.
|
|
25
|
+
- [uv](https://docs.astral.sh/uv/). It installs Python 3.12 for you.
|
|
26
|
+
- A client ID, which you get once in the next step.
|
|
27
|
+
|
|
28
|
+
## Step 1: register an app and get a client ID
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
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`.
|
|
33
|
+
|
|
34
|
+
1. Open <https://portal.azure.com>, search for `App registrations`, choose **New registration**.
|
|
35
|
+
2. Give it any name, for example `mstodo-mcp`.
|
|
36
|
+
3. For supported account types choose **Any Entra ID Tenant + Personal Microsoft accounts**.
|
|
37
|
+
4. Choose **Register** and copy the **Application (client) ID** from the overview page.
|
|
38
|
+
5. Under **Authentication** → **Add a platform** → **Mobile and desktop applications**, enter the redirect URI `http://localhost`.
|
|
39
|
+
6. On the same page, under **Advanced settings**, set **Allow public client flows** to Yes and save.
|
|
40
|
+
|
|
41
|
+
Do not create a client secret, and do not add API permissions.
|
|
42
|
+
|
|
43
|
+
## Step 2: install and sign in
|
|
44
|
+
|
|
45
|
+
```powershell
|
|
46
|
+
git clone https://github.com/gaivrt/mstodo-mcp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
cd mstodo-mcp; uv sync
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Sign in. A browser window opens; the client ID is remembered for later runs:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
uv run mstodo-mcp login --client-id <client-id>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
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.
|
|
60
|
+
|
|
61
|
+
## Step 3: add it to an MCP client
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"mcpServers": {
|
|
66
|
+
"mstodo": {
|
|
67
|
+
"command": "uv",
|
|
68
|
+
"args": ["--directory", "C:/path/to/mstodo-mcp", "run", "mstodo-mcp"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
## Remote use (HTTP mode)
|
|
77
|
+
|
|
78
|
+
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:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
mstodo-mcp serve --http 8765
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
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`):
|
|
85
|
+
|
|
86
|
+
```nginx
|
|
87
|
+
location ^~ /mstodo-<random>/ {
|
|
88
|
+
proxy_pass http://127.0.0.1:8765/;
|
|
89
|
+
proxy_set_header Host 127.0.0.1:8765;
|
|
90
|
+
proxy_http_version 1.1;
|
|
91
|
+
proxy_buffering off;
|
|
92
|
+
access_log off;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
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.
|
|
97
|
+
|
|
98
|
+
On the server:
|
|
99
|
+
|
|
100
|
+
- Sign in with `mstodo-mcp login --client-id <client-id> --device`.
|
|
101
|
+
- 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.
|
|
102
|
+
- Set `MSTODO_TIMEZONE`; the server's own zone is probably not yours.
|
|
103
|
+
- Use the same `MSTODO_DATA_DIR` for `login` and for the running server.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
## Tools
|
|
108
|
+
|
|
109
|
+
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).
|
|
110
|
+
|
|
111
|
+
| Tool | What it does |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `list_lists` | Every list, marked when it is the default list, the flagged-emails list, shared, or owned by someone else |
|
|
114
|
+
| `find_tasks` | Find tasks across all lists or in one. `view`: `open`, `today`, `overdue`, `upcoming`, `important`, `completed`; plus `query` and `category`. Paged |
|
|
115
|
+
| `get_tasks` | Everything about up to 50 tasks: the full note, numbered steps, links, attachments, timestamps |
|
|
116
|
+
| `create_tasks` | Up to 50 tasks, each with its own list, note, due date, reminder, importance, categories, steps, links and repetition |
|
|
117
|
+
| `update_tasks` | Up to 50 tasks; only the given fields change |
|
|
118
|
+
| `complete_tasks` | Up to 50 tasks; `reopen=true` reopens them. A repeating task moves on to its next due date |
|
|
119
|
+
| `move_tasks` | Up to 50 tasks to another list: copy, check, then delete the original. The handle keeps naming the task |
|
|
120
|
+
| `delete_tasks` | Up to 50 tasks, permanently |
|
|
121
|
+
| `edit_steps` | Add, check, uncheck, rename and remove the steps of one task in one call |
|
|
122
|
+
| `create_list`, `rename_list`, `delete_list` | Manage lists. Deleting a list that holds tasks or is shared needs `force=true` |
|
|
123
|
+
| `account` | `status`, `login`, `logout` |
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
## Settings
|
|
130
|
+
|
|
131
|
+
All optional environment variables.
|
|
132
|
+
|
|
133
|
+
| Variable | Meaning | Default |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| `MSTODO_TIMEZONE` | Your IANA time zone, e.g. `Asia/Shanghai` | the system's |
|
|
136
|
+
| `MSTODO_READ_ONLY` | Register only the reading tools and request only `Tasks.Read` | off |
|
|
137
|
+
| `MSTODO_CLIENT_ID` | Client ID; wins over the remembered one | the remembered one |
|
|
138
|
+
| `MSTODO_DATA_DIR` | Where the client ID, the token cache and the handle table live | `%LOCALAPPDATA%\mstodo-mcp` on Windows |
|
|
139
|
+
| `MSTODO_AUTHORITY` | Sign-in endpoint | `https://login.microsoftonline.com/common` |
|
|
140
|
+
| `MSTODO_ALLOW_PLAINTEXT_CACHE` | Allow an unencrypted token file where no keyring exists | off |
|
|
141
|
+
|
|
142
|
+
## Known limits
|
|
143
|
+
|
|
144
|
+
- **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.
|
|
145
|
+
- **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.
|
|
146
|
+
- **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.
|
|
147
|
+
- **Attachments are read-only.** They are listed, not uploaded or downloaded.
|
|
148
|
+
- **The completed view has a window.** 7 days by default; widen it with `days`.
|
|
149
|
+
- **Deleting is permanent.**
|
|
150
|
+
- **Handles are local.** Another machine or data directory gives the same task another handle.
|
|
151
|
+
- **HTTP mode has no sign-in of its own.** See "Remote use".
|
|
152
|
+
- **Tested on personal Microsoft accounts only.**
|
|
153
|
+
|
|
154
|
+
## Development
|
|
155
|
+
|
|
156
|
+
```powershell
|
|
157
|
+
uv run pytest
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```powershell
|
|
161
|
+
uv run ruff check
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
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.
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mstodo-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Microsoft To Do MCP server built for agents: cross-list queries, bulk edits, short task IDs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.12"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"httpx>=0.29.0",
|
|
10
|
+
"mcp>=2.3,<3",
|
|
11
|
+
"msal>=1.39.0",
|
|
12
|
+
"msal-extensions>=1.3.1",
|
|
13
|
+
"pydantic>=2.14.4",
|
|
14
|
+
"tzlocal>=5.4.5",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[[project.authors]]
|
|
18
|
+
name = "GEORGE-Ta"
|
|
19
|
+
email = "gaivrt@outlook.com"
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
mstodo-mcp = "mstodo_mcp.cli:main"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["uv_build>=0.10.10,<0.11.0"]
|
|
26
|
+
build-backend = "uv_build"
|
|
27
|
+
|
|
28
|
+
[dependency-groups]
|
|
29
|
+
dev = [
|
|
30
|
+
"pytest>=9.2.0",
|
|
31
|
+
"ruff>=0.17.6",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
pythonpath = [
|
|
37
|
+
"tests",
|
|
38
|
+
"scripts",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.ruff]
|
|
42
|
+
line-length = 100
|
|
43
|
+
|
|
44
|
+
[tool.ruff.lint]
|
|
45
|
+
select = [
|
|
46
|
+
"E",
|
|
47
|
+
"F",
|
|
48
|
+
"I",
|
|
49
|
+
"UP",
|
|
50
|
+
"B",
|
|
51
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mstodo-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Microsoft To Do MCP server built for agents: cross-list queries, bulk edits, short task IDs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "GEORGE-Ta", email = "gaivrt@outlook.com" }
|
|
9
|
+
]
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"httpx>=0.29.0",
|
|
13
|
+
"mcp>=2.3,<3",
|
|
14
|
+
"msal>=1.39.0",
|
|
15
|
+
"msal-extensions>=1.3.1",
|
|
16
|
+
"pydantic>=2.14.4",
|
|
17
|
+
"tzlocal>=5.4.5",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
mstodo-mcp = "mstodo_mcp.cli:main"
|
|
22
|
+
|
|
23
|
+
[build-system]
|
|
24
|
+
requires = ["uv_build>=0.10.10,<0.11.0"]
|
|
25
|
+
build-backend = "uv_build"
|
|
26
|
+
|
|
27
|
+
[dependency-groups]
|
|
28
|
+
dev = [
|
|
29
|
+
"pytest>=9.2.0",
|
|
30
|
+
"ruff>=0.17.6",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
testpaths = ["tests"]
|
|
35
|
+
pythonpath = ["tests", "scripts"]
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
line-length = 100
|
|
39
|
+
|
|
40
|
+
[tool.ruff.lint]
|
|
41
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Microsoft To Do MCP server."""
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""The account tool: whose sign-in is stored, signing in through the browser, signing out.
|
|
2
|
+
|
|
3
|
+
It is the one tool that a server in read-only mode has too. Whatever it does, nothing may go
|
|
4
|
+
to stdout, which carries the protocol; like ``auth`` this module only returns texts.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from importlib.metadata import version
|
|
8
|
+
from typing import Annotated, Literal
|
|
9
|
+
|
|
10
|
+
from anyio import to_thread
|
|
11
|
+
from mcp.server.mcpserver import MCPServer
|
|
12
|
+
from mcp.server.mcpserver.exceptions import ToolError
|
|
13
|
+
from pydantic import Field
|
|
14
|
+
|
|
15
|
+
from mstodo_mcp.auth import AuthError
|
|
16
|
+
from mstodo_mcp.config import Config
|
|
17
|
+
from mstodo_mcp.todo import Todo
|
|
18
|
+
from mstodo_mcp.tools import reported
|
|
19
|
+
from mstodo_mcp.write_tools import WRITE
|
|
20
|
+
|
|
21
|
+
ACCOUNT = (
|
|
22
|
+
"The Microsoft account this server works with. status (the default) says for which account "
|
|
23
|
+
"a sign-in is stored, without checking that it still works, the time zone that dates and "
|
|
24
|
+
"times are given in, whether the server is read-only, and its version. login opens a "
|
|
25
|
+
"browser window on the computer this server runs on and waits up to three minutes for the "
|
|
26
|
+
"user to sign in there: tell the user to look for that window. Use it when a tool answers "
|
|
27
|
+
'"Not signed in". logout signs the account out. After a logout, and after a login as '
|
|
28
|
+
"another account, the handles from earlier calls no longer work: run find_tasks again."
|
|
29
|
+
)
|
|
30
|
+
STORED = ( # all that status knows without a request: the sign-in may have stopped working
|
|
31
|
+
"A sign-in is stored for {}. No request was made to check it: if it no longer works, the "
|
|
32
|
+
'task tools answer "Not signed in".'
|
|
33
|
+
)
|
|
34
|
+
NO_CLIENT_ID = (
|
|
35
|
+
"no client ID is configured. Ask the user to run `mstodo-mcp login --client-id <ID>` once "
|
|
36
|
+
"in a terminal, <ID> being the Application (client) ID of their app registration in the "
|
|
37
|
+
"Azure portal, and to restart this server afterwards."
|
|
38
|
+
)
|
|
39
|
+
HOW_TO_SIGN_IN = (
|
|
40
|
+
'To sign in, call account with action="login", which opens a browser window on the '
|
|
41
|
+
"computer this server runs on, or ask the user to run `mstodo-mcp login` in a terminal."
|
|
42
|
+
)
|
|
43
|
+
OR_ELSE = (
|
|
44
|
+
'Call account with action="login" again to retry, or ask the user to run '
|
|
45
|
+
"`mstodo-mcp login` in a terminal."
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def add_account_tool(server: MCPServer, config: Config, auth, todo: Todo) -> None:
|
|
50
|
+
"""Register the account tool for the sign-in that ``auth`` holds."""
|
|
51
|
+
|
|
52
|
+
@server.tool(
|
|
53
|
+
title="Account and sign-in",
|
|
54
|
+
description=ACCOUNT,
|
|
55
|
+
annotations=WRITE, # not read-only: it changes who is signed in
|
|
56
|
+
structured_output=False,
|
|
57
|
+
)
|
|
58
|
+
async def account(
|
|
59
|
+
action: Annotated[
|
|
60
|
+
Literal["status", "login", "logout"],
|
|
61
|
+
Field(description="What to do: status, login or logout."),
|
|
62
|
+
] = "status",
|
|
63
|
+
) -> str:
|
|
64
|
+
if action == "login":
|
|
65
|
+
return await _login(config, auth, todo)
|
|
66
|
+
if action == "logout":
|
|
67
|
+
return await _logout(config, auth, todo)
|
|
68
|
+
return await _status(config, auth, todo)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def _status(config: Config, auth, todo: Todo) -> str:
|
|
72
|
+
"""Whose sign-in is stored and how this server is set up; nothing is asked of Graph."""
|
|
73
|
+
if not config.client_id:
|
|
74
|
+
who = f"Not signed in: {NO_CLIENT_ID}"
|
|
75
|
+
else:
|
|
76
|
+
try:
|
|
77
|
+
name = await to_thread.run_sync(auth.username)
|
|
78
|
+
except AuthError as error:
|
|
79
|
+
who = f"Could not tell who is signed in: {error}"
|
|
80
|
+
else:
|
|
81
|
+
who = STORED.format(name) if name else f"Not signed in. {HOW_TO_SIGN_IN}"
|
|
82
|
+
mode = "read and write"
|
|
83
|
+
if config.read_only:
|
|
84
|
+
mode = "read-only (this server cannot change lists or tasks)"
|
|
85
|
+
return "\n".join(
|
|
86
|
+
[who, f"Time zone: {todo.zone.key}", f"Mode: {mode}", f"Version: {version('mstodo-mcp')}"]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
async def _login(config: Config, auth, todo: Todo) -> str:
|
|
91
|
+
"""Sign in through the browser; the wait for the user is in a worker thread."""
|
|
92
|
+
if not config.client_id:
|
|
93
|
+
raise ToolError(f"Cannot sign in: {NO_CLIENT_ID}")
|
|
94
|
+
|
|
95
|
+
def sign_in() -> tuple[str | None, str]:
|
|
96
|
+
before = auth.username()
|
|
97
|
+
return before, auth.login_interactive()
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
before, name = await to_thread.run_sync(sign_in)
|
|
101
|
+
except AuthError as error:
|
|
102
|
+
raise ToolError(f"{error}\n{OR_ELSE}") from error
|
|
103
|
+
# Nothing is awaited between the sign-in and this, so it also runs when the client has
|
|
104
|
+
# given up on the call in the meantime.
|
|
105
|
+
if name != before:
|
|
106
|
+
todo.ids.clear() # the handles belong to another account, or to nobody known
|
|
107
|
+
return f"Signed in as {name}."
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
async def _logout(config: Config, auth, todo: Todo) -> str:
|
|
111
|
+
"""Sign out, and forget the handles: they belong to the account that was signed in."""
|
|
112
|
+
with reported():
|
|
113
|
+
# Without a client ID nobody can be signed in, and Auth has nothing to ask.
|
|
114
|
+
signed_out = bool(config.client_id) and await to_thread.run_sync(auth.logout)
|
|
115
|
+
todo.ids.clear()
|
|
116
|
+
return f"Signed out. {HOW_TO_SIGN_IN}" if signed_out else "No account was signed in."
|