@spronta/mcp 0.1.0 → 0.1.2
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 +127 -46
- package/dist/api.d.ts +15 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +55 -0
- package/dist/api.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +261 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +344 -0
- package/dist/tools.js.map +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,30 +1,41 @@
|
|
|
1
1
|
# @spronta/mcp
|
|
2
2
|
|
|
3
|
-
MCP server for
|
|
3
|
+
MCP server for uploading, transforming, and serving images on a global CDN — directly from AI assistants.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Connect Claude, GPT, Cursor, Windsurf, or any [MCP](https://modelcontextprotocol.io)-compatible client to the [Spronta](https://www.spronta.com) Image CDN. Upload images from URLs or base64, apply real-time transforms (resize, crop, format conversion, smart crop, blurhash), create reusable presets, generate signed URLs, and monitor usage — all through natural language.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
## Why use this?
|
|
8
|
+
|
|
9
|
+
- **Upload images from AI** — give your LLM an image URL and it uploads, optimizes, and returns a CDN link
|
|
10
|
+
- **Real-time transforms** — resize, crop, convert to WebP/AVIF/JXL, smart crop with face detection
|
|
11
|
+
- **Global CDN delivery** — images served from edge locations worldwide
|
|
12
|
+
- **Blurhash generation** — automatic blur placeholders computed on upload
|
|
13
|
+
- **Signed URLs** — HMAC-SHA256 signed URLs with expiration for private images
|
|
14
|
+
- **Named presets** — create reusable transform configurations (e.g. `thumbnail`, `hero`, `og-image`)
|
|
15
|
+
- **No vendor lock-in** — MIT licensed, open source
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
### Install
|
|
12
20
|
|
|
13
21
|
```bash
|
|
22
|
+
npm install -g @spronta/mcp
|
|
23
|
+
# or use directly
|
|
14
24
|
npx @spronta/mcp
|
|
15
25
|
```
|
|
16
26
|
|
|
17
|
-
## Setup
|
|
18
|
-
|
|
19
27
|
### Claude Code
|
|
20
28
|
|
|
21
29
|
```bash
|
|
22
|
-
claude mcp add spronta
|
|
30
|
+
claude mcp add spronta \
|
|
31
|
+
-e SPRONTA_API_KEY=spronta_img_... \
|
|
32
|
+
-e SPRONTA_PROJECT_ID=your-project-id \
|
|
33
|
+
-- npx @spronta/mcp
|
|
23
34
|
```
|
|
24
35
|
|
|
25
|
-
### Claude Desktop / Cursor
|
|
36
|
+
### Claude Desktop / Cursor / Windsurf
|
|
26
37
|
|
|
27
|
-
Add to your MCP
|
|
38
|
+
Add to your MCP configuration file:
|
|
28
39
|
|
|
29
40
|
```json
|
|
30
41
|
{
|
|
@@ -41,58 +52,128 @@ Add to your MCP config:
|
|
|
41
52
|
}
|
|
42
53
|
```
|
|
43
54
|
|
|
55
|
+
### Get your API key
|
|
56
|
+
|
|
57
|
+
1. Sign up at [app.spronta.com](https://app.spronta.com/sign-up) (free tier: 100 images)
|
|
58
|
+
2. Create a project in the dashboard
|
|
59
|
+
3. Copy your API key from project settings
|
|
60
|
+
|
|
44
61
|
## Environment variables
|
|
45
62
|
|
|
46
63
|
| Variable | Required | Description |
|
|
47
64
|
|----------|----------|-------------|
|
|
48
|
-
| `SPRONTA_API_KEY` | Yes | Your project API key
|
|
49
|
-
| `SPRONTA_PROJECT_ID` | No | Default project ID
|
|
65
|
+
| `SPRONTA_API_KEY` | Yes | Your project API key |
|
|
66
|
+
| `SPRONTA_PROJECT_ID` | No | Default project ID (can also be passed per-tool) |
|
|
50
67
|
| `SPRONTA_API_URL` | No | API base URL (default: `https://app.spronta.com/api`) |
|
|
51
68
|
|
|
52
|
-
##
|
|
69
|
+
## 18 tools available
|
|
53
70
|
|
|
54
71
|
### Projects
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|------|-------------|
|
|
74
|
+
| `list_projects` | List all image projects |
|
|
75
|
+
| `create_project` | Create a new project |
|
|
76
|
+
| `get_project` | Get project details with usage stats |
|
|
77
|
+
| `update_project` | Update name or custom domain |
|
|
78
|
+
| `delete_project` | Permanently delete a project |
|
|
79
|
+
|
|
80
|
+
### Upload & Images
|
|
81
|
+
| Tool | Description |
|
|
82
|
+
|------|-------------|
|
|
83
|
+
| `upload_image` | Upload from URL or base64 — handles presigned upload, blurhash generation, and CDN URL creation in one call |
|
|
84
|
+
| `list_images` | List images with pagination |
|
|
85
|
+
| `update_image` | Update alt text and tags |
|
|
86
|
+
| `delete_image` | Delete an image from CDN and storage |
|
|
87
|
+
|
|
88
|
+
### Transform Presets
|
|
89
|
+
| Tool | Description |
|
|
90
|
+
|------|-------------|
|
|
91
|
+
| `list_presets` | List named transform presets |
|
|
92
|
+
| `create_preset` | Create a preset (use in CDN URLs with `?t=name`) |
|
|
93
|
+
| `update_preset` | Update a preset's name or transforms |
|
|
94
|
+
| `delete_preset` | Delete a preset |
|
|
95
|
+
|
|
96
|
+
### URL Signing
|
|
97
|
+
| Tool | Description |
|
|
98
|
+
|------|-------------|
|
|
99
|
+
| `get_signing_config` | Get URL signing configuration |
|
|
100
|
+
| `update_signing` | Enable/disable HMAC-SHA256 signing |
|
|
101
|
+
| `generate_signed_url` | Generate a signed CDN URL with optional expiration |
|
|
102
|
+
|
|
103
|
+
### Analytics & Utility
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
|------|-------------|
|
|
106
|
+
| `get_usage` | Get daily metrics (requests, bandwidth, transforms) |
|
|
107
|
+
| `build_cdn_url` | Build a CDN URL with transform parameters (no API call) |
|
|
60
108
|
|
|
61
|
-
|
|
62
|
-
- `upload_image` — Upload an image from URL or base64. Handles the full upload flow (presigned URL → upload → confirm) and returns the CDN URL with blurhash.
|
|
109
|
+
## Example prompts
|
|
63
110
|
|
|
64
|
-
|
|
65
|
-
- `list_images` — List images with pagination
|
|
66
|
-
- `update_image` — Update alt text and tags
|
|
67
|
-
- `delete_image` — Delete an image
|
|
111
|
+
Once connected, just ask your AI:
|
|
68
112
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- `create_preset` — Create a preset (use in URLs with `?t=name`)
|
|
72
|
-
- `update_preset` — Update a preset
|
|
73
|
-
- `delete_preset` — Delete a preset
|
|
113
|
+
```
|
|
114
|
+
> Upload this image to my project: https://example.com/photo.jpg
|
|
74
115
|
|
|
75
|
-
|
|
76
|
-
- `get_signing_config` — Get URL signing configuration
|
|
77
|
-
- `update_signing` — Enable/disable signing
|
|
78
|
-
- `generate_signed_url` — Generate an HMAC-SHA256 signed URL
|
|
116
|
+
> Create a thumbnail preset: 200x200, cover crop, face detection, webp format
|
|
79
117
|
|
|
80
|
-
|
|
81
|
-
- `get_usage` — Get daily metrics (requests, bandwidth, transforms)
|
|
118
|
+
> How many requests did my project handle this week?
|
|
82
119
|
|
|
83
|
-
|
|
84
|
-
- `build_cdn_url` — Build a CDN URL with transform parameters (no API call)
|
|
120
|
+
> Generate a signed URL for hero.jpg that expires in 1 hour
|
|
85
121
|
|
|
86
|
-
|
|
122
|
+
> List all my images and update the alt text on the product shots
|
|
87
123
|
|
|
88
|
-
|
|
124
|
+
> Build a CDN URL for banner.png at 1200px wide in avif format
|
|
125
|
+
```
|
|
89
126
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
127
|
+
## Transform options
|
|
128
|
+
|
|
129
|
+
When creating presets or building URLs, these transforms are available:
|
|
130
|
+
|
|
131
|
+
| Parameter | Type | Description |
|
|
132
|
+
|-----------|------|-------------|
|
|
133
|
+
| `width` | integer | Output width (1–8192) |
|
|
134
|
+
| `height` | integer | Output height (1–8192) |
|
|
135
|
+
| `fit` | string | `cover`, `contain`, `fill`, `scale-down`, `crop`, `pad` |
|
|
136
|
+
| `format` | string | `auto`, `webp`, `avif`, `jpeg`, `png`, `jxl` |
|
|
137
|
+
| `quality` | integer | 1–100 |
|
|
138
|
+
| `qualityMode` | string | `high`, `medium`, `low` (perceptual targeting) |
|
|
139
|
+
| `gravity` | string | `auto`, `face`, `center`, position keywords |
|
|
140
|
+
| `blur` | integer | Gaussian blur (1–250) |
|
|
141
|
+
| `sharpen` | number | Unsharp mask (0–10) |
|
|
142
|
+
| `radius` | integer | Corner radius (1–9999, or "max" for circle) |
|
|
143
|
+
| `grayscale` | boolean | Convert to grayscale |
|
|
144
|
+
| `brightness` | integer | -100 to 100 |
|
|
145
|
+
| `contrast` | number | -100 to 100 |
|
|
146
|
+
| `saturation` | integer | -100 to 100 |
|
|
147
|
+
| `sepia` | boolean | Sepia tone filter |
|
|
148
|
+
| `rotate` | integer | 90, 180, 270 |
|
|
149
|
+
| `flip` | string | `h` (horizontal), `v` (vertical) |
|
|
150
|
+
|
|
151
|
+
## How upload works
|
|
152
|
+
|
|
153
|
+
The `upload_image` tool handles the full upload pipeline in a single call:
|
|
154
|
+
|
|
155
|
+
1. You provide an image URL (or base64 data) and a filename
|
|
156
|
+
2. The server fetches the image
|
|
157
|
+
3. Requests a presigned upload URL from Spronta
|
|
158
|
+
4. Uploads the file directly to storage
|
|
159
|
+
5. Confirms the upload — Spronta computes the blurhash and detects dimensions
|
|
160
|
+
6. Returns the confirmed image with CDN URL, blurhash, and metadata
|
|
161
|
+
|
|
162
|
+
## Related packages
|
|
163
|
+
|
|
164
|
+
- [`@spronta/images`](https://www.npmjs.com/package/@spronta/images) — Core URL builder SDK (zero deps)
|
|
165
|
+
- [`@spronta/images-react`](https://www.npmjs.com/package/@spronta/images-react) — React components
|
|
166
|
+
- [`@spronta/images-next`](https://www.npmjs.com/package/@spronta/images-next) — Next.js integration
|
|
167
|
+
- [WordPress plugin](https://github.com/spronta/wordpress-plugin) — Automatic CDN for WordPress
|
|
168
|
+
|
|
169
|
+
## Links
|
|
170
|
+
|
|
171
|
+
- [Website](https://www.spronta.com)
|
|
172
|
+
- [Documentation](https://www.spronta.com/docs)
|
|
173
|
+
- [API Reference](https://www.spronta.com/docs/api)
|
|
174
|
+
- [OpenAPI Spec](https://www.spronta.com/openapi.yaml)
|
|
175
|
+
- [GitHub](https://github.com/spronta/mcp)
|
|
176
|
+
- [npm](https://www.npmjs.com/package/@spronta/mcp)
|
|
96
177
|
|
|
97
178
|
## License
|
|
98
179
|
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spronta REST API client for the MCP server.
|
|
3
|
+
* Thin fetch wrapper with Bearer token auth.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SprontaApi {
|
|
6
|
+
private apiKey;
|
|
7
|
+
private baseUrl;
|
|
8
|
+
constructor(apiKey: string, baseUrl?: string);
|
|
9
|
+
request<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Upload a file to a presigned URL.
|
|
12
|
+
*/
|
|
13
|
+
uploadToPresigned(uploadUrl: string, fileBuffer: Buffer, contentType: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAsC;IAKrE,OAAO,CAAC,CAAC,GAAG,OAAO,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,CAAC;IAmCb;;OAEG;IACG,iBAAiB,CACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;CAWjB"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spronta REST API client for the MCP server.
|
|
3
|
+
* Thin fetch wrapper with Bearer token auth.
|
|
4
|
+
*/
|
|
5
|
+
export class SprontaApi {
|
|
6
|
+
apiKey;
|
|
7
|
+
baseUrl;
|
|
8
|
+
constructor(apiKey, baseUrl = "https://app.spronta.com/api") {
|
|
9
|
+
this.apiKey = apiKey;
|
|
10
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
11
|
+
}
|
|
12
|
+
async request(method, path, body) {
|
|
13
|
+
const url = `${this.baseUrl}${path}`;
|
|
14
|
+
const headers = {
|
|
15
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
16
|
+
};
|
|
17
|
+
if (body !== undefined) {
|
|
18
|
+
headers["Content-Type"] = "application/json";
|
|
19
|
+
}
|
|
20
|
+
const res = await fetch(url, {
|
|
21
|
+
method,
|
|
22
|
+
headers,
|
|
23
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
24
|
+
});
|
|
25
|
+
const text = await res.text();
|
|
26
|
+
let data;
|
|
27
|
+
try {
|
|
28
|
+
data = JSON.parse(text);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
data = text;
|
|
32
|
+
}
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
const msg = typeof data === "object" && data !== null && "error" in data
|
|
35
|
+
? data.error
|
|
36
|
+
: `HTTP ${res.status}: ${text.slice(0, 200)}`;
|
|
37
|
+
throw new Error(msg);
|
|
38
|
+
}
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Upload a file to a presigned URL.
|
|
43
|
+
*/
|
|
44
|
+
async uploadToPresigned(uploadUrl, fileBuffer, contentType) {
|
|
45
|
+
const res = await fetch(uploadUrl, {
|
|
46
|
+
method: "PUT",
|
|
47
|
+
headers: { "Content-Type": contentType },
|
|
48
|
+
body: fileBuffer,
|
|
49
|
+
});
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
throw new Error(`Upload failed: HTTP ${res.status}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,UAAU;IACb,MAAM,CAAS;IACf,OAAO,CAAS;IAExB,YAAY,MAAc,EAAE,UAAkB,6BAA6B;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAc,EACd,IAAY,EACZ,IAAc;QAEd,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QACrC,MAAM,OAAO,GAA2B;YACtC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;SACvC,CAAC;QAEF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAC/C,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,MAAM;YACN,OAAO;YACP,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC5D,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,IAAa,CAAC;QAClB,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,GAAG,GACP,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,IAAI;gBAC1D,CAAC,CAAE,IAA0B,CAAC,KAAK;gBACnC,CAAC,CAAC,QAAQ,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,IAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CACrB,SAAiB,EACjB,UAAkB,EAClB,WAAmB;QAEnB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE;YACjC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;YACxC,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Spronta MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes the Spronta Image CDN API as MCP tools for LLM integrations.
|
|
6
|
+
*
|
|
7
|
+
* Environment variables:
|
|
8
|
+
* SPRONTA_API_KEY — Required. Your project API key.
|
|
9
|
+
* SPRONTA_PROJECT_ID — Optional. Default project ID (can be passed per-tool).
|
|
10
|
+
* SPRONTA_API_URL — Optional. API base URL (default: https://app.spronta.com/api).
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Spronta MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes the Spronta Image CDN API as MCP tools for LLM integrations.
|
|
6
|
+
*
|
|
7
|
+
* Environment variables:
|
|
8
|
+
* SPRONTA_API_KEY — Required. Your project API key.
|
|
9
|
+
* SPRONTA_PROJECT_ID — Optional. Default project ID (can be passed per-tool).
|
|
10
|
+
* SPRONTA_API_URL — Optional. API base URL (default: https://app.spronta.com/api).
|
|
11
|
+
*/
|
|
12
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
15
|
+
import { SprontaApi } from "./api.js";
|
|
16
|
+
import { TOOLS } from "./tools.js";
|
|
17
|
+
// ── Config ──────────────────────────────────────────────────────
|
|
18
|
+
const API_KEY = process.env.SPRONTA_API_KEY;
|
|
19
|
+
const DEFAULT_PROJECT_ID = process.env.SPRONTA_PROJECT_ID;
|
|
20
|
+
const API_URL = process.env.SPRONTA_API_URL ?? "https://app.spronta.com/api";
|
|
21
|
+
const CDN_URL_DEFAULT = "https://cdn.spronta.com";
|
|
22
|
+
if (!API_KEY) {
|
|
23
|
+
console.error("Error: SPRONTA_API_KEY environment variable is required.");
|
|
24
|
+
console.error("Get your API key from https://app.spronta.com");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const api = new SprontaApi(API_KEY, API_URL);
|
|
28
|
+
// ── Helpers ─────────────────────────────────────────────────────
|
|
29
|
+
function getProjectId(args) {
|
|
30
|
+
const id = args.projectId || DEFAULT_PROJECT_ID;
|
|
31
|
+
if (!id) {
|
|
32
|
+
throw new Error("projectId is required. Pass it as a parameter or set SPRONTA_PROJECT_ID env var.");
|
|
33
|
+
}
|
|
34
|
+
return id;
|
|
35
|
+
}
|
|
36
|
+
function ok(data) {
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{ type: "text", text: JSON.stringify(data, null, 2) },
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function detectContentType(filename) {
|
|
44
|
+
const ext = filename.split(".").pop()?.toLowerCase();
|
|
45
|
+
const map = {
|
|
46
|
+
jpg: "image/jpeg",
|
|
47
|
+
jpeg: "image/jpeg",
|
|
48
|
+
png: "image/png",
|
|
49
|
+
gif: "image/gif",
|
|
50
|
+
webp: "image/webp",
|
|
51
|
+
avif: "image/avif",
|
|
52
|
+
svg: "image/svg+xml",
|
|
53
|
+
tiff: "image/tiff",
|
|
54
|
+
tif: "image/tiff",
|
|
55
|
+
bmp: "image/bmp",
|
|
56
|
+
};
|
|
57
|
+
return map[ext ?? ""] ?? "image/jpeg";
|
|
58
|
+
}
|
|
59
|
+
// ── Tool handler ────────────────────────────────────────────────
|
|
60
|
+
async function handleTool(name, args) {
|
|
61
|
+
switch (name) {
|
|
62
|
+
// ── Projects ─────────────────────────────────────────────
|
|
63
|
+
case "list_projects":
|
|
64
|
+
return ok(await api.request("GET", "/images/projects"));
|
|
65
|
+
case "create_project":
|
|
66
|
+
return ok(await api.request("POST", "/images/projects", { name: args.name }));
|
|
67
|
+
case "get_project": {
|
|
68
|
+
const pid = getProjectId(args);
|
|
69
|
+
return ok(await api.request("GET", `/images/projects/${pid}`));
|
|
70
|
+
}
|
|
71
|
+
case "update_project": {
|
|
72
|
+
const pid = getProjectId(args);
|
|
73
|
+
const body = {};
|
|
74
|
+
if (args.name !== undefined)
|
|
75
|
+
body.name = args.name;
|
|
76
|
+
if (args.customDomain !== undefined)
|
|
77
|
+
body.customDomain = args.customDomain;
|
|
78
|
+
return ok(await api.request("PATCH", `/images/projects/${pid}`, body));
|
|
79
|
+
}
|
|
80
|
+
case "delete_project": {
|
|
81
|
+
const pid = getProjectId(args);
|
|
82
|
+
return ok(await api.request("DELETE", `/images/projects/${pid}`));
|
|
83
|
+
}
|
|
84
|
+
// ── Upload ───────────────────────────────────────────────
|
|
85
|
+
case "upload_image": {
|
|
86
|
+
const pid = getProjectId(args);
|
|
87
|
+
const filename = args.filename;
|
|
88
|
+
const contentType = args.contentType || detectContentType(filename);
|
|
89
|
+
// Fetch the image data
|
|
90
|
+
let buffer;
|
|
91
|
+
if (args.imageData) {
|
|
92
|
+
buffer = Buffer.from(args.imageData, "base64");
|
|
93
|
+
}
|
|
94
|
+
else if (args.imageUrl) {
|
|
95
|
+
const res = await fetch(args.imageUrl);
|
|
96
|
+
if (!res.ok)
|
|
97
|
+
throw new Error(`Failed to fetch image: HTTP ${res.status}`);
|
|
98
|
+
buffer = Buffer.from(await res.arrayBuffer());
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new Error("Either imageUrl or imageData (base64) is required.");
|
|
102
|
+
}
|
|
103
|
+
// Step 1: Initiate upload
|
|
104
|
+
const initiate = await api.request("POST", `/images/projects/${pid}/upload`, {
|
|
105
|
+
filename,
|
|
106
|
+
contentType,
|
|
107
|
+
fileSize: buffer.length,
|
|
108
|
+
});
|
|
109
|
+
// Step 2: Upload to presigned URL
|
|
110
|
+
await api.uploadToPresigned(initiate.uploadUrl, buffer, contentType);
|
|
111
|
+
// Step 3: Confirm
|
|
112
|
+
const confirmed = await api.request("POST", `/images/projects/${pid}/upload/confirm`, { imageId: initiate.imageId });
|
|
113
|
+
return ok(confirmed);
|
|
114
|
+
}
|
|
115
|
+
// ── Images ───────────────────────────────────────────────
|
|
116
|
+
case "list_images": {
|
|
117
|
+
const pid = getProjectId(args);
|
|
118
|
+
const params = new URLSearchParams();
|
|
119
|
+
if (args.limit)
|
|
120
|
+
params.set("limit", String(args.limit));
|
|
121
|
+
if (args.offset)
|
|
122
|
+
params.set("offset", String(args.offset));
|
|
123
|
+
const qs = params.toString();
|
|
124
|
+
return ok(await api.request("GET", `/images/projects/${pid}/images${qs ? `?${qs}` : ""}`));
|
|
125
|
+
}
|
|
126
|
+
case "update_image": {
|
|
127
|
+
const pid = getProjectId(args);
|
|
128
|
+
const body = {};
|
|
129
|
+
if (args.altText !== undefined)
|
|
130
|
+
body.altText = args.altText;
|
|
131
|
+
if (args.tags !== undefined)
|
|
132
|
+
body.tags = args.tags;
|
|
133
|
+
return ok(await api.request("PATCH", `/images/projects/${pid}/images/${args.imageId}`, body));
|
|
134
|
+
}
|
|
135
|
+
case "delete_image": {
|
|
136
|
+
const pid = getProjectId(args);
|
|
137
|
+
return ok(await api.request("DELETE", `/images/projects/${pid}/images/${args.imageId}`));
|
|
138
|
+
}
|
|
139
|
+
// ── Presets ──────────────────────────────────────────────
|
|
140
|
+
case "list_presets": {
|
|
141
|
+
const pid = getProjectId(args);
|
|
142
|
+
return ok(await api.request("GET", `/images/projects/${pid}/presets`));
|
|
143
|
+
}
|
|
144
|
+
case "create_preset": {
|
|
145
|
+
const pid = getProjectId(args);
|
|
146
|
+
return ok(await api.request("POST", `/images/projects/${pid}/presets`, {
|
|
147
|
+
name: args.name,
|
|
148
|
+
transforms: args.transforms,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
case "update_preset": {
|
|
152
|
+
const pid = getProjectId(args);
|
|
153
|
+
const body = {};
|
|
154
|
+
if (args.name !== undefined)
|
|
155
|
+
body.name = args.name;
|
|
156
|
+
if (args.transforms !== undefined)
|
|
157
|
+
body.transforms = args.transforms;
|
|
158
|
+
return ok(await api.request("PATCH", `/images/projects/${pid}/presets/${args.presetId}`, body));
|
|
159
|
+
}
|
|
160
|
+
case "delete_preset": {
|
|
161
|
+
const pid = getProjectId(args);
|
|
162
|
+
return ok(await api.request("DELETE", `/images/projects/${pid}/presets/${args.presetId}`));
|
|
163
|
+
}
|
|
164
|
+
// ── Signing ─────────────────────────────────────────────
|
|
165
|
+
case "get_signing_config": {
|
|
166
|
+
const pid = getProjectId(args);
|
|
167
|
+
return ok(await api.request("GET", `/images/projects/${pid}/signing`));
|
|
168
|
+
}
|
|
169
|
+
case "update_signing": {
|
|
170
|
+
const pid = getProjectId(args);
|
|
171
|
+
const body = {};
|
|
172
|
+
if (args.enabled !== undefined)
|
|
173
|
+
body.enabled = args.enabled;
|
|
174
|
+
if (args.requireSignedUrls !== undefined)
|
|
175
|
+
body.requireSignedUrls = args.requireSignedUrls;
|
|
176
|
+
return ok(await api.request("POST", `/images/projects/${pid}/signing`, body));
|
|
177
|
+
}
|
|
178
|
+
case "generate_signed_url": {
|
|
179
|
+
const pid = getProjectId(args);
|
|
180
|
+
return ok(await api.request("PUT", `/images/projects/${pid}/signing`, {
|
|
181
|
+
path: args.path,
|
|
182
|
+
params: args.params,
|
|
183
|
+
expiresIn: args.expiresIn,
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
// ── Usage ───────────────────────────────────────────────
|
|
187
|
+
case "get_usage": {
|
|
188
|
+
const pid = getProjectId(args);
|
|
189
|
+
const days = args.days ? `?days=${args.days}` : "";
|
|
190
|
+
return ok(await api.request("GET", `/images/projects/${pid}/usage${days}`));
|
|
191
|
+
}
|
|
192
|
+
// ── Utility ─────────────────────────────────────────────
|
|
193
|
+
case "build_cdn_url": {
|
|
194
|
+
const pid = getProjectId(args);
|
|
195
|
+
const cdnBase = args.cdnUrl || CDN_URL_DEFAULT;
|
|
196
|
+
const imagePath = args.imagePath;
|
|
197
|
+
const transforms = (args.transforms ?? {});
|
|
198
|
+
const paramMap = {
|
|
199
|
+
width: "w",
|
|
200
|
+
height: "h",
|
|
201
|
+
fit: "fit",
|
|
202
|
+
format: "f",
|
|
203
|
+
quality: "q",
|
|
204
|
+
qualityMode: "q",
|
|
205
|
+
dpr: "dpr",
|
|
206
|
+
gravity: "g",
|
|
207
|
+
blur: "blur",
|
|
208
|
+
sharpen: "sharpen",
|
|
209
|
+
radius: "r",
|
|
210
|
+
grayscale: "grayscale",
|
|
211
|
+
brightness: "brightness",
|
|
212
|
+
contrast: "contrast",
|
|
213
|
+
saturation: "saturation",
|
|
214
|
+
sepia: "sepia",
|
|
215
|
+
bg: "bg",
|
|
216
|
+
rotate: "rot",
|
|
217
|
+
flip: "flip",
|
|
218
|
+
};
|
|
219
|
+
const params = new URLSearchParams();
|
|
220
|
+
for (const [key, value] of Object.entries(transforms)) {
|
|
221
|
+
const param = paramMap[key];
|
|
222
|
+
if (param && value !== undefined && value !== null) {
|
|
223
|
+
params.set(param, String(value));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const qs = params.toString();
|
|
227
|
+
const url = `${cdnBase}/${pid}/${imagePath}${qs ? `?${qs}` : ""}`;
|
|
228
|
+
return ok({ url });
|
|
229
|
+
}
|
|
230
|
+
default:
|
|
231
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// ── Server setup ────────────────────────────────────────────────
|
|
235
|
+
const server = new Server({ name: "spronta", version: "0.1.0" }, { capabilities: { tools: {} } });
|
|
236
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
237
|
+
tools: TOOLS,
|
|
238
|
+
}));
|
|
239
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
240
|
+
const { name, arguments: args } = request.params;
|
|
241
|
+
try {
|
|
242
|
+
return await handleTool(name, (args ?? {}));
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
246
|
+
return {
|
|
247
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
248
|
+
isError: true,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
// ── Start ───────────────────────────────────────────────────────
|
|
253
|
+
async function main() {
|
|
254
|
+
const transport = new StdioServerTransport();
|
|
255
|
+
await server.connect(transport);
|
|
256
|
+
}
|
|
257
|
+
main().catch((error) => {
|
|
258
|
+
console.error("Fatal:", error);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
});
|
|
261
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,mEAAmE;AAEnE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;AAC5C,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,6BAA6B,CAAC;AAC7E,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAElD,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC1E,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAE7C,mEAAmE;AAEnE,SAAS,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;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,mEAAmE;AAEnE,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAiE/D,eAAO,MAAM,KAAK,EAAE,IAAI,EAySvB,CAAC"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool definitions for the Spronta Image CDN API.
|
|
3
|
+
* Each tool maps to one or more REST API calls.
|
|
4
|
+
*/
|
|
5
|
+
const projectIdParam = {
|
|
6
|
+
projectId: {
|
|
7
|
+
type: "string",
|
|
8
|
+
description: "Project ID (UUID). If omitted, uses SPRONTA_PROJECT_ID env var.",
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
const transformsSchema = {
|
|
12
|
+
type: "object",
|
|
13
|
+
description: "Image transform parameters",
|
|
14
|
+
properties: {
|
|
15
|
+
width: { type: "integer", description: "Width (1–8192)" },
|
|
16
|
+
height: { type: "integer", description: "Height (1–8192)" },
|
|
17
|
+
fit: {
|
|
18
|
+
type: "string",
|
|
19
|
+
enum: ["cover", "contain", "fill", "scale-down", "crop", "pad"],
|
|
20
|
+
},
|
|
21
|
+
format: {
|
|
22
|
+
type: "string",
|
|
23
|
+
enum: ["webp", "avif", "jpeg", "png", "jxl", "auto"],
|
|
24
|
+
},
|
|
25
|
+
quality: {
|
|
26
|
+
type: "integer",
|
|
27
|
+
description: "Quality 1–100, or use qualityMode",
|
|
28
|
+
},
|
|
29
|
+
qualityMode: { type: "string", enum: ["high", "medium", "low"] },
|
|
30
|
+
gravity: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: [
|
|
33
|
+
"auto",
|
|
34
|
+
"face",
|
|
35
|
+
"center",
|
|
36
|
+
"top",
|
|
37
|
+
"bottom",
|
|
38
|
+
"left",
|
|
39
|
+
"right",
|
|
40
|
+
"top-left",
|
|
41
|
+
"top-right",
|
|
42
|
+
"bottom-left",
|
|
43
|
+
"bottom-right",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
blur: { type: "integer", description: "Gaussian blur (1–250)" },
|
|
47
|
+
sharpen: {
|
|
48
|
+
type: "number",
|
|
49
|
+
description: "Unsharp mask (0–10)",
|
|
50
|
+
},
|
|
51
|
+
radius: { type: "integer", description: "Corner radius (1–9999)" },
|
|
52
|
+
grayscale: { type: "boolean" },
|
|
53
|
+
brightness: { type: "integer", description: "-100 to 100" },
|
|
54
|
+
contrast: { type: "number", description: "-100 to 100" },
|
|
55
|
+
saturation: { type: "integer", description: "-100 to 100" },
|
|
56
|
+
sepia: { type: "boolean" },
|
|
57
|
+
bg: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Background hex color (6 chars, no #)",
|
|
60
|
+
},
|
|
61
|
+
rotate: { type: "integer", enum: [90, 180, 270] },
|
|
62
|
+
flip: { type: "string", enum: ["h", "v"] },
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const TOOLS = [
|
|
66
|
+
// ── Projects ─────────────────────────────────────────────────
|
|
67
|
+
{
|
|
68
|
+
name: "list_projects",
|
|
69
|
+
description: "List all Spronta image projects for your account.",
|
|
70
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "create_project",
|
|
74
|
+
description: "Create a new image project.",
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties: {
|
|
78
|
+
name: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "Project name (1–100 chars)",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ["name"],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "get_project",
|
|
88
|
+
description: "Get project details including usage stats (image count, total storage).",
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: { ...projectIdParam },
|
|
92
|
+
required: [],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "update_project",
|
|
97
|
+
description: "Update a project's name or custom domain.",
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: {
|
|
101
|
+
...projectIdParam,
|
|
102
|
+
name: { type: "string", description: "New name (1–100 chars)" },
|
|
103
|
+
customDomain: {
|
|
104
|
+
type: "string",
|
|
105
|
+
description: "Custom CDN domain (max 253 chars), or null to remove",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
required: [],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "delete_project",
|
|
113
|
+
description: "Permanently delete a project and all its images. This cannot be undone.",
|
|
114
|
+
inputSchema: {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: { ...projectIdParam },
|
|
117
|
+
required: [],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
// ── Upload ───────────────────────────────────────────────────
|
|
121
|
+
{
|
|
122
|
+
name: "upload_image",
|
|
123
|
+
description: "Upload an image from a URL. Fetches the image, uploads it to Spronta, and returns the CDN URL with blurhash. For base64, pass imageData instead of imageUrl.",
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: "object",
|
|
126
|
+
properties: {
|
|
127
|
+
...projectIdParam,
|
|
128
|
+
imageUrl: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "URL of the image to upload",
|
|
131
|
+
},
|
|
132
|
+
imageData: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "Base64-encoded image data (alternative to imageUrl)",
|
|
135
|
+
},
|
|
136
|
+
filename: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "Filename for the image (e.g. hero.jpg)",
|
|
139
|
+
},
|
|
140
|
+
contentType: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: "MIME type (e.g. image/jpeg). Auto-detected if omitted.",
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
required: ["filename"],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
// ── Images ───────────────────────────────────────────────────
|
|
149
|
+
{
|
|
150
|
+
name: "list_images",
|
|
151
|
+
description: "List images in a project with pagination.",
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: "object",
|
|
154
|
+
properties: {
|
|
155
|
+
...projectIdParam,
|
|
156
|
+
limit: {
|
|
157
|
+
type: "integer",
|
|
158
|
+
description: "Max results, 1–100 (default 50)",
|
|
159
|
+
},
|
|
160
|
+
offset: {
|
|
161
|
+
type: "integer",
|
|
162
|
+
description: "Pagination offset (default 0)",
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
required: [],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "update_image",
|
|
170
|
+
description: "Update an image's alt text and/or tags.",
|
|
171
|
+
inputSchema: {
|
|
172
|
+
type: "object",
|
|
173
|
+
properties: {
|
|
174
|
+
...projectIdParam,
|
|
175
|
+
imageId: { type: "string", description: "Image ID (UUID)" },
|
|
176
|
+
altText: {
|
|
177
|
+
type: "string",
|
|
178
|
+
description: "Alt text (max 1000 chars), or null to remove",
|
|
179
|
+
},
|
|
180
|
+
tags: {
|
|
181
|
+
type: "array",
|
|
182
|
+
items: { type: "string" },
|
|
183
|
+
description: "Tags (max 50, each max 100 chars)",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
required: ["imageId"],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "delete_image",
|
|
191
|
+
description: "Permanently delete an image from storage and database. Cannot be undone.",
|
|
192
|
+
inputSchema: {
|
|
193
|
+
type: "object",
|
|
194
|
+
properties: {
|
|
195
|
+
...projectIdParam,
|
|
196
|
+
imageId: { type: "string", description: "Image ID (UUID)" },
|
|
197
|
+
},
|
|
198
|
+
required: ["imageId"],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
// ── Presets ──────────────────────────────────────────────────
|
|
202
|
+
{
|
|
203
|
+
name: "list_presets",
|
|
204
|
+
description: "List named transform presets. Presets can be used in CDN URLs with ?t=name.",
|
|
205
|
+
inputSchema: {
|
|
206
|
+
type: "object",
|
|
207
|
+
properties: { ...projectIdParam },
|
|
208
|
+
required: [],
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "create_preset",
|
|
213
|
+
description: "Create a named transform preset. Use in CDN URLs with ?t=preset-name.",
|
|
214
|
+
inputSchema: {
|
|
215
|
+
type: "object",
|
|
216
|
+
properties: {
|
|
217
|
+
...projectIdParam,
|
|
218
|
+
name: {
|
|
219
|
+
type: "string",
|
|
220
|
+
description: "Preset name (alphanumeric, hyphens, underscores, 1–64 chars)",
|
|
221
|
+
},
|
|
222
|
+
transforms: transformsSchema,
|
|
223
|
+
},
|
|
224
|
+
required: ["name", "transforms"],
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "update_preset",
|
|
229
|
+
description: "Update a preset's name or transforms.",
|
|
230
|
+
inputSchema: {
|
|
231
|
+
type: "object",
|
|
232
|
+
properties: {
|
|
233
|
+
...projectIdParam,
|
|
234
|
+
presetId: { type: "string", description: "Preset ID (UUID)" },
|
|
235
|
+
name: { type: "string", description: "New name" },
|
|
236
|
+
transforms: transformsSchema,
|
|
237
|
+
},
|
|
238
|
+
required: ["presetId"],
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "delete_preset",
|
|
243
|
+
description: "Delete a transform preset.",
|
|
244
|
+
inputSchema: {
|
|
245
|
+
type: "object",
|
|
246
|
+
properties: {
|
|
247
|
+
...projectIdParam,
|
|
248
|
+
presetId: { type: "string", description: "Preset ID (UUID)" },
|
|
249
|
+
},
|
|
250
|
+
required: ["presetId"],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
// ── Signing ──────────────────────────────────────────────────
|
|
254
|
+
{
|
|
255
|
+
name: "get_signing_config",
|
|
256
|
+
description: "Get the URL signing configuration for a project (enabled, requireSignedUrls, masked secret).",
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: { ...projectIdParam },
|
|
260
|
+
required: [],
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "update_signing",
|
|
265
|
+
description: "Enable/disable URL signing. When enabling, a new secret is generated and returned once.",
|
|
266
|
+
inputSchema: {
|
|
267
|
+
type: "object",
|
|
268
|
+
properties: {
|
|
269
|
+
...projectIdParam,
|
|
270
|
+
enabled: {
|
|
271
|
+
type: "boolean",
|
|
272
|
+
description: "true = generate new signing secret, false = disable signing",
|
|
273
|
+
},
|
|
274
|
+
requireSignedUrls: {
|
|
275
|
+
type: "boolean",
|
|
276
|
+
description: "When true, unsigned CDN URLs return 403",
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
required: [],
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "generate_signed_url",
|
|
284
|
+
description: "Generate an HMAC-SHA256 signed CDN URL. Requires signing to be enabled.",
|
|
285
|
+
inputSchema: {
|
|
286
|
+
type: "object",
|
|
287
|
+
properties: {
|
|
288
|
+
...projectIdParam,
|
|
289
|
+
path: {
|
|
290
|
+
type: "string",
|
|
291
|
+
description: "Image path (e.g. /my-project/hero.jpg)",
|
|
292
|
+
},
|
|
293
|
+
params: {
|
|
294
|
+
type: "object",
|
|
295
|
+
additionalProperties: { type: "string" },
|
|
296
|
+
description: "Transform params as key-value strings (e.g. {w: '800'})",
|
|
297
|
+
},
|
|
298
|
+
expiresIn: {
|
|
299
|
+
type: "integer",
|
|
300
|
+
description: "Expiration in seconds (60–604800)",
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
required: ["path"],
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
// ── Usage ────────────────────────────────────────────────────
|
|
307
|
+
{
|
|
308
|
+
name: "get_usage",
|
|
309
|
+
description: "Get daily usage metrics (requests, bandwidth, transforms) for a project.",
|
|
310
|
+
inputSchema: {
|
|
311
|
+
type: "object",
|
|
312
|
+
properties: {
|
|
313
|
+
...projectIdParam,
|
|
314
|
+
days: {
|
|
315
|
+
type: "integer",
|
|
316
|
+
description: "Lookback period, 1–90 (default 30)",
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
required: [],
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
// ── Utility ──────────────────────────────────────────────────
|
|
323
|
+
{
|
|
324
|
+
name: "build_cdn_url",
|
|
325
|
+
description: "Build a Spronta CDN URL with transform parameters. Does not make an API call.",
|
|
326
|
+
inputSchema: {
|
|
327
|
+
type: "object",
|
|
328
|
+
properties: {
|
|
329
|
+
...projectIdParam,
|
|
330
|
+
imagePath: {
|
|
331
|
+
type: "string",
|
|
332
|
+
description: "Image filename or path (e.g. hero.jpg)",
|
|
333
|
+
},
|
|
334
|
+
transforms: transformsSchema,
|
|
335
|
+
cdnUrl: {
|
|
336
|
+
type: "string",
|
|
337
|
+
description: "CDN base URL (default: https://cdn.spronta.com)",
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
required: ["imagePath"],
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
];
|
|
344
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,cAAc,GAAG;IACrB,SAAS,EAAE;QACT,IAAI,EAAE,QAAiB;QACvB,WAAW,EACT,iEAAiE;KACpE;CACF,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,QAAiB;IACvB,WAAW,EAAE,4BAA4B;IACzC,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,SAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE;QAClE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE;QACpE,GAAG,EAAE;YACH,IAAI,EAAE,QAAiB;YACvB,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC;SAChE;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAiB;YACvB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;SACrD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAkB;YACxB,WAAW,EAAE,mCAAmC;SACjD;QACD,WAAW,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE;QACzE,OAAO,EAAE;YACP,IAAI,EAAE,QAAiB;YACvB,IAAI,EAAE;gBACJ,MAAM;gBACN,MAAM;gBACN,QAAQ;gBACR,KAAK;gBACL,QAAQ;gBACR,MAAM;gBACN,OAAO;gBACP,UAAU;gBACV,WAAW;gBACX,aAAa;gBACb,cAAc;aACf;SACF;QACD,IAAI,EAAE,EAAE,IAAI,EAAE,SAAkB,EAAE,WAAW,EAAE,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;oBACd,WAAW,EACT,iDAAiD;iBACpD;aACF;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACF;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spronta/mcp",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Spronta Image CDN — MCP server for LLM integrations",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Spronta Image CDN — MCP server for LLM integrations. Upload, transform, and deliver images via AI agents.",
|
|
5
|
+
"mcpName": "io.github.spronta/images",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|