@mdeleon23/wardrowbe-mcp 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +130 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +87 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.js +221 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.js +61 -0
- package/dist/http.d.ts +10 -0
- package/dist/http.js +138 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/login.d.ts +32 -0
- package/dist/login.js +140 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +59 -0
- package/dist/token-store.d.ts +20 -0
- package/dist/token-store.js +49 -0
- package/dist/tools.d.ts +5 -0
- package/dist/tools.js +183 -0
- package/dist/uploads.d.ts +36 -0
- package/dist/uploads.js +57 -0
- package/package.json +47 -4
- package/skill/SKILL.md +49 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Image types Wardrowbe accepts. HEIC is what iPhones produce by default. */
|
|
2
|
+
export declare const ALLOWED_IMAGE_TYPES: string[];
|
|
3
|
+
/** Largest photo the upload endpoint accepts. Phone photos are often 3 to 8 MB. */
|
|
4
|
+
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
|
+
export declare const UPLOAD_TTL_MS: number;
|
|
11
|
+
/** Caps how many photos can wait at once, so a flood of uploads cannot fill memory. */
|
|
12
|
+
export declare const MAX_PENDING_UPLOADS = 50;
|
|
13
|
+
export interface PendingUpload {
|
|
14
|
+
bytes: Buffer;
|
|
15
|
+
contentType: string;
|
|
16
|
+
filename: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class UploadError extends Error {
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Holds photos from the upload endpoint until a tool uses them. Each id works once, and entries
|
|
22
|
+
* expire after UPLOAD_TTL_MS. Kept in memory, so uploads are lost if the server restarts.
|
|
23
|
+
*/
|
|
24
|
+
export declare class UploadStore {
|
|
25
|
+
private readonly now;
|
|
26
|
+
private readonly ttlMs;
|
|
27
|
+
private readonly entries;
|
|
28
|
+
constructor(now?: () => number, ttlMs?: number);
|
|
29
|
+
/** Stores a photo and returns its id. */
|
|
30
|
+
put(upload: PendingUpload): string;
|
|
31
|
+
/** Returns the photo and removes it, so each id is used only once. */
|
|
32
|
+
take(id: string): PendingUpload;
|
|
33
|
+
private sweep;
|
|
34
|
+
}
|
|
35
|
+
/** Shared by every HTTP request, since the HTTP transport builds a server per request. */
|
|
36
|
+
export declare const sharedUploads: UploadStore;
|
package/dist/uploads.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
/** Image types Wardrowbe accepts. HEIC is what iPhones produce by default. */
|
|
3
|
+
export const ALLOWED_IMAGE_TYPES = ["image/jpeg", "image/png", "image/webp", "image/heic", "image/heif"];
|
|
4
|
+
/** Largest photo the upload endpoint accepts. Phone photos are often 3 to 8 MB. */
|
|
5
|
+
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
|
+
export const UPLOAD_TTL_MS = 10 * 60_000;
|
|
12
|
+
/** Caps how many photos can wait at once, so a flood of uploads cannot fill memory. */
|
|
13
|
+
export const MAX_PENDING_UPLOADS = 50;
|
|
14
|
+
export class UploadError extends Error {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Holds photos from the upload endpoint until a tool uses them. Each id works once, and entries
|
|
18
|
+
* expire after UPLOAD_TTL_MS. Kept in memory, so uploads are lost if the server restarts.
|
|
19
|
+
*/
|
|
20
|
+
export class UploadStore {
|
|
21
|
+
now;
|
|
22
|
+
ttlMs;
|
|
23
|
+
entries = new Map();
|
|
24
|
+
constructor(now = Date.now, ttlMs = UPLOAD_TTL_MS) {
|
|
25
|
+
this.now = now;
|
|
26
|
+
this.ttlMs = ttlMs;
|
|
27
|
+
}
|
|
28
|
+
/** Stores a photo and returns its id. */
|
|
29
|
+
put(upload) {
|
|
30
|
+
this.sweep();
|
|
31
|
+
if (this.entries.size >= MAX_PENDING_UPLOADS) {
|
|
32
|
+
throw new UploadError("Too many photos are waiting to be added. Try again in a few minutes.");
|
|
33
|
+
}
|
|
34
|
+
const id = randomUUID();
|
|
35
|
+
this.entries.set(id, { ...upload, expiresAt: this.now() + this.ttlMs });
|
|
36
|
+
return id;
|
|
37
|
+
}
|
|
38
|
+
/** Returns the photo and removes it, so each id is used only once. */
|
|
39
|
+
take(id) {
|
|
40
|
+
this.sweep();
|
|
41
|
+
const entry = this.entries.get(id);
|
|
42
|
+
if (!entry) {
|
|
43
|
+
throw new UploadError(`Upload ${id} was not found. It may have expired or already been used. Upload the photo again.`);
|
|
44
|
+
}
|
|
45
|
+
this.entries.delete(id);
|
|
46
|
+
return { bytes: entry.bytes, contentType: entry.contentType, filename: entry.filename };
|
|
47
|
+
}
|
|
48
|
+
sweep() {
|
|
49
|
+
const now = this.now();
|
|
50
|
+
for (const [id, entry] of this.entries) {
|
|
51
|
+
if (entry.expiresAt <= now)
|
|
52
|
+
this.entries.delete(id);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Shared by every HTTP request, since the HTTP transport builds a server per request. */
|
|
57
|
+
export const sharedUploads = new UploadStore();
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdeleon23/wardrowbe-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for the Wardrowbe wardrobe API. Runs over stdio (npx) or Streamable HTTP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wardrowbe-mcp": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"skill",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"prepack": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"mcp",
|
|
27
|
+
"model-context-protocol",
|
|
28
|
+
"wardrobe",
|
|
29
|
+
"wardrowbe"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/mjrealm/wardrowbe-mcp.git"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/mjrealm/wardrowbe-mcp#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/mjrealm/wardrowbe-mcp/issues"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
42
|
+
"zod": "^4.6.7"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^24.0.0",
|
|
46
|
+
"typescript": "^5.9.0",
|
|
47
|
+
"vitest": "^4.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wardrowbe
|
|
3
|
+
description: Manage a Wardrowbe wardrobe through MCP tools. Use it to browse and add items, log wear and washes, archive or restore items, check wardrobe stats, and handle outfit suggestions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wardrowbe wardrobe
|
|
7
|
+
|
|
8
|
+
Use these tools to help the user with their own wardrobe. Wardrowbe stores each item with a photo, a type, colors, and wear and wash history.
|
|
9
|
+
|
|
10
|
+
## Choosing a tool
|
|
11
|
+
|
|
12
|
+
| The user wants to... | Use |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| See how the wardrobe is doing | `get_wardrobe_summary` |
|
|
15
|
+
| Find or look at items | `list_items`, then `get_item` for details |
|
|
16
|
+
| Know what needs washing | `get_items_to_wash` |
|
|
17
|
+
| Know what they wear most | `get_most_worn_items` |
|
|
18
|
+
| Log a day's wear or a wash | `log_wear`, `log_wash` |
|
|
19
|
+
| Remove an item from suggestions without deleting it | `archive_item` |
|
|
20
|
+
| Bring an archived item back | `restore_item` |
|
|
21
|
+
| Add a new item | `upload_photo`, then `add_item` (see below) |
|
|
22
|
+
| Get or respond to outfit suggestions | `suggest_outfit`, `accept_outfit`, `reject_outfit` |
|
|
23
|
+
|
|
24
|
+
## Adding an item from a photo
|
|
25
|
+
|
|
26
|
+
1. Ask the user for a photo of the item.
|
|
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.
|
|
30
|
+
|
|
31
|
+
### Re-encoding a large photo
|
|
32
|
+
|
|
33
|
+
Shrink the photo before encoding it to base64. Resize the longest side to 512 pixels and save it as JPEG at quality 70. Most clothing photos come out well under 300 KB this way. If the result is still over the limit, lower the quality in steps of 10, down to 50.
|
|
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.
|
|
38
|
+
|
|
39
|
+
An `upload_id` works once and expires after 10 minutes. If `add_item` says the upload was not found, upload the photo again.
|
|
40
|
+
|
|
41
|
+
## Archiving
|
|
42
|
+
|
|
43
|
+
Archive is reversible. Prefer it over anything destructive. When an item is archived, it stays in the wardrobe and can be restored, but it's left out of outfit suggestions. Confirm with the user before archiving an item they didn't name.
|
|
44
|
+
|
|
45
|
+
## Reading results
|
|
46
|
+
|
|
47
|
+
- Tool results are JSON. Summarize them for the user rather than dumping the raw fields.
|
|
48
|
+
- `get_most_worn_items` returns at most 5 items.
|
|
49
|
+
- Errors come back as tool errors with Wardrowbe's message. Read the message and tell the user what went wrong. Retry only if the fix is clear, such as a wrong ID.
|