ailist-mcp-server 0.0.0-stage → 0.1.6
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.
- package/README.md +88 -2
- package/dist/index.js +121 -0
- package/package.json +33 -4
package/README.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AIList MCP server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for [AIList](https://ai-list.web.app) household lists. A thin stdio
|
|
4
|
+
wrapper over the AIList REST API v1: every tool call is one REST call to
|
|
5
|
+
`https://ai-list.web.app/api/v1`, authenticated with one household API key
|
|
6
|
+
(`X-API-Key`). The REST API stays the base; this server only calls it.
|
|
7
|
+
|
|
8
|
+
## Tools
|
|
9
|
+
|
|
10
|
+
| Tool | REST call |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `list_lists` | `GET /lists` |
|
|
13
|
+
| `get_list` | `GET /lists/{id}` |
|
|
14
|
+
| `get_item` | `GET /lists/{id}/items/{itemId}` |
|
|
15
|
+
| `list_categories` | `GET /lists/{id}/categories` |
|
|
16
|
+
| `add_item` | `POST /lists/{id}/items` |
|
|
17
|
+
| `update_item` | `PATCH /lists/{id}/items/{itemId}` |
|
|
18
|
+
| `delete_item` | `DELETE /lists/{id}/items/{itemId}` |
|
|
19
|
+
| `move_item` | `POST /lists/{id}/items/{itemId}/move` |
|
|
20
|
+
| `check_item` | `POST /lists/{id}/items/{itemId}/check` |
|
|
21
|
+
| `uncheck_item` | `POST /lists/{id}/items/{itemId}/uncheck` |
|
|
22
|
+
|
|
23
|
+
Items support `quantity`, `unit`, `barcode` (exact product preference),
|
|
24
|
+
`icon` (one emoji as a manual icon choice) and `note` (a short note shown
|
|
25
|
+
under the item, e.g. a preferred brand). Moving an item also teaches the
|
|
26
|
+
household dictionary, like the REST API.
|
|
27
|
+
|
|
28
|
+
## Connect (Claude Code)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
claude mcp add ailist -e AILIST_API_KEY=sl_... -- npx -y ailist-mcp-server
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or add it to your MCP config by hand (`~/.claude.json` for Claude Code,
|
|
35
|
+
Claude Desktop settings for the desktop app):
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"ailist": {
|
|
41
|
+
"command": "npx",
|
|
42
|
+
"args": ["-y", "ailist-mcp-server"],
|
|
43
|
+
"env": {
|
|
44
|
+
"AILIST_API_KEY": "sl_..."
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Get the key in the AIList app: household settings → API keys (owner only).
|
|
52
|
+
The key is shown once when created, and it works only for the household it
|
|
53
|
+
was created in. To point at a local dev server instead of production, set
|
|
54
|
+
`AILIST_BASE_URL` (default `https://ai-list.web.app`).
|
|
55
|
+
|
|
56
|
+
> You can also run it from a local checkout instead (see below).
|
|
57
|
+
|
|
58
|
+
## Run from a local checkout
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cd mcp-server
|
|
62
|
+
npm install
|
|
63
|
+
npm run build
|
|
64
|
+
AILIST_API_KEY=sl_... node dist/index.js
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Claude Code config for the local build:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"mcpServers": {
|
|
72
|
+
"ailist": {
|
|
73
|
+
"command": "node",
|
|
74
|
+
"args": ["/absolute/path/to/mcp-server/dist/index.js"],
|
|
75
|
+
"env": {
|
|
76
|
+
"AILIST_API_KEY": "sl_..."
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Develop
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install
|
|
87
|
+
npm run build # tsc -> dist/
|
|
88
|
+
npm start # node dist/index.js (needs AILIST_API_KEY)
|
|
89
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// AIList MCP server: a thin stdio MCP wrapper over the AIList REST API v1.
|
|
3
|
+
// It makes no decisions of its own — every tool call is one REST call to
|
|
4
|
+
// https://ai-list.web.app/api/v1 (or AILIST_BASE_URL). Auth is one API key
|
|
5
|
+
// (X-API-Key), created in the household settings in the AIList app.
|
|
6
|
+
//
|
|
7
|
+
// Usage:
|
|
8
|
+
// AILIST_API_KEY=sl_... npx -y ailist-mcp-server
|
|
9
|
+
// AILIST_API_KEY=sl_... AILIST_BASE_URL=http://localhost:3000 node dist/index.js
|
|
10
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
function flagValue(name) {
|
|
15
|
+
const i = args.indexOf(name);
|
|
16
|
+
return i >= 0 ? args[i + 1] : undefined;
|
|
17
|
+
}
|
|
18
|
+
const API_KEY = process.env.AILIST_API_KEY ?? flagValue("--api-key") ?? "";
|
|
19
|
+
const BASE_URL = (process.env.AILIST_BASE_URL ?? flagValue("--base-url") ?? "https://ai-list.web.app").replace(/\/$/, "");
|
|
20
|
+
if (!API_KEY) {
|
|
21
|
+
console.error("ailist-mcp-server: missing API key. Set AILIST_API_KEY (or pass --api-key <key>).\n" +
|
|
22
|
+
"Create a key in the AIList app: household settings -> API keys (owner only).");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
async function api(path, init = {}) {
|
|
26
|
+
const res = await fetch(`${BASE_URL}/api/v1${path}`, {
|
|
27
|
+
...init,
|
|
28
|
+
headers: {
|
|
29
|
+
"X-API-Key": API_KEY,
|
|
30
|
+
...(init.body ? { "Content-Type": "application/json" } : {}),
|
|
31
|
+
...(init.headers ?? {}),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const text = await res.text();
|
|
35
|
+
let data;
|
|
36
|
+
try {
|
|
37
|
+
data = JSON.parse(text);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
data = text;
|
|
41
|
+
}
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
const message = typeof data === "object" && data !== null && "message" in data
|
|
44
|
+
? String(data.message)
|
|
45
|
+
: `HTTP ${res.status}`;
|
|
46
|
+
throw new Error(`AIList API ${res.status}: ${message}`);
|
|
47
|
+
}
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
function textResult(data) {
|
|
51
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
52
|
+
}
|
|
53
|
+
async function run(fn) {
|
|
54
|
+
try {
|
|
55
|
+
return textResult(await fn());
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: "text", text: err instanceof Error ? err.message : String(err) }],
|
|
60
|
+
isError: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const server = new McpServer({ name: "ailist", version: "0.1.6" }, {
|
|
65
|
+
instructions: "AIList household lists. The API key belongs to one household, so every " +
|
|
66
|
+
"tool works on that household's lists only. Before a shopping trip, call " +
|
|
67
|
+
"list_lists and then get_list to see what is still unchecked. Never invent " +
|
|
68
|
+
"a barcode; only set one when the user gave it.",
|
|
69
|
+
});
|
|
70
|
+
server.tool("list_lists", "List the household's lists, with item counts.", {}, () => run(() => api("/lists")));
|
|
71
|
+
server.tool("get_list", "Get one list in full: categories and items, with checked state, quantity, unit, barcode, icon and note.", { listId: z.string().describe("List id, from list_lists.") }, ({ listId }) => run(() => api(`/lists/${encodeURIComponent(listId)}`)));
|
|
72
|
+
server.tool("get_item", "Get one item by id.", {
|
|
73
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
74
|
+
itemId: z.string().describe("Item id, from get_list."),
|
|
75
|
+
}, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}`)));
|
|
76
|
+
server.tool("list_categories", "List the categories of one list.", { listId: z.string().describe("List id, from list_lists.") }, ({ listId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/categories`)));
|
|
77
|
+
server.tool("add_item", "Add an item to a list. It is auto-categorized (household dictionary, then the general dictionary, else 'other'); the response includes the assigned category. Quantities and weights go in unit (e.g. '250g'), not quantity.", {
|
|
78
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
79
|
+
text: z.string().min(1).describe("Product name, e.g. 'milk'."),
|
|
80
|
+
quantity: z.number().positive().optional().describe("Quantity, e.g. 2."),
|
|
81
|
+
unit: z.string().optional().describe("Unit, e.g. '1l', '250g', 'pack'."),
|
|
82
|
+
barcode: z.string().optional().describe("Barcode of a specific preferred product, only when the user gave it."),
|
|
83
|
+
icon: z.string().optional().describe("One emoji as a manual icon choice for the item."),
|
|
84
|
+
note: z.string().optional().describe("Short note shown under the item, e.g. a preferred brand."),
|
|
85
|
+
}, ({ listId, ...body }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items`, { method: "POST", body: JSON.stringify(body) })));
|
|
86
|
+
server.tool("update_item", "Edit an item's fields (only the fields sent change) and/or check/uncheck it. Setting quantity, unit, barcode, icon or note to null clears it. Moving to another category also teaches the household dictionary, like move_item.", {
|
|
87
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
88
|
+
itemId: z.string().describe("Item id, from get_list."),
|
|
89
|
+
checked: z.boolean().optional().describe("true = bought, false = still to buy."),
|
|
90
|
+
text: z.string().min(1).optional().describe("New product name."),
|
|
91
|
+
quantity: z.number().positive().nullable().optional().describe("New quantity, or null to clear it."),
|
|
92
|
+
unit: z.string().nullable().optional().describe("New unit, or null to clear it."),
|
|
93
|
+
categoryId: z.string().optional().describe("Id of an existing category in this list."),
|
|
94
|
+
barcode: z.string().nullable().optional().describe("New barcode, or null to clear the preference."),
|
|
95
|
+
icon: z.string().nullable().optional().describe("One emoji as a manual icon choice, or null to go back to the automatic icon."),
|
|
96
|
+
note: z.string().nullable().optional().describe("New note, or null to clear it."),
|
|
97
|
+
}, ({ listId, itemId, ...body }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}`, {
|
|
98
|
+
method: "PATCH",
|
|
99
|
+
body: JSON.stringify(body),
|
|
100
|
+
})));
|
|
101
|
+
server.tool("delete_item", "Delete an item from a list.", {
|
|
102
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
103
|
+
itemId: z.string().describe("Item id, from get_list."),
|
|
104
|
+
}, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}`, { method: "DELETE" })));
|
|
105
|
+
server.tool("move_item", "Move an item to another category. Also teaches the household dictionary: next time the same product is added, it lands in the new category on its own.", {
|
|
106
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
107
|
+
itemId: z.string().describe("Item id, from get_list."),
|
|
108
|
+
categoryId: z.string().describe("Id of an existing category in this list."),
|
|
109
|
+
}, ({ listId, itemId, categoryId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}/move`, {
|
|
110
|
+
method: "POST",
|
|
111
|
+
body: JSON.stringify({ categoryId }),
|
|
112
|
+
})));
|
|
113
|
+
server.tool("check_item", "Mark an item as bought.", {
|
|
114
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
115
|
+
itemId: z.string().describe("Item id, from get_list."),
|
|
116
|
+
}, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}/check`, { method: "POST" })));
|
|
117
|
+
server.tool("uncheck_item", "Unmark an item (still to buy).", {
|
|
118
|
+
listId: z.string().describe("List id, from list_lists."),
|
|
119
|
+
itemId: z.string().describe("Item id, from get_list."),
|
|
120
|
+
}, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}/uncheck`, { method: "POST" })));
|
|
121
|
+
await server.connect(new StdioServerTransport());
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
+
"bin": {
|
|
3
|
+
"ailist-mcp": "dist/index.js"
|
|
4
|
+
},
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
7
|
+
"zod": "^3.25.0"
|
|
8
|
+
},
|
|
9
|
+
"description": "MCP server for AIList household lists: a thin stdio wrapper over the AIList REST API v1",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^22.20.5",
|
|
12
|
+
"typescript": "^5.9.0"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
2
22
|
"name": "ailist-mcp-server",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
23
|
+
"private": false,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"start": "node dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"version": "0.1.6",
|
|
30
|
+
"mcpName": "io.github.eagami9/ailist",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/eagami9/SharedLists"
|
|
34
|
+
}
|
|
35
|
+
}
|