@mdeleon23/wardrowbe-mcp 0.3.0 → 0.4.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.
- package/README.md +104 -35
- package/dist/cli.js +1 -1
- package/dist/client.js +22 -5
- package/dist/server.d.ts +3 -1
- package/dist/server.js +2 -2
- package/dist/tools.d.ts +3 -1
- package/dist/tools.js +36 -21
- package/dist/uploads.d.ts +2 -5
- package/dist/uploads.js +9 -5
- package/package.json +1 -1
- package/skill/SKILL.md +6 -11
package/README.md
CHANGED
|
@@ -6,31 +6,106 @@ Requires Node.js 20 or newer.
|
|
|
6
6
|
|
|
7
7
|
## Quick start
|
|
8
8
|
|
|
9
|
-
You need
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
You need:
|
|
10
|
+
|
|
11
|
+
- Node.js 20 or newer
|
|
12
|
+
- Your Wardrowbe URL, for example `https://wardrowbe.example.com`
|
|
13
|
+
- An OIDC identity provider that runs Wardrowbe sign-in. Pocket ID works.
|
|
14
|
+
|
|
15
|
+
Setup has four steps: create an OIDC client, get a refresh token, add the server to your MCP client, and check that it works.
|
|
16
|
+
|
|
17
|
+
### Step 1: Create an OIDC client
|
|
18
|
+
|
|
19
|
+
In your identity provider:
|
|
20
|
+
|
|
21
|
+
1. Create a client. A **public** client uses PKCE and has no secret. A **confidential** client has a client secret. Both work. If yours is confidential, you'll set `OIDC_CLIENT_SECRET` in steps 2 and 3.
|
|
22
|
+
2. Allow the scopes `openid profile email offline_access`. `offline_access` is required. Without it the provider returns no refresh token.
|
|
23
|
+
3. Add the redirect URI `http://localhost:8765/callback` exactly as written.
|
|
24
|
+
4. Note two values: the issuer URL (for example `https://pocket.example.com`) and the client ID (for example `wardrowbe`).
|
|
25
|
+
|
|
26
|
+
### Step 2: Get a refresh token
|
|
27
|
+
|
|
28
|
+
Run this on a computer with a web browser. It can be your laptop, even if the MCP server runs somewhere else. Port `8765` must be free.
|
|
29
|
+
|
|
30
|
+
Run it from a folder outside any project, such as your home directory. Running it inside a clone of this repository fails with `sh: wardrowbe-mcp: command not found`.
|
|
31
|
+
|
|
32
|
+
If your client is confidential, set the secret in your shell first. `read -s` keeps it out of your shell history and off the command line. Type the secret when prompted and press Enter. Skip this for a public client.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
read -s OIDC_CLIENT_SECRET && export OIDC_CLIENT_SECRET
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then run the login. It reads `OIDC_CLIENT_SECRET` from the environment automatically.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cd ~
|
|
42
|
+
npx -y @mdeleon23/wardrowbe-mcp@0.3.0 login \
|
|
43
|
+
--issuer https://pocket.example.com \
|
|
44
|
+
--client-id wardrowbe \
|
|
45
|
+
> refresh-token.txt
|
|
46
|
+
chmod 600 refresh-token.txt
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The command pins `@0.3.0`, the release this step was checked against. You can drop the pin to use the latest release.
|
|
50
|
+
|
|
51
|
+
1. The command prints progress messages to your terminal and tries to open the provider's sign-in page in your browser. If the browser doesn't open, copy the URL from the terminal into a browser yourself.
|
|
52
|
+
2. Sign in and approve the request.
|
|
53
|
+
3. The browser then redirects to `localhost:8765`. The terminal prints `Refresh token printed to stdout`. If you see an error instead, see [Troubleshooting](#troubleshooting).
|
|
54
|
+
4. `refresh-token.txt` now contains the token. Treat it like a password.
|
|
55
|
+
|
|
56
|
+
### Step 3: Add the server to your MCP client
|
|
57
|
+
|
|
58
|
+
For Claude Desktop or Claude Code, add this to your MCP config. Replace `<refresh-token>` with the contents of `refresh-token.txt`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"wardrowbe": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "@mdeleon23/wardrowbe-mcp"],
|
|
66
|
+
"env": {
|
|
67
|
+
"WARDROWBE_URL": "https://wardrowbe.example.com",
|
|
68
|
+
"OIDC_ISSUER_URL": "https://pocket.example.com",
|
|
69
|
+
"OIDC_CLIENT_ID": "wardrowbe",
|
|
70
|
+
"OIDC_REFRESH_TOKEN": "<refresh-token>"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Save the config, then delete `refresh-token.txt`. The token now lives only in your MCP config.
|
|
78
|
+
|
|
79
|
+
If you use a confidential client, also add `"OIDC_CLIENT_SECRET": "<client-secret>"` to `env`. Use the same secret as in step 2. The server needs it to refresh the token, so a token from a confidential client won't work without it.
|
|
31
80
|
|
|
32
81
|
To use a plain access token instead, set `WARDROWBE_TOKEN` in place of the `OIDC_*` variables. It expires, so OIDC is better for regular use.
|
|
33
82
|
|
|
83
|
+
### Step 4: Check that it works
|
|
84
|
+
|
|
85
|
+
Restart your MCP client, then ask it to call `get_wardrobe_summary`. It should return your item counts without asking you to sign in. If it reports a token or sign-in error, see [Troubleshooting](#troubleshooting).
|
|
86
|
+
|
|
87
|
+
## Troubleshooting
|
|
88
|
+
|
|
89
|
+
**"The identity provider returned no refresh_token"**
|
|
90
|
+
The client doesn't allow `offline_access`. Enable that scope on the client, then repeat step 2.
|
|
91
|
+
|
|
92
|
+
**`sh: wardrowbe-mcp: command not found`**
|
|
93
|
+
You ran step 2 from inside a project folder, most likely this repository. Run it from another folder, such as your home directory.
|
|
94
|
+
|
|
95
|
+
**`Token exchange failed (HTTP 401: invalid_client)`**
|
|
96
|
+
The client is confidential, and `OIDC_CLIENT_SECRET` is missing or wrong at login. Set the secret as shown in step 2, then run the login again.
|
|
97
|
+
|
|
98
|
+
**Port 8765 is in use, or the browser redirect never arrives**
|
|
99
|
+
Another program is using port `8765`. Stop it, then repeat step 2. The redirect URI must still be `http://localhost:8765/callback`.
|
|
100
|
+
|
|
101
|
+
**"OIDC refresh failed" or "The refresh token may be expired or revoked"**
|
|
102
|
+
The token is no longer valid. Repeat step 2, then replace `OIDC_REFRESH_TOKEN` in your MCP config with the new token and restart the client.
|
|
103
|
+
|
|
104
|
+
If your provider rotates refresh tokens, the server saves each new token to `WARDROWBE_TOKEN_FILE`. At startup, though, `OIDC_REFRESH_TOKEN` takes priority over that file. If sign-in worked before and fails after a restart, repeat step 2 and update the config.
|
|
105
|
+
|
|
106
|
+
**A tool call starts a browser sign-in, or fails without one**
|
|
107
|
+
The server can start a browser sign-in by itself the first time a tool needs a token, but that path has not been reliable. Don't rely on it. Complete step 2 ahead of time and set `OIDC_REFRESH_TOKEN`.
|
|
108
|
+
|
|
34
109
|
## Configuration
|
|
35
110
|
|
|
36
111
|
| Variable | Required | Default | Purpose |
|
|
@@ -40,7 +115,7 @@ To use a plain access token instead, set `WARDROWBE_TOKEN` in place of the `OIDC
|
|
|
40
115
|
| `OIDC_ISSUER_URL` | or token | | OIDC issuer, e.g. `https://pocket.example.com`. |
|
|
41
116
|
| `OIDC_CLIENT_ID` | with OIDC | | OIDC client ID. |
|
|
42
117
|
| `OIDC_CLIENT_SECRET` | no | | Only for confidential clients. |
|
|
43
|
-
| `OIDC_REFRESH_TOKEN` | no | |
|
|
118
|
+
| `OIDC_REFRESH_TOKEN` | no | | Refresh token from step 2 of the Quick start. Takes priority over the saved one. |
|
|
44
119
|
| `WARDROWBE_TOKEN_FILE` | no | `~/.config/wardrowbe-mcp/refresh-token.json` | Where the refresh token is saved. |
|
|
45
120
|
| `MCP_TRANSPORT` | no | `stdio` | `stdio` or `http`. |
|
|
46
121
|
| `MCP_BIND_HOST` | no | `127.0.0.1` | Address for HTTP. Use `0.0.0.0` in containers. |
|
|
@@ -49,15 +124,9 @@ To use a plain access token instead, set `WARDROWBE_TOKEN` in place of the `OIDC
|
|
|
49
124
|
|
|
50
125
|
## How sign-in works
|
|
51
126
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
The browser sign-in needs a browser on the same machine as the server. On a headless host or in a container, sign in elsewhere and pass the token in:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npx -y @mdeleon23/wardrowbe-mcp login --issuer https://pocket.example.com --client-id wardrowbe > refresh-token.txt
|
|
58
|
-
```
|
|
127
|
+
The server turns the refresh token into a short-lived access token before each batch of calls. It takes the refresh token from `OIDC_REFRESH_TOKEN` if you set it, and otherwise from `WARDROWBE_TOKEN_FILE`. If the provider issues a new refresh token, the server saves it to that file.
|
|
59
128
|
|
|
60
|
-
|
|
129
|
+
Step 2 of the Quick start is the supported way to get a refresh token. This works on headless hosts and in containers too: sign in on any machine with a browser, then pass the token in with `OIDC_REFRESH_TOKEN`.
|
|
61
130
|
|
|
62
131
|
## HTTP transport
|
|
63
132
|
|
|
@@ -92,9 +161,9 @@ curl -s -X POST https://<host>:8080/uploads \
|
|
|
92
161
|
--data-binary @blue-shirt.jpg
|
|
93
162
|
```
|
|
94
163
|
|
|
95
|
-
|
|
164
|
+
There is no MCP tool for sending image bytes, because the model would have to write the whole photo out as base64.
|
|
96
165
|
|
|
97
|
-
`
|
|
166
|
+
Over stdio, the server runs on your own machine, so it offers `upload_photo_from_path` instead. Give it an absolute path to a photo (`.jpg`, `.jpeg`, `.png`, `.webp`, `.heic`, `.heif`, up to 15 MB). The server reads the file itself and returns an `upload_id` for `add_item`. The tool is not offered over HTTP, because it would let a remote caller read files off the server. `/uploads` is HTTP only.
|
|
98
167
|
|
|
99
168
|
## Tools
|
|
100
169
|
|
|
@@ -107,8 +176,8 @@ An agent can also do the whole thing through MCP with the `upload_photo` tool, w
|
|
|
107
176
|
| `suggest_outfit` | `POST /outfits/suggest` | Rate limited to about 10 per minute per user. |
|
|
108
177
|
| `accept_outfit` | `POST /outfits/{id}/accept` | |
|
|
109
178
|
| `reject_outfit` | `POST /outfits/{id}/reject` | |
|
|
110
|
-
| `
|
|
111
|
-
| `add_item` | `POST /items` | Takes an `upload_id` from `
|
|
179
|
+
| `upload_photo_from_path` | `POST /uploads` (in-process) | stdio only. Reads a photo from an absolute local path and returns an `upload_id`. |
|
|
180
|
+
| `add_item` | `POST /items` | Takes an `upload_id` from `upload_photo_from_path` (stdio) or `POST /uploads` (HTTP). Wardrowbe detects the type unless you pass one. |
|
|
112
181
|
| `get_analytics` | `GET /analytics` | `days` from 7 to 365. |
|
|
113
182
|
| `get_wardrobe_summary` | `GET /analytics` | Counts, insights, most and never worn items. Good first call. |
|
|
114
183
|
| `get_most_worn_items` | `GET /analytics` | Up to 5 items, from the same trend window. |
|
package/dist/cli.js
CHANGED
|
@@ -64,7 +64,7 @@ async function serve() {
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
// stdio: stdout carries MCP frames, so diagnostics go to stderr only.
|
|
67
|
-
const server = createServer(config);
|
|
67
|
+
const server = createServer(config, fetch, undefined, { localFiles: true });
|
|
68
68
|
await server.connect(new StdioServerTransport());
|
|
69
69
|
console.error(`${SERVER_NAME} ${SERVER_VERSION} running on stdio`);
|
|
70
70
|
}
|
package/dist/client.js
CHANGED
|
@@ -49,10 +49,22 @@ export class TokenProvider {
|
|
|
49
49
|
if (!oidc)
|
|
50
50
|
throw new Error("No OIDC configuration");
|
|
51
51
|
const idToken = await this.refreshIdToken(oidc);
|
|
52
|
+
const claims = jwtClaims(idToken);
|
|
53
|
+
// Wardrowbe's /auth/sync requires external_id and display_name next to the id token.
|
|
54
|
+
if (typeof claims.sub !== "string" || !claims.sub) {
|
|
55
|
+
throw new Error("The ID token has no sub claim, so Wardrowbe cannot identify the user.");
|
|
56
|
+
}
|
|
57
|
+
const email = typeof claims.email === "string" ? claims.email : undefined;
|
|
58
|
+
const name = [claims.name, claims.preferred_username, email?.split("@")[0]].find((v) => typeof v === "string" && v.trim() !== "");
|
|
52
59
|
const res = await this.fetchFn(`${this.config.wardrowbeUrl}/api/v1/auth/sync`, {
|
|
53
60
|
method: "POST",
|
|
54
61
|
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
55
|
-
body: JSON.stringify({
|
|
62
|
+
body: JSON.stringify({
|
|
63
|
+
id_token: idToken,
|
|
64
|
+
external_id: claims.sub,
|
|
65
|
+
email,
|
|
66
|
+
display_name: name ?? "User",
|
|
67
|
+
}),
|
|
56
68
|
});
|
|
57
69
|
const body = (await parseJson(res));
|
|
58
70
|
if (!res.ok || !body?.access_token) {
|
|
@@ -207,15 +219,20 @@ function describe(body, res) {
|
|
|
207
219
|
return res.statusText || "request failed";
|
|
208
220
|
}
|
|
209
221
|
/** Milliseconds until a JWT's exp claim, or undefined when it has none. Signature is not checked. */
|
|
210
|
-
|
|
222
|
+
/** Reads the claims from a JWT's payload. The signature is not checked; Wardrowbe verifies it. */
|
|
223
|
+
function jwtClaims(jwt) {
|
|
211
224
|
const payload = jwt.split(".")[1];
|
|
212
225
|
if (!payload)
|
|
213
|
-
return
|
|
226
|
+
return {};
|
|
214
227
|
try {
|
|
215
228
|
const claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
216
|
-
return typeof claims
|
|
229
|
+
return claims && typeof claims === "object" ? claims : {};
|
|
217
230
|
}
|
|
218
231
|
catch {
|
|
219
|
-
return
|
|
232
|
+
return {};
|
|
220
233
|
}
|
|
221
234
|
}
|
|
235
|
+
function jwtTtlMs(jwt, now) {
|
|
236
|
+
const exp = jwtClaims(jwt).exp;
|
|
237
|
+
return typeof exp === "number" ? exp * 1000 - now() : undefined;
|
|
238
|
+
}
|
package/dist/server.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ import { type UploadStore } from "./uploads.js";
|
|
|
4
4
|
export declare const SERVER_NAME = "wardrowbe-mcp";
|
|
5
5
|
export declare const SERVER_VERSION = "0.3.0";
|
|
6
6
|
/** Builds an MCP server with all Wardrowbe tools registered against the configured instance. */
|
|
7
|
-
export declare function createServer(config: Config, fetchFn?: typeof fetch, uploads?: UploadStore
|
|
7
|
+
export declare function createServer(config: Config, fetchFn?: typeof fetch, uploads?: UploadStore, options?: {
|
|
8
|
+
localFiles?: boolean;
|
|
9
|
+
}): McpServer;
|
package/dist/server.js
CHANGED
|
@@ -49,11 +49,11 @@ function registerSkill(server) {
|
|
|
49
49
|
}, (uri) => ({ contents: [{ uri: uri.toString(), mimeType: "text/markdown", text: skillText }] }));
|
|
50
50
|
}
|
|
51
51
|
/** Builds an MCP server with all Wardrowbe tools registered against the configured instance. */
|
|
52
|
-
export function createServer(config, fetchFn = fetch, uploads = sharedUploads) {
|
|
52
|
+
export function createServer(config, fetchFn = fetch, uploads = sharedUploads, options = {}) {
|
|
53
53
|
const tokens = new TokenProvider(config, fetchFn, Date.now, signInHooks(config));
|
|
54
54
|
const client = new WardrowbeClient(config, tokens, fetchFn);
|
|
55
55
|
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
|
|
56
|
-
registerTools(server, client, uploads);
|
|
56
|
+
registerTools(server, client, uploads, options);
|
|
57
57
|
registerSkill(server);
|
|
58
58
|
return server;
|
|
59
59
|
}
|
package/dist/tools.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import type { WardrowbeClient } from "./client.js";
|
|
3
3
|
import { type UploadStore } from "./uploads.js";
|
|
4
4
|
/** Registers the Wardrowbe tools on an MCP server. */
|
|
5
|
-
export declare function registerTools(server: McpServer, client: WardrowbeClient, uploads?: UploadStore
|
|
5
|
+
export declare function registerTools(server: McpServer, client: WardrowbeClient, uploads?: UploadStore, options?: {
|
|
6
|
+
localFiles?: boolean;
|
|
7
|
+
}): void;
|
package/dist/tools.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { basename, extname, isAbsolute } from "node:path";
|
|
1
3
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
4
|
+
import { IMAGE_EXTENSIONS, MAX_UPLOAD_BYTES, UPLOAD_TTL_MS, sharedUploads, } from "./uploads.js";
|
|
3
5
|
const uuid = z.string().uuid().describe("Item or outfit UUID");
|
|
4
6
|
const isoDate = z
|
|
5
7
|
.string()
|
|
@@ -17,7 +19,7 @@ async function run(fn) {
|
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
/** Registers the Wardrowbe tools on an MCP server. */
|
|
20
|
-
export function registerTools(server, client, uploads = sharedUploads) {
|
|
22
|
+
export function registerTools(server, client, uploads = sharedUploads, options = {}) {
|
|
21
23
|
server.registerTool("list_items", {
|
|
22
24
|
title: "List wardrobe items",
|
|
23
25
|
description: "List items in the user's wardrobe. Filter by type, status, favorites, or items that need washing.",
|
|
@@ -90,27 +92,40 @@ export function registerTools(server, client, uploads = sharedUploads) {
|
|
|
90
92
|
days: z.number().int().min(7).max(365).optional().describe("Trend window, 7 to 365 days"),
|
|
91
93
|
},
|
|
92
94
|
}, ({ days }) => run(() => client.get("/analytics", { days: days ?? 30 })));
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
if (options.localFiles) {
|
|
96
|
+
// Only for stdio, where the server runs on the user's own machine. Over HTTP this would let
|
|
97
|
+
// a remote caller read files off the server, so it is not registered there.
|
|
98
|
+
server.registerTool("upload_photo_from_path", {
|
|
99
|
+
title: "Upload a photo from a local file",
|
|
100
|
+
description: `Read an image file from this computer and stage it for add_item, without the image passing through the model. Pass an absolute path to a ${Object.keys(IMAGE_EXTENSIONS).join(", ")} file. Returns an upload_id for add_item. The id is good for 10 minutes and works once.`,
|
|
101
|
+
inputSchema: {
|
|
102
|
+
path: z.string().min(1).describe("Absolute path to the photo on this computer"),
|
|
103
|
+
},
|
|
104
|
+
}, ({ path }) => run(async () => {
|
|
105
|
+
if (!isAbsolute(path))
|
|
106
|
+
throw new Error("Pass an absolute path to the photo.");
|
|
107
|
+
const contentType = IMAGE_EXTENSIONS[extname(path).toLowerCase()];
|
|
108
|
+
if (!contentType) {
|
|
109
|
+
throw new Error(`Unsupported file type. Use one of: ${Object.keys(IMAGE_EXTENSIONS).join(", ")}.`);
|
|
110
|
+
}
|
|
111
|
+
const info = await stat(path).catch(() => {
|
|
112
|
+
throw new Error(`No file found at ${path}.`);
|
|
113
|
+
});
|
|
114
|
+
if (!info.isFile())
|
|
115
|
+
throw new Error(`${path} is not a file.`);
|
|
116
|
+
if (info.size > MAX_UPLOAD_BYTES) {
|
|
117
|
+
throw new Error(`The photo is larger than ${MAX_UPLOAD_BYTES / 1024 / 1024} MB.`);
|
|
118
|
+
}
|
|
119
|
+
const bytes = await readFile(path);
|
|
120
|
+
if (bytes.length === 0)
|
|
121
|
+
throw new Error("The file is empty.");
|
|
122
|
+
const upload_id = uploads.put({ bytes, contentType, filename: basename(path) });
|
|
123
|
+
return { upload_id, expires_in_seconds: UPLOAD_TTL_MS / 1000 };
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
111
126
|
server.registerTool("add_item", {
|
|
112
127
|
title: "Add a wardrobe item",
|
|
113
|
-
description: "Add a new item to the wardrobe from a photo. The photo must first be
|
|
128
|
+
description: "Add a new item to the wardrobe from a photo. The photo must first be staged, which returns an upload_id: with upload_photo_from_path when it is available (stdio), otherwise by sending the raw image bytes to the server's POST /uploads endpoint with the same Bearer key. Pass that id here. Wardrowbe detects the type and colors unless skip_ai is true or you pass them.",
|
|
114
129
|
inputSchema: {
|
|
115
130
|
upload_id: z.string().uuid().describe("upload_id returned when the photo was uploaded"),
|
|
116
131
|
type: z.string().optional().describe("Item type, e.g. top, bottom, shoes. Detected if omitted."),
|
package/dist/uploads.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/** Image types Wardrowbe accepts. HEIC is what iPhones produce by default. */
|
|
2
2
|
export declare const ALLOWED_IMAGE_TYPES: string[];
|
|
3
|
+
/** Maps file extensions to the image types above, for reading photos from disk. */
|
|
4
|
+
export declare const IMAGE_EXTENSIONS: Record<string, string>;
|
|
3
5
|
/** Largest photo the upload endpoint accepts. Phone photos are often 3 to 8 MB. */
|
|
4
6
|
export declare const MAX_UPLOAD_BYTES: number;
|
|
5
|
-
/**
|
|
6
|
-
* Largest photo the upload_photo tool accepts. The model has to write the whole image as base64
|
|
7
|
-
* inside the tool call, so this stays small. Full-size photos go through POST /uploads.
|
|
8
|
-
*/
|
|
9
|
-
export declare const MAX_TOOL_UPLOAD_BYTES: number;
|
|
10
7
|
export declare const UPLOAD_TTL_MS: number;
|
|
11
8
|
/** Caps how many photos can wait at once, so a flood of uploads cannot fill memory. */
|
|
12
9
|
export declare const MAX_PENDING_UPLOADS = 50;
|
package/dist/uploads.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
/** Image types Wardrowbe accepts. HEIC is what iPhones produce by default. */
|
|
3
3
|
export const ALLOWED_IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp", "image/heic", "image/heif"];
|
|
4
|
+
/** Maps file extensions to the image types above, for reading photos from disk. */
|
|
5
|
+
export const IMAGE_EXTENSIONS = {
|
|
6
|
+
".jpg": "image/jpeg",
|
|
7
|
+
".jpeg": "image/jpeg",
|
|
8
|
+
".png": "image/png",
|
|
9
|
+
".webp": "image/webp",
|
|
10
|
+
".heic": "image/heic",
|
|
11
|
+
".heif": "image/heif",
|
|
12
|
+
};
|
|
4
13
|
/** Largest photo the upload endpoint accepts. Phone photos are often 3 to 8 MB. */
|
|
5
14
|
export const MAX_UPLOAD_BYTES = 15 * 1024 * 1024;
|
|
6
|
-
/**
|
|
7
|
-
* Largest photo the upload_photo tool accepts. The model has to write the whole image as base64
|
|
8
|
-
* inside the tool call, so this stays small. Full-size photos go through POST /uploads.
|
|
9
|
-
*/
|
|
10
|
-
export const MAX_TOOL_UPLOAD_BYTES = 300 * 1024;
|
|
11
15
|
export const UPLOAD_TTL_MS = 10 * 60_000;
|
|
12
16
|
/** Caps how many photos can wait at once, so a flood of uploads cannot fill memory. */
|
|
13
17
|
export const MAX_PENDING_UPLOADS = 50;
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -18,23 +18,18 @@ Use these tools to help the user with their own wardrobe. Wardrowbe stores each
|
|
|
18
18
|
| Log a day's wear or a wash | `log_wear`, `log_wash` |
|
|
19
19
|
| Remove an item from suggestions without deleting it | `archive_item` |
|
|
20
20
|
| Bring an archived item back | `restore_item` |
|
|
21
|
-
| Add a new item | `
|
|
21
|
+
| Add a new item | `upload_photo_from_path` if you have it, then `add_item` (see below) |
|
|
22
22
|
| Get or respond to outfit suggestions | `suggest_outfit`, `accept_outfit`, `reject_outfit` |
|
|
23
23
|
|
|
24
24
|
## Adding an item from a photo
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
2. Make sure the photo is under 300 KB before calling `upload_photo`. Phone photos usually aren't, so re-encode them first (see below).
|
|
28
|
-
3. Call `upload_photo` with the image as base64 and its MIME type. It returns an `upload_id`.
|
|
29
|
-
4. Call `add_item` with that `upload_id`. Pass `type`, `name`, `colors`, or `brand` only if the user gave them. Otherwise leave them out and Wardrowbe detects them.
|
|
26
|
+
Photos don't go through MCP tools as image data. The server stages the photo and returns an `upload_id`.
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
1. Ask the user for a photo of the item, or the path to it on their computer.
|
|
29
|
+
2. If you have `upload_photo_from_path`, call it with the absolute path. Otherwise the app (or a shell tool, if you have one) sends the raw image bytes to `POST /uploads` on the server with the same Bearer key, and `Content-Type` set to the image type. Either way you get an `upload_id`.
|
|
30
|
+
3. Call `add_item` with that `upload_id`. Pass `type`, `name`, `colors`, or `brand` only if the user gave them. Otherwise leave them out and Wardrowbe detects them.
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
A reduced photo is fine for adding the item. Once the item is added, tell the user they can upload a full-resolution photo later from the app if they want a sharper image.
|
|
36
|
-
|
|
37
|
-
If you have no tool to resize or re-encode images, don't send the original. Tell the user the photo is too large and ask for a smaller one, or ask them to use the app, which can upload full-size photos.
|
|
32
|
+
If you have neither `upload_photo_from_path` nor a way to reach `/uploads`, don't try to paste the image into a tool call. Ask the user to add the photo from the app, then use the `upload_id` it gives you.
|
|
38
33
|
|
|
39
34
|
An `upload_id` works once and expires after 10 minutes. If `add_item` says the upload was not found, upload the photo again.
|
|
40
35
|
|