@raywake/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.
@@ -0,0 +1,52 @@
1
+ import { type Stats } from 'node:fs';
2
+ import { type FileHandle } from 'node:fs/promises';
3
+ export declare const UPLOAD_LIMITS: {
4
+ readonly 'image/jpeg': number;
5
+ readonly 'image/png': number;
6
+ readonly 'image/webp': number;
7
+ readonly 'video/mp4': number;
8
+ readonly 'video/quicktime': number;
9
+ readonly 'video/webm': number;
10
+ readonly 'audio/mpeg': number;
11
+ readonly 'audio/wav': number;
12
+ };
13
+ export type UploadType = keyof typeof UPLOAD_LIMITS;
14
+ export declare const LIMITS_TEXT = "JPEG/PNG/WebP up to 25 MB, MP4/MOV up to 200 MB, WebM up to 100 MB, MP3/WAV up to 50 MB";
15
+ export declare const ROOTS_ENV = "RAYWAKE_UPLOAD_ROOTS";
16
+ export declare class UploadError extends Error {
17
+ readonly code: string;
18
+ constructor(code: string, message: string);
19
+ }
20
+ /** Content type from the file's own first bytes; the extension only breaks MOV/MP4 ties. */
21
+ export declare function detectType(head: Buffer, extension?: string): UploadType | undefined;
22
+ export interface PathPolicy {
23
+ /** Replaces the default roots (home folder and working folder) when set. */
24
+ roots?: string[];
25
+ home?: string;
26
+ cwd?: string;
27
+ }
28
+ /** Parse RAYWAKE_UPLOAD_ROOTS: absolute folders separated by the platform path delimiter. */
29
+ export declare function parseRoots(value: string | undefined, home?: string): string[] | undefined;
30
+ export interface CheckedFile {
31
+ realPath: string;
32
+ name: string;
33
+ extension: string;
34
+ stats: Stats;
35
+ }
36
+ /** Resolve and vet a path without opening the file. */
37
+ export declare function checkPath(raw: string, policy?: PathPolicy): Promise<CheckedFile>;
38
+ export declare function unsupported(): UploadError;
39
+ export declare function tooLarge(type: UploadType, size: number): UploadError;
40
+ export interface OpenedFile extends CheckedFile {
41
+ handle: FileHandle;
42
+ contentType: UploadType;
43
+ size: number;
44
+ }
45
+ /** Open the vetted file, confirm it is the same file, and identify it from its first bytes. */
46
+ export declare function openMedia(raw: string, policy?: PathPolicy): Promise<OpenedFile>;
47
+ export declare function localHost(hostname: string): boolean;
48
+ /** Stream exactly `size` bytes of the file to a presigned PUT URL. Resolves with the HTTP status. */
49
+ export declare function putFile(url: URL, file: OpenedFile, options?: {
50
+ idleMs?: number;
51
+ signal?: AbortSignal;
52
+ }): Promise<number>;
package/dist/upload.js ADDED
@@ -0,0 +1,240 @@
1
+ import { constants } from 'node:fs';
2
+ import { open, realpath, stat } from 'node:fs/promises';
3
+ import { request as httpRequest } from 'node:http';
4
+ import { request as httpsRequest } from 'node:https';
5
+ import { homedir } from 'node:os';
6
+ import path from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ const MB = 1024 * 1024;
9
+ // Mirrors the gateway's upload allowlist; the gateway stays authoritative.
10
+ export const UPLOAD_LIMITS = {
11
+ 'image/jpeg': 25 * MB, 'image/png': 25 * MB, 'image/webp': 25 * MB,
12
+ 'video/mp4': 200 * MB, 'video/quicktime': 200 * MB, 'video/webm': 100 * MB,
13
+ 'audio/mpeg': 50 * MB, 'audio/wav': 50 * MB,
14
+ };
15
+ export const LIMITS_TEXT = 'JPEG/PNG/WebP up to 25 MB, MP4/MOV up to 200 MB, WebM up to 100 MB, MP3/WAV up to 50 MB';
16
+ export const ROOTS_ENV = 'RAYWAKE_UPLOAD_ROOTS';
17
+ // A file is opened only when its name already says it is an accepted media type.
18
+ const EXTENSIONS = {
19
+ '.jpg': ['image/jpeg'], '.jpeg': ['image/jpeg'], '.jpe': ['image/jpeg'], '.jfif': ['image/jpeg'],
20
+ '.png': ['image/png'], '.webp': ['image/webp'],
21
+ '.mp4': ['video/mp4', 'video/quicktime'], '.m4v': ['video/mp4', 'video/quicktime'],
22
+ '.mov': ['video/quicktime', 'video/mp4'], '.qt': ['video/quicktime', 'video/mp4'],
23
+ '.webm': ['video/webm'], '.mp3': ['audio/mpeg'], '.wav': ['audio/wav'],
24
+ };
25
+ export class UploadError extends Error {
26
+ code;
27
+ constructor(code, message) {
28
+ super(message);
29
+ this.code = code;
30
+ this.name = 'UploadError';
31
+ }
32
+ }
33
+ const ascii = (bytes, start, end) => bytes.subarray(start, end).toString('latin1');
34
+ // ISO media brands that are not a video the gateway accepts (audio-only MP4, HEIF/AVIF stills).
35
+ const NOT_VIDEO_BRANDS = new Set(['M4A ', 'M4B ', 'M4P ', 'F4A ', 'F4B ', 'heic', 'heix', 'hevc', 'hevx', 'heim', 'heis', 'mif1', 'msf1', 'avif', 'avis', 'crx ', 'jp2 ', 'jpx ']);
36
+ const QUICKTIME_ATOMS = new Set(['moov', 'mdat', 'wide', 'free', 'skip', 'pnot']);
37
+ /** Content type from the file's own first bytes; the extension only breaks MOV/MP4 ties. */
38
+ export function detectType(head, extension = '') {
39
+ if (head.length >= 3 && head[0] === 0xff && head[1] === 0xd8 && head[2] === 0xff)
40
+ return 'image/jpeg';
41
+ if (head.length >= 8 && head.subarray(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])))
42
+ return 'image/png';
43
+ if (head.length >= 12 && ascii(head, 0, 4) === 'RIFF') {
44
+ if (ascii(head, 8, 12) === 'WEBP')
45
+ return 'image/webp';
46
+ if (ascii(head, 8, 12) === 'WAVE')
47
+ return 'audio/wav';
48
+ return undefined;
49
+ }
50
+ if (head.length >= 4 && head.readUInt32BE(0) === 0x1a45dfa3) {
51
+ // EBML: WebM declares DocType "webm"; other Matroska files are not accepted.
52
+ return ascii(head, 4, Math.min(head.length, 64)).includes('webm') ? 'video/webm' : undefined;
53
+ }
54
+ if (head.length >= 12 && ascii(head, 4, 8) === 'ftyp') {
55
+ const brand = ascii(head, 8, 12);
56
+ if (brand === 'qt ')
57
+ return 'video/quicktime';
58
+ if (NOT_VIDEO_BRANDS.has(brand))
59
+ return undefined;
60
+ return 'video/mp4';
61
+ }
62
+ if (head.length >= 8 && QUICKTIME_ATOMS.has(ascii(head, 4, 8)) && ['.mov', '.qt'].includes(extension))
63
+ return 'video/quicktime';
64
+ if (head.length >= 3 && ascii(head, 0, 3) === 'ID3')
65
+ return 'audio/mpeg';
66
+ // MPEG audio frame sync with a defined layer (excludes ADTS AAC, whose layer bits are 00).
67
+ if (head.length >= 2 && head[0] === 0xff && (head[1] & 0xe0) === 0xe0 && (head[1] & 0x06) !== 0 && (head[1] & 0x18) !== 0x08)
68
+ return 'audio/mpeg';
69
+ return undefined;
70
+ }
71
+ /** Parse RAYWAKE_UPLOAD_ROOTS: absolute folders separated by the platform path delimiter. */
72
+ export function parseRoots(value, home = homedir()) {
73
+ if (value === undefined || !value.trim())
74
+ return undefined;
75
+ return value.split(path.delimiter).map(entry => entry.trim()).filter(Boolean)
76
+ .map(entry => expandHome(entry, home)).filter(entry => path.isAbsolute(entry)).map(entry => path.resolve(entry));
77
+ }
78
+ function expandHome(value, home) {
79
+ if (value === '~')
80
+ return home;
81
+ if (value.startsWith('~/') || value.startsWith('~\\'))
82
+ return path.join(home, value.slice(2));
83
+ return value;
84
+ }
85
+ function within(root, target) {
86
+ const relative = path.relative(root, target);
87
+ if (relative === '')
88
+ return '';
89
+ if (relative.startsWith('..') || path.isAbsolute(relative))
90
+ return undefined;
91
+ return relative;
92
+ }
93
+ function defaultRoots(home, cwd) {
94
+ const roots = [home];
95
+ // A client may start the server in "/" or another folder above home; that must not open the whole disk.
96
+ if (path.parse(cwd).root !== cwd && within(cwd, home) === undefined)
97
+ roots.push(cwd);
98
+ return roots;
99
+ }
100
+ async function realRoots(roots) {
101
+ const resolved = await Promise.all(roots.map(root => realpath(root).catch(() => undefined)));
102
+ return [...new Set([...roots, ...resolved.filter((root) => !!root)])];
103
+ }
104
+ /** Inside at least one root, and inside no hidden folder as seen from any root that contains it. */
105
+ function allowed(target, roots) {
106
+ const relatives = roots.map(root => within(root, target)).filter((relative) => relative !== undefined);
107
+ return relatives.length > 0 && !relatives.some(relative => relative.split(/[\\/]/).some(segment => segment.startsWith('.')));
108
+ }
109
+ function notAllowed(rootsText) {
110
+ return new UploadError('path_not_allowed', `This file is not in a folder Raywake may read (${rootsText}). Hidden and settings folders such as .ssh or .config are never read. Ask the user to move the file into an allowed folder, or to set ${ROOTS_ENV} in the MCP server configuration.`);
111
+ }
112
+ /** Resolve and vet a path without opening the file. */
113
+ export async function checkPath(raw, policy = {}) {
114
+ const home = path.resolve(policy.home ?? homedir());
115
+ const cwd = path.resolve(policy.cwd ?? process.cwd());
116
+ let value = raw.trim();
117
+ if (/^file:\/\//i.test(value)) {
118
+ try {
119
+ value = fileURLToPath(value);
120
+ }
121
+ catch {
122
+ throw new UploadError('not_found', 'This file:// address is not a valid local path. Pass the file path instead.');
123
+ }
124
+ }
125
+ else if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value) || /^data:/i.test(value)) {
126
+ throw new UploadError('not_a_local_file', 'upload_file takes a path to a file on this computer, not a link or data URI.');
127
+ }
128
+ if (!value || value.includes('\0'))
129
+ throw new UploadError('not_found', 'Pass the path of one file on this computer.');
130
+ const target = path.resolve(cwd, expandHome(value, home));
131
+ const configured = policy.roots !== undefined;
132
+ const roots = await realRoots(configured ? policy.roots : defaultRoots(home, cwd));
133
+ const rootsText = configured ? `${ROOTS_ENV}: ${policy.roots.join(path.delimiter) || 'none'}` : 'the home folder and the working folder';
134
+ const extension = path.extname(target).toLowerCase();
135
+ if (!EXTENSIONS[extension])
136
+ throw unsupported();
137
+ // Refuse before touching the disk, so paths outside the roots are not even probed for existence.
138
+ if (!allowed(target, roots))
139
+ throw notAllowed(rootsText);
140
+ let realPath;
141
+ try {
142
+ realPath = await realpath(target);
143
+ }
144
+ catch (error) {
145
+ const code = error.code;
146
+ if (code === 'EACCES' || code === 'EPERM')
147
+ throw new UploadError('not_readable', 'This file cannot be read: permission denied.');
148
+ throw new UploadError('not_found', 'File not found. Check the exact path, including the folder and extension.');
149
+ }
150
+ // Symlinks are judged by where they lead.
151
+ if (!allowed(realPath, roots))
152
+ throw notAllowed(rootsText);
153
+ const realExtension = path.extname(realPath).toLowerCase();
154
+ if (!EXTENSIONS[realExtension])
155
+ throw unsupported();
156
+ const stats = await stat(realPath).catch(() => { throw new UploadError('not_found', 'File not found.'); });
157
+ if (!stats.isFile())
158
+ throw new UploadError('not_a_file', 'This path is not a regular file. Pass one image, video or audio file.');
159
+ return { realPath, name: path.basename(target), extension: realExtension, stats };
160
+ }
161
+ export function unsupported() {
162
+ return new UploadError('unsupported_type', `Unsupported file type. Accepted: ${LIMITS_TEXT}. Do not convert or re-encode the user's file without asking them.`);
163
+ }
164
+ export function tooLarge(type, size) {
165
+ const limit = UPLOAD_LIMITS[type] / MB;
166
+ return new UploadError('too_large', `This file is too large: ${(size / MB).toFixed(1)} MB, and ${type} files can be at most ${limit} MB. Do not shrink, trim or re-encode the user's file without asking them.`);
167
+ }
168
+ /** Open the vetted file, confirm it is the same file, and identify it from its first bytes. */
169
+ export async function openMedia(raw, policy = {}) {
170
+ const checked = await checkPath(raw, policy);
171
+ const size = checked.stats.size;
172
+ if (size < 1)
173
+ throw new UploadError('empty_file', 'This file is empty.');
174
+ // Reject on size before reading anything when no accepted type could hold it.
175
+ const candidates = EXTENSIONS[checked.extension];
176
+ if (size > Math.max(...Object.values(UPLOAD_LIMITS)))
177
+ throw tooLarge(candidates[0], size);
178
+ let handle;
179
+ try {
180
+ handle = await open(checked.realPath, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
181
+ }
182
+ catch {
183
+ throw new UploadError('not_readable', 'This file cannot be opened for reading.');
184
+ }
185
+ try {
186
+ const opened = await handle.stat();
187
+ if (!opened.isFile() || opened.ino !== checked.stats.ino || opened.dev !== checked.stats.dev || opened.size !== size) {
188
+ throw new UploadError('file_changed', 'The file changed while it was being checked. Try again once it is saved.');
189
+ }
190
+ const head = Buffer.alloc(Math.min(64, size));
191
+ await handle.read(head, 0, head.length, 0);
192
+ const contentType = detectType(head, checked.extension);
193
+ if (!contentType)
194
+ throw unsupported();
195
+ if (size > UPLOAD_LIMITS[contentType])
196
+ throw tooLarge(contentType, size);
197
+ return { ...checked, handle, contentType, size };
198
+ }
199
+ catch (error) {
200
+ await handle.close();
201
+ throw error;
202
+ }
203
+ }
204
+ export function localHost(hostname) {
205
+ return ['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
206
+ }
207
+ /** Stream exactly `size` bytes of the file to a presigned PUT URL. Resolves with the HTTP status. */
208
+ export function putFile(url, file, options = {}) {
209
+ return new Promise((resolve, reject) => {
210
+ const send = url.protocol === 'https:' ? httpsRequest : httpRequest;
211
+ let status;
212
+ let settled = false;
213
+ const finish = (error) => {
214
+ if (settled)
215
+ return;
216
+ settled = true;
217
+ if (status !== undefined)
218
+ resolve(status);
219
+ else
220
+ reject(error ?? new Error('Upload ended without a response.'));
221
+ };
222
+ const request = send(url, {
223
+ method: 'PUT',
224
+ // Both headers are part of the signature: the bytes must be exactly this type and length.
225
+ headers: { 'Content-Type': file.contentType, 'Content-Length': String(file.size) },
226
+ signal: options.signal,
227
+ }, (response) => {
228
+ status = response.statusCode ?? 0;
229
+ response.resume();
230
+ response.on('end', () => finish());
231
+ response.on('error', error => finish(error));
232
+ });
233
+ request.setTimeout(options.idleMs ?? 60_000, () => request.destroy(new Error('Upload stalled.')));
234
+ request.on('error', error => finish(error));
235
+ const stream = file.handle.createReadStream({ start: 0, end: file.size - 1, autoClose: false, highWaterMark: 1024 * 1024 });
236
+ stream.on('error', error => request.destroy(error));
237
+ stream.pipe(request);
238
+ });
239
+ }
240
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAwB,MAAM,WAAW,CAAC;AACzE,OAAO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AAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;QAC5H,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@raywake/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "500+ AI image, video and audio models in Claude, ChatGPT, Cursor and any MCP client.",
5
+ "type": "module",
6
+ "bin": {
7
+ "raywake-mcp": "dist/index.js"
8
+ },
9
+ "main": "dist/server.js",
10
+ "types": "dist/server.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/server.d.ts",
14
+ "import": "./dist/server.js"
15
+ },
16
+ "./client": {
17
+ "types": "./dist/client.d.ts",
18
+ "import": "./dist/client.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "license": "MIT",
28
+ "author": "Raywake",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/oguzhankayan/raywake-mcp.git"
32
+ },
33
+ "homepage": "https://raywake.si",
34
+ "mcpName": "si.raywake/mcp",
35
+ "keywords": [
36
+ "raywake",
37
+ "mcp",
38
+ "ai",
39
+ "image",
40
+ "video",
41
+ "audio"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc && node scripts/make-executable.mjs",
48
+ "test": "npm run build && vitest run",
49
+ "smoke": "node scripts/smoke.mjs",
50
+ "prepack": "npm run build"
51
+ },
52
+ "dependencies": {
53
+ "@modelcontextprotocol/sdk": "^1.30.0",
54
+ "zod": "^3.25.76"
55
+ },
56
+ "devDependencies": {
57
+ "@types/node": "^22.0.0",
58
+ "typescript": "^5.9.3",
59
+ "vitest": "^4.1.11"
60
+ }
61
+ }