ailist-mcp-server 0.0.0-stage → 0.1.0

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.
Files changed (3) hide show
  1. package/README.md +88 -2
  2. package/dist/index.js +119 -0
  3. package/package.json +1 -6
package/README.md CHANGED
@@ -1,3 +1,89 @@
1
- # Temporary Holding Version
1
+ # AIList MCP server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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) and
24
+ `icon` (one emoji as a manual icon choice). Moving an item also teaches the
25
+ household dictionary, like the REST API.
26
+
27
+ ## Connect (Claude Code)
28
+
29
+ ```bash
30
+ claude mcp add ailist -e AILIST_API_KEY=sl_... -- npx -y ailist-mcp-server
31
+ ```
32
+
33
+ Or add it to your MCP config by hand (`~/.claude.json` for Claude Code,
34
+ Claude Desktop settings for the desktop app):
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "ailist": {
40
+ "command": "npx",
41
+ "args": ["-y", "ailist-mcp-server"],
42
+ "env": {
43
+ "AILIST_API_KEY": "sl_..."
44
+ }
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ Get the key in the AIList app: household settings → API keys (owner only).
51
+ The key is shown once when created, and it works only for the household it
52
+ was created in. To point at a local dev server instead of production, set
53
+ `AILIST_BASE_URL` (default `https://ai-list.web.app`).
54
+
55
+ > The `npx` one-command install above needs the package published to npm.
56
+ > Until then, 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,119 @@
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.0" }, {
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 and icon.", { 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
+ }, ({ listId, ...body }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items`, { method: "POST", body: JSON.stringify(body) })));
85
+ server.tool("update_item", "Edit an item's fields (only the fields sent change) and/or check/uncheck it. Setting quantity, unit, barcode or icon to null clears it. Moving to another category also teaches the household dictionary, like move_item.", {
86
+ listId: z.string().describe("List id, from list_lists."),
87
+ itemId: z.string().describe("Item id, from get_list."),
88
+ checked: z.boolean().optional().describe("true = bought, false = still to buy."),
89
+ text: z.string().min(1).optional().describe("New product name."),
90
+ quantity: z.number().positive().nullable().optional().describe("New quantity, or null to clear it."),
91
+ unit: z.string().nullable().optional().describe("New unit, or null to clear it."),
92
+ categoryId: z.string().optional().describe("Id of an existing category in this list."),
93
+ barcode: z.string().nullable().optional().describe("New barcode, or null to clear the preference."),
94
+ icon: z.string().nullable().optional().describe("One emoji as a manual icon choice, or null to go back to the automatic icon."),
95
+ }, ({ listId, itemId, ...body }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}`, {
96
+ method: "PATCH",
97
+ body: JSON.stringify(body),
98
+ })));
99
+ server.tool("delete_item", "Delete an item from a list.", {
100
+ listId: z.string().describe("List id, from list_lists."),
101
+ itemId: z.string().describe("Item id, from get_list."),
102
+ }, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}`, { method: "DELETE" })));
103
+ 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.", {
104
+ listId: z.string().describe("List id, from list_lists."),
105
+ itemId: z.string().describe("Item id, from get_list."),
106
+ categoryId: z.string().describe("Id of an existing category in this list."),
107
+ }, ({ listId, itemId, categoryId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}/move`, {
108
+ method: "POST",
109
+ body: JSON.stringify({ categoryId }),
110
+ })));
111
+ server.tool("check_item", "Mark an item as bought.", {
112
+ listId: z.string().describe("List id, from list_lists."),
113
+ itemId: z.string().describe("Item id, from get_list."),
114
+ }, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}/check`, { method: "POST" })));
115
+ server.tool("uncheck_item", "Unmark an item (still to buy).", {
116
+ listId: z.string().describe("List id, from list_lists."),
117
+ itemId: z.string().describe("Item id, from get_list."),
118
+ }, ({ listId, itemId }) => run(() => api(`/lists/${encodeURIComponent(listId)}/items/${encodeURIComponent(itemId)}/uncheck`, { method: "POST" })));
119
+ await server.connect(new StdioServerTransport());
package/package.json CHANGED
@@ -1,6 +1 @@
1
- {
2
- "name": "ailist-mcp-server",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {"bin":{"ailist-mcp":"dist/index.js"},"dependencies":{"@modelcontextprotocol/sdk":"^1.32.2","zod":"^3.25.0"},"description":"MCP server for AIList household lists: a thin stdio wrapper over the AIList REST API v1","devDependencies":{"typescript":"^5.9.0"},"engines":{"node":">=18"},"files":["dist","README.md"],"license":"MIT","name":"ailist-mcp-server","private":false,"scripts":{"build":"tsc","start":"node dist/index.js"},"type":"module","version":"0.1.0"}