@strapi/upload 5.53.0 → 5.54.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/dist/admin/future/components/UploadProgressDialog.js +9 -8
- package/dist/admin/future/components/UploadProgressDialog.js.map +1 -1
- package/dist/admin/future/components/UploadProgressDialog.mjs +9 -8
- package/dist/admin/future/components/UploadProgressDialog.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/AssetsPage.js +0 -2
- package/dist/admin/future/pages/Assets/AssetsPage.js.map +1 -1
- package/dist/admin/future/pages/Assets/AssetsPage.mjs +0 -2
- package/dist/admin/future/pages/Assets/AssetsPage.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.js +7 -0
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.mjs +7 -0
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.js +4 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.mjs +4 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.mjs.map +1 -1
- package/dist/admin/future/services/api.js +17 -0
- package/dist/admin/future/services/api.js.map +1 -1
- package/dist/admin/future/services/api.mjs +18 -1
- package/dist/admin/future/services/api.mjs.map +1 -1
- package/dist/admin/future/store/uploadProgress.js +31 -22
- package/dist/admin/future/store/uploadProgress.js.map +1 -1
- package/dist/admin/future/store/uploadProgress.mjs +31 -22
- package/dist/admin/future/store/uploadProgress.mjs.map +1 -1
- package/dist/admin/index.js +11 -10
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +11 -10
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/src/future/store/uploadProgress.d.ts +14 -20
- package/dist/admin/translations/en.json.js +0 -3
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +0 -3
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/bootstrap.js +11 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +11 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/admin-upload.js +31 -1
- package/dist/server/controllers/admin-upload.js.map +1 -1
- package/dist/server/controllers/admin-upload.mjs +31 -1
- package/dist/server/controllers/admin-upload.mjs.map +1 -1
- package/dist/server/controllers/utils/find-entity-and-check-permissions.js +15 -4
- package/dist/server/controllers/utils/find-entity-and-check-permissions.js.map +1 -1
- package/dist/server/controllers/utils/find-entity-and-check-permissions.mjs +15 -4
- package/dist/server/controllers/utils/find-entity-and-check-permissions.mjs.map +1 -1
- package/dist/server/controllers/utils/folders.js +1 -1
- package/dist/server/controllers/utils/folders.js.map +1 -1
- package/dist/server/controllers/utils/folders.mjs +1 -1
- package/dist/server/controllers/utils/folders.mjs.map +1 -1
- package/dist/server/mcp/ambient-instance.js +46 -0
- package/dist/server/mcp/ambient-instance.js.map +1 -0
- package/dist/server/mcp/ambient-instance.mjs +43 -0
- package/dist/server/mcp/ambient-instance.mjs.map +1 -0
- package/dist/server/mcp/handlers/constants.js +60 -0
- package/dist/server/mcp/handlers/constants.js.map +1 -0
- package/dist/server/mcp/handlers/constants.mjs +45 -0
- package/dist/server/mcp/handlers/constants.mjs.map +1 -0
- package/dist/server/mcp/handlers/folder-handlers.js +308 -0
- package/dist/server/mcp/handlers/folder-handlers.js.map +1 -0
- package/dist/server/mcp/handlers/folder-handlers.mjs +303 -0
- package/dist/server/mcp/handlers/folder-handlers.mjs.map +1 -0
- package/dist/server/mcp/handlers/read-handlers.js +134 -0
- package/dist/server/mcp/handlers/read-handlers.js.map +1 -0
- package/dist/server/mcp/handlers/read-handlers.mjs +130 -0
- package/dist/server/mcp/handlers/read-handlers.mjs.map +1 -0
- package/dist/server/mcp/handlers/write-handlers.js +315 -0
- package/dist/server/mcp/handlers/write-handlers.js.map +1 -0
- package/dist/server/mcp/handlers/write-handlers.mjs +311 -0
- package/dist/server/mcp/handlers/write-handlers.mjs.map +1 -0
- package/dist/server/mcp/permissions.js +36 -0
- package/dist/server/mcp/permissions.js.map +1 -0
- package/dist/server/mcp/permissions.mjs +33 -0
- package/dist/server/mcp/permissions.mjs.map +1 -0
- package/dist/server/mcp/register-upload-mcp-tools.js +235 -0
- package/dist/server/mcp/register-upload-mcp-tools.js.map +1 -0
- package/dist/server/mcp/register-upload-mcp-tools.mjs +232 -0
- package/dist/server/mcp/register-upload-mcp-tools.mjs.map +1 -0
- package/dist/server/mcp/sanitizers/sanitize-media.js +97 -0
- package/dist/server/mcp/sanitizers/sanitize-media.js.map +1 -0
- package/dist/server/mcp/sanitizers/sanitize-media.mjs +93 -0
- package/dist/server/mcp/sanitizers/sanitize-media.mjs.map +1 -0
- package/dist/server/mcp/schemas/input-schemas.js +206 -0
- package/dist/server/mcp/schemas/input-schemas.js.map +1 -0
- package/dist/server/mcp/schemas/input-schemas.mjs +190 -0
- package/dist/server/mcp/schemas/input-schemas.mjs.map +1 -0
- package/dist/server/mcp/schemas/output-schemas.js +158 -0
- package/dist/server/mcp/schemas/output-schemas.js.map +1 -0
- package/dist/server/mcp/schemas/output-schemas.mjs +142 -0
- package/dist/server/mcp/schemas/output-schemas.mjs.map +1 -0
- package/dist/server/mcp/utils.js +14 -0
- package/dist/server/mcp/utils.js.map +1 -0
- package/dist/server/mcp/utils.mjs +12 -0
- package/dist/server/mcp/utils.mjs.map +1 -0
- package/dist/server/media-library-default-notice.js +42 -0
- package/dist/server/media-library-default-notice.js.map +1 -0
- package/dist/server/media-library-default-notice.mjs +40 -0
- package/dist/server/media-library-default-notice.mjs.map +1 -0
- package/dist/server/register.js +5 -0
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +5 -0
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/services/folder.js.map +1 -1
- package/dist/server/services/folder.mjs.map +1 -1
- package/dist/server/services/upload.js +14 -2
- package/dist/server/services/upload.js.map +1 -1
- package/dist/server/services/upload.mjs +14 -2
- package/dist/server/services/upload.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/admin-upload.d.ts +1 -0
- package/dist/server/src/controllers/admin-upload.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/find-entity-and-check-permissions.d.ts +14 -1
- package/dist/server/src/controllers/utils/find-entity-and-check-permissions.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/folders.d.ts +2 -1
- package/dist/server/src/controllers/utils/folders.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +8 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/ambient-instance.d.ts +65 -0
- package/dist/server/src/mcp/ambient-instance.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/constants.d.ts +48 -0
- package/dist/server/src/mcp/handlers/constants.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/folder-handlers.d.ts +49 -0
- package/dist/server/src/mcp/handlers/folder-handlers.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/index.d.ts +5 -0
- package/dist/server/src/mcp/handlers/index.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/read-handlers.d.ts +35 -0
- package/dist/server/src/mcp/handlers/read-handlers.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/write-handlers.d.ts +66 -0
- package/dist/server/src/mcp/handlers/write-handlers.d.ts.map +1 -0
- package/dist/server/src/mcp/index.d.ts +3 -0
- package/dist/server/src/mcp/index.d.ts.map +1 -0
- package/dist/server/src/mcp/permissions.d.ts +22 -0
- package/dist/server/src/mcp/permissions.d.ts.map +1 -0
- package/dist/server/src/mcp/register-upload-mcp-tools.d.ts +29 -0
- package/dist/server/src/mcp/register-upload-mcp-tools.d.ts.map +1 -0
- package/dist/server/src/mcp/sanitizers/sanitize-media.d.ts +63 -0
- package/dist/server/src/mcp/sanitizers/sanitize-media.d.ts.map +1 -0
- package/dist/server/src/mcp/schemas/index.d.ts +3 -0
- package/dist/server/src/mcp/schemas/index.d.ts.map +1 -0
- package/dist/server/src/mcp/schemas/input-schemas.d.ts +148 -0
- package/dist/server/src/mcp/schemas/input-schemas.d.ts.map +1 -0
- package/dist/server/src/mcp/schemas/output-schemas.d.ts +276 -0
- package/dist/server/src/mcp/schemas/output-schemas.d.ts.map +1 -0
- package/dist/server/src/mcp/types.d.ts +19 -0
- package/dist/server/src/mcp/types.d.ts.map +1 -0
- package/dist/server/src/mcp/utils.d.ts +4 -0
- package/dist/server/src/mcp/utils.d.ts.map +1 -0
- package/dist/server/src/media-library-default-notice.d.ts +19 -0
- package/dist/server/src/media-library-default-notice.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/folder.d.ts +6 -2
- package/dist/server/src/services/folder.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +8 -2
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/upload.d.ts +8 -1
- package/dist/server/src/services/upload.d.ts.map +1 -1
- package/dist/server/src/types.d.ts +2 -2
- package/dist/server/src/types.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/utils/index.js +2 -2
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs +2 -2
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/shared/contracts/files.d.ts +22 -0
- package/dist/shared/contracts/files.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/admin/future/components/BetaNotice.js +0 -72
- package/dist/admin/future/components/BetaNotice.js.map +0 -1
- package/dist/admin/future/components/BetaNotice.mjs +0 -70
- package/dist/admin/future/components/BetaNotice.mjs.map +0 -1
- package/dist/admin/src/future/components/BetaNotice.d.ts +0 -11
|
@@ -321,6 +321,12 @@ declare const _default: () => {
|
|
|
321
321
|
replace: (id: string | number, { data, file }: {
|
|
322
322
|
data: {
|
|
323
323
|
fileInfo: import("./types").FileInfo;
|
|
324
|
+
} & {
|
|
325
|
+
refId?: string | number;
|
|
326
|
+
ref?: string;
|
|
327
|
+
field?: string;
|
|
328
|
+
path?: string;
|
|
329
|
+
tmpWorkingDirectory?: string;
|
|
324
330
|
};
|
|
325
331
|
file: import("./types").InputFile;
|
|
326
332
|
}, opts?: {
|
|
@@ -367,14 +373,14 @@ declare const _default: () => {
|
|
|
367
373
|
};
|
|
368
374
|
}) => Promise<any>;
|
|
369
375
|
exists: (params?: {}) => Promise<boolean>;
|
|
370
|
-
deleteByIds: (ids?:
|
|
376
|
+
deleteByIds: (ids?: number[]) => Promise<{
|
|
371
377
|
folders: any[];
|
|
372
378
|
totalFolderNumber: number;
|
|
373
379
|
totalFileNumber: number;
|
|
374
380
|
}>;
|
|
375
381
|
update: (id: number, { name, parent, }: {
|
|
376
382
|
name: string;
|
|
377
|
-
parent
|
|
383
|
+
parent?: number | null;
|
|
378
384
|
}, { user }: {
|
|
379
385
|
user: {
|
|
380
386
|
id: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;gCAKxC,CAAC;oCAAmC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAW00G,CAAC;mBAAe,CAAC;qBAAqB,CAAC;oBAAoB,CAAC;mCAAmC,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;gCAKxC,CAAC;oCAAmC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAW00G,CAAC;mBAAe,CAAC;qBAAqB,CAAC;oBAAoB,CAAC;mCAAmC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAv1B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AATznF,wBAQG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
/**
|
|
3
|
+
* Asserts that an MCP handler's Strapi instance is the ambient `global.strapi`.
|
|
4
|
+
*
|
|
5
|
+
* Two of the upload plugin's services — `folder` and `file` — are registered as plain object
|
|
6
|
+
* literals rather than factories (see `services/index.ts`), so their methods close over the
|
|
7
|
+
* module-scope ambient `strapi` and query `global.strapi.db` regardless of which instance is
|
|
8
|
+
* passed to `getService`. Passing an instance therefore selects the right plugin registry but
|
|
9
|
+
* does *not* bind the queries to it.
|
|
10
|
+
*
|
|
11
|
+
* The folder tools reach `folder` directly. The asset write tools reach `file` transitively:
|
|
12
|
+
* `upload.updateFileInfo` resolves it with a bare `getService('file')` (`services/upload.ts`),
|
|
13
|
+
* and `file.getFolderPath` then queries the ambient `strapi.db`. So a handler that looks
|
|
14
|
+
* instance-bound can still mix ambient reads with instance-bound writes.
|
|
15
|
+
*
|
|
16
|
+
* Threading an instance through both services is a broader refactor than the MCP surface should
|
|
17
|
+
* carry: `create`, `update` and `deleteByIds` reach for `strapi.db`, `strapi.eventHub` and
|
|
18
|
+
* `strapi.getModel`, `update` runs a multi-statement transaction, and every admin controller and
|
|
19
|
+
* validator already depends on the ambient form.
|
|
20
|
+
*
|
|
21
|
+
* So the dependency is made explicit and asserted instead. Handlers call this in their factory
|
|
22
|
+
* body — at handler construction, not per call — so a mismatch fails while the tool is being
|
|
23
|
+
* registered rather than surfacing to an agent as tool output mid-conversation.
|
|
24
|
+
*
|
|
25
|
+
* A single-app server is unaffected: `createStrapi` assigns its instance to `global.strapi`, so
|
|
26
|
+
* the two agree. If they ever diverge — a second Strapi instance in one process — this throws
|
|
27
|
+
* rather than silently reading or writing the wrong app's media library.
|
|
28
|
+
*/
|
|
29
|
+
export declare const assertAmbientInstance: (strapi: Core.Strapi) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves the `folder` service for an MCP handler.
|
|
32
|
+
*
|
|
33
|
+
* A bare `getService('folder', strapi)` reads as instance-bound but is not — see
|
|
34
|
+
* `assertAmbientInstance` for why. Handlers assert the instance once at construction; this keeps
|
|
35
|
+
* the resolution behind a named helper so the call sites do not reintroduce the misleading form.
|
|
36
|
+
*/
|
|
37
|
+
export declare const getFolderService: (strapi: Core.Strapi) => {
|
|
38
|
+
create: (folderData: Pick<import("../types").Folder, "name" | "parent">, opts?: {
|
|
39
|
+
user: {
|
|
40
|
+
id: string | number;
|
|
41
|
+
};
|
|
42
|
+
}) => Promise<any>;
|
|
43
|
+
exists: (params?: {}) => Promise<boolean>;
|
|
44
|
+
deleteByIds: (ids?: number[]) => Promise<{
|
|
45
|
+
folders: any[];
|
|
46
|
+
totalFolderNumber: number;
|
|
47
|
+
totalFileNumber: number;
|
|
48
|
+
}>;
|
|
49
|
+
update: (id: number, { name, parent, }: {
|
|
50
|
+
name: string;
|
|
51
|
+
parent?: number | null;
|
|
52
|
+
}, { user }: {
|
|
53
|
+
user: {
|
|
54
|
+
id: string | number;
|
|
55
|
+
};
|
|
56
|
+
}) => Promise<any>;
|
|
57
|
+
setPathIdAndPath: (folder: Pick<import("../types").Folder, "parent">) => Promise<Pick<import("../types").Folder, "parent"> & {
|
|
58
|
+
pathId: number;
|
|
59
|
+
path: string;
|
|
60
|
+
}>;
|
|
61
|
+
getStructure: () => Promise<number[] & (Partial<import("../types").Folder> & {
|
|
62
|
+
children: (Partial<import("../types").Folder> & /*elided*/ any)[];
|
|
63
|
+
})[]>;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=ambient-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient-instance.d.ts","sourceRoot":"","sources":["../../../../server/src/mcp/ambient-instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,IAAI,CAAC,MAAM,SASxD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,IAAI,CAAC,MAAM;;;;;;;;;;;;;;cACwX,CAAC;;;;;;;;;;;;;CADxV,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const MCP_NOT_FOUND_ASSET = "Media asset not found.";
|
|
2
|
+
export declare const MCP_UPDATE_ASSET_NO_FIELDS = "Provide at least one field to update: name, alternativeText or caption. To move an asset between folders use media_move_assets; url, mime, size and the file contents are owned by the upload provider and cannot be edited over MCP.";
|
|
3
|
+
export declare const MCP_NOT_FOUND_FOLDER = "Media folder not found.";
|
|
4
|
+
export declare const MCP_FOLDER_NAME_TAKEN = "A folder with this name already exists in the same parent folder. Folder names must be unique among siblings.";
|
|
5
|
+
export declare const MCP_PARENT_FOLDER_NOT_FOUND = "The parent folder does not exist. Use media_list_folders to discover valid folder ids, or pass null for the media library root.";
|
|
6
|
+
export declare const MCP_FOLDER_MOVE_INTO_SELF = "A folder cannot be moved into itself or into one of its own descendants.";
|
|
7
|
+
/**
|
|
8
|
+
* Returned when `media_delete_folder` is handed any id that does not resolve to a folder.
|
|
9
|
+
*
|
|
10
|
+
* Names the offending ids, because the call rejects as a whole: the agent has to know which
|
|
11
|
+
* entries to drop or correct, and cannot infer that from a generic failure. Folder ids and
|
|
12
|
+
* asset ids are indistinguishable integers, so an asset id is the likeliest cause and is named
|
|
13
|
+
* first — but a deleted or never-existent folder id looks the same from here, so the message
|
|
14
|
+
* covers both rather than asserting one.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MCP_DELETE_FOLDER_UNRESOLVED_IDS: (ids: number[]) => string;
|
|
17
|
+
export declare const MCP_MOVE_ASSETS_DESTINATION_NOT_FOUND = "The destination folder does not exist. Use media_list_folders to discover valid folder ids, or pass null for the media library root.";
|
|
18
|
+
/** Per-id `failed` reasons for `media_move_assets`. Both are per asset, so the wording names the id's fate, not the call's. */
|
|
19
|
+
export declare const MCP_MOVE_ASSETS_ID_NOT_FOUND = "No media asset has this id, so nothing was moved for it. If this is a folder id, use media_move_folder \u2014 and note that a folder id only fails like this when no asset happens to share the number; when one does, media_move_assets moves that asset instead. Otherwise the asset may already be deleted \u2014 use media_list_assets to discover valid asset ids.";
|
|
20
|
+
export declare const MCP_MOVE_ASSETS_ID_FORBIDDEN = "This token is not allowed to edit this asset. A permission condition on plugin::upload.assets.update excludes it.";
|
|
21
|
+
/**
|
|
22
|
+
* Returned when the move of one asset failed for a reason that is not a missing asset or a
|
|
23
|
+
* permission denial — a DB error, say, or an upload-provider fault.
|
|
24
|
+
*
|
|
25
|
+
* Reported per id rather than thrown: a tool error carries no `structuredContent`, so throwing
|
|
26
|
+
* would discard the report naming the assets that had already moved in the same call.
|
|
27
|
+
* `cause` is the underlying message, kept verbatim so the real fault stays legible.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MCP_MOVE_ASSETS_ID_FAILED: (cause: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Per-id `failed` reasons for `media_delete_assets`, and the dry-run's `failed` reason.
|
|
32
|
+
*
|
|
33
|
+
* Reported per id rather than thrown, because a delete is irreversible: an error carries no
|
|
34
|
+
* `structuredContent`, so throwing on the third id would discard the report saying the first
|
|
35
|
+
* two are already gone — and no re-read can recover what was deleted.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MCP_DELETE_ASSETS_ID_NOT_FOUND = "No media asset has this id, so nothing was deleted for it. If this is a folder id, use media_delete_folder \u2014 and note that a folder id only fails like this when no asset happens to share the number; when one does, media_delete_assets deletes that asset instead. Otherwise the asset may already be deleted; use media_list_assets to discover valid asset ids.";
|
|
38
|
+
export declare const MCP_DELETE_ASSETS_ID_FORBIDDEN = "This token is not allowed to delete this asset. A permission condition on plugin::upload.assets.update excludes it.";
|
|
39
|
+
/**
|
|
40
|
+
* Returned when the deletion of one asset failed for a reason that is not a missing asset or a
|
|
41
|
+
* permission denial — a DB error, say, or an upload-provider fault.
|
|
42
|
+
*
|
|
43
|
+
* `cause` is the underlying message, kept verbatim so the real fault stays legible. The asset
|
|
44
|
+
* may be half-removed (the provider file gone, the row still present, or the reverse), so the
|
|
45
|
+
* wording tells the agent to re-read rather than assume either outcome.
|
|
46
|
+
*/
|
|
47
|
+
export declare const MCP_DELETE_ASSETS_ID_FAILED: (cause: string) => string;
|
|
48
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/handlers/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,0BAA0B,0OACkM,CAAC;AAE1O,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D,eAAO,MAAM,qBAAqB,kHAC+E,CAAC;AAElH,eAAO,MAAM,2BAA2B,oIAC2F,CAAC;AAEpI,eAAO,MAAM,yBAAyB,6EACsC,CAAC;AAE7E;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,GAAI,KAAK,MAAM,EAAE,WACgV,CAAC;AAE/Y,eAAO,MAAM,qCAAqC,yIACsF,CAAC;AAEzI,+HAA+H;AAC/H,eAAO,MAAM,4BAA4B,4WACwT,CAAC;AAElW,eAAO,MAAM,4BAA4B,sHAC4E,CAAC;AAEtH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,WACsJ,CAAC;AAE9M;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,8WAC6T,CAAC;AAEzW,eAAO,MAAM,8BAA8B,wHAC4E,CAAC;AAExH;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,WAC6H,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Core, Modules } from '@strapi/types';
|
|
2
|
+
/**
|
|
3
|
+
* `media_create_folder` — a new folder, optionally nested.
|
|
4
|
+
*
|
|
5
|
+
* Gated on `plugin::upload.assets.create` and mirrors `POST /upload/folders`: the same
|
|
6
|
+
* permission, the same uniqueness and parent-existence validation, the same `folder.create()`
|
|
7
|
+
* call, and the same `createdBy` attribution from the session user.
|
|
8
|
+
*
|
|
9
|
+
* `create` rather than the `update` the other folder tools use: creating a folder is the one
|
|
10
|
+
* folder operation whose admin route gates on `assets.create`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createMediaCreateFolderHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
13
|
+
args: Record<string, unknown>;
|
|
14
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
15
|
+
/**
|
|
16
|
+
* `media_rename_folder` — changes a folder's name and nothing else.
|
|
17
|
+
*
|
|
18
|
+
* Deliberately does not forward `parent` to `folder.update()`: the service branches on
|
|
19
|
+
* `isUndefined(parent)`, and the name-only branch skips the transaction that rewrites descendant
|
|
20
|
+
* paths. Passing the folder's existing parent would take the move branch and rewrite the whole
|
|
21
|
+
* subtree to compute the identical paths.
|
|
22
|
+
*/
|
|
23
|
+
export declare const createMediaRenameFolderHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
26
|
+
/**
|
|
27
|
+
* `media_move_folder` — re-parents a folder, carrying its whole subtree with it.
|
|
28
|
+
*
|
|
29
|
+
* `folder.update()` recalculates the materialized `path` of every descendant folder and the
|
|
30
|
+
* `folderPath` of every contained file inside a transaction, so the move is atomic and no
|
|
31
|
+
* separate bookkeeping is needed here.
|
|
32
|
+
*/
|
|
33
|
+
export declare const createMediaMoveFolderHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
34
|
+
args: Record<string, unknown>;
|
|
35
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
36
|
+
/**
|
|
37
|
+
* `media_delete_folder` — previews or performs a cascading folder deletion.
|
|
38
|
+
*
|
|
39
|
+
* Two branches behind one tool, because the preview and the deletion must agree on what the
|
|
40
|
+
* cascade covers; splitting them across tools would let the two drift apart, and an agent could
|
|
41
|
+
* reach the destructive one without ever seeing a count.
|
|
42
|
+
*
|
|
43
|
+
* `dryRun` defaults to true (see the input schema): omitting the flag previews, and deleting
|
|
44
|
+
* takes an explicit `dryRun: false`.
|
|
45
|
+
*/
|
|
46
|
+
export declare const createMediaDeleteFolderHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
47
|
+
args: Record<string, unknown>;
|
|
48
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
49
|
+
//# sourceMappingURL=folder-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder-handlers.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/handlers/folder-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA4KnD;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,GACzC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAY7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GACzC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAsB7C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAyB7C,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,8BAA8B,GACzC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAuD7C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createMediaListAssetsHandler, createMediaGetAssetHandler, createMediaListFoldersHandler, } from './read-handlers';
|
|
2
|
+
export { createMediaUpdateAssetHandler, createMediaMoveAssetsHandler, createMediaDeleteAssetsHandler, } from './write-handlers';
|
|
3
|
+
export { createMediaCreateFolderHandler, createMediaRenameFolderHandler, createMediaMoveFolderHandler, createMediaDeleteFolderHandler, } from './folder-handlers';
|
|
4
|
+
export { MCP_NOT_FOUND_ASSET, MCP_UPDATE_ASSET_NO_FIELDS, MCP_NOT_FOUND_FOLDER, MCP_FOLDER_NAME_TAKEN, MCP_PARENT_FOLDER_NOT_FOUND, MCP_FOLDER_MOVE_INTO_SELF, MCP_DELETE_FOLDER_UNRESOLVED_IDS, MCP_MOVE_ASSETS_DESTINATION_NOT_FOUND, MCP_MOVE_ASSETS_ID_NOT_FOUND, MCP_MOVE_ASSETS_ID_FORBIDDEN, MCP_MOVE_ASSETS_ID_FAILED, MCP_DELETE_ASSETS_ID_NOT_FOUND, MCP_DELETE_ASSETS_ID_FORBIDDEN, MCP_DELETE_ASSETS_ID_FAILED, } from './constants';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,gCAAgC,EAChC,qCAAqC,EACrC,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Core, Modules } from '@strapi/types';
|
|
2
|
+
/**
|
|
3
|
+
* `media_list_assets` — paginated, filtered listing of media files.
|
|
4
|
+
*
|
|
5
|
+
* Permission conditions are applied through the permissions manager
|
|
6
|
+
* (`addPermissionsQueryTo`) so a token restricted by a condition — e.g. own-assets-only —
|
|
7
|
+
* sees the same subset it would through the admin API.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createMediaListAssetsHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
12
|
+
/**
|
|
13
|
+
* `media_get_asset` — a single asset by numeric id.
|
|
14
|
+
*
|
|
15
|
+
* Row-level permission *conditions* are enforced by `findEntityAndCheckPermissions`, the same
|
|
16
|
+
* helper the admin `findOne` controller uses: it populates `createdBy` and the creator's roles
|
|
17
|
+
* before building the CASL subject, which is what the admin conditions read. Checking a subject
|
|
18
|
+
* without those fields would deny a conditioned grant its own assets, and would disagree with
|
|
19
|
+
* `media_list_assets`, where the condition is pushed into the query instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare const createMediaGetAssetHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
22
|
+
args: Record<string, unknown>;
|
|
23
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
24
|
+
/**
|
|
25
|
+
* `media_list_folders` — the nested folder structure, reusing `folder.getStructure()`.
|
|
26
|
+
*
|
|
27
|
+
* `getStructure()` returns the whole tree in one query and has no permission-condition
|
|
28
|
+
* filtering, so this is gated on the model-level read permission only — matching
|
|
29
|
+
* `GET /upload/folder-structure` in the admin API.
|
|
30
|
+
*
|
|
31
|
+
* The factory asserts the handler's instance is the ambient `global.strapi` the folder service
|
|
32
|
+
* actually queries — see `assertAmbientInstance` for why.
|
|
33
|
+
*/
|
|
34
|
+
export declare const createMediaListFoldersHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => () => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
35
|
+
//# sourceMappingURL=read-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-handlers.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/handlers/read-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA4DnD;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAmB7C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GACrC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CA0B7C,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,GACxC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,WAIrB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAO1D,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Core, Modules } from '@strapi/types';
|
|
2
|
+
/**
|
|
3
|
+
* `media_update_asset` — edits the writable metadata of one asset.
|
|
4
|
+
*
|
|
5
|
+
* Gated on `plugin::upload.assets.update` and mirrors `PUT /upload/files/:id`: the same
|
|
6
|
+
* `findEntityAndCheckPermissions` row-level check, the same `updateFileInfo` service call, and
|
|
7
|
+
* the same `updatedBy` attribution from the session user.
|
|
8
|
+
*
|
|
9
|
+
* The response carries the updated asset through the read sanitizer, so a client can confirm
|
|
10
|
+
* the write without a second `media_get_asset` round-trip — and so provider fields stay
|
|
11
|
+
* invisible on the write path too.
|
|
12
|
+
*/
|
|
13
|
+
export declare const createMediaUpdateAssetHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
14
|
+
args: Record<string, unknown>;
|
|
15
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
16
|
+
/**
|
|
17
|
+
* `media_move_assets` — moves assets between folders in bulk.
|
|
18
|
+
*
|
|
19
|
+
* Bulk with a per-id report, rather than all-or-nothing: an agent reorganising a library moves
|
|
20
|
+
* many assets at once, and one bad id among good ones must not discard the valid moves. Each
|
|
21
|
+
* asset is moved on its own, so a failure is confined to its own id and the response says exactly
|
|
22
|
+
* which ids to retry.
|
|
23
|
+
*
|
|
24
|
+
* That is why this does not reuse the admin `/actions/bulk-move` controller path, whose single
|
|
25
|
+
* transaction is all-or-nothing by construction (and which also handles folders, out of scope
|
|
26
|
+
* here). It goes through `updateFileInfo` instead — the same service `media_update_asset` and
|
|
27
|
+
* `PUT /upload/files/:id` use — which sets the `folder` relation, recomputes the private
|
|
28
|
+
* `folderPath`, attributes `updatedBy`, and emits `media.update` per asset. Replicating the
|
|
29
|
+
* controller's raw join-table writes would skip all four.
|
|
30
|
+
*
|
|
31
|
+
* The moves are sequential on purpose. Each one writes the join table and `folderPath` for its
|
|
32
|
+
* asset, and a bounded reorganisation (100 ids max, per the input schema) is not worth the
|
|
33
|
+
* connection-pool contention of firing them in parallel.
|
|
34
|
+
*/
|
|
35
|
+
export declare const createMediaMoveAssetsHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
36
|
+
args: Record<string, unknown>;
|
|
37
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
38
|
+
/**
|
|
39
|
+
* `media_delete_assets` — previews or performs the permanent deletion of assets, in bulk.
|
|
40
|
+
*
|
|
41
|
+
* Two branches behind one tool, for the same reason as `media_delete_folder`: the preview and the
|
|
42
|
+
* deletion must agree on what would be destroyed, and splitting them across tools would both let
|
|
43
|
+
* the two drift apart and let an agent reach the destructive one without ever seeing a preview.
|
|
44
|
+
* `dryRun` defaults to true (see the input schema), so omitting the flag previews and deleting
|
|
45
|
+
* takes an explicit `dryRun: false`.
|
|
46
|
+
*
|
|
47
|
+
* Per-id, not all-or-nothing — the opposite of `media_delete_folder`, on purpose. A folder delete
|
|
48
|
+
* cascades, so a mixed id list there is refused outright rather than half-applied over an unknown
|
|
49
|
+
* amount of content. Here each id is exactly one asset, the blast radius of a bad one is nil, and
|
|
50
|
+
* the requirement is explicit: a bad id among good ones must not discard the valid deletions.
|
|
51
|
+
* The dry run reports the same per-id split, so an agent sees which ids will not resolve *before*
|
|
52
|
+
* anything is destroyed rather than after.
|
|
53
|
+
*
|
|
54
|
+
* This does not reuse `file.deleteByIds` (the admin `/actions/bulk-delete` path). That helper
|
|
55
|
+
* fires `upload.remove` under a single `Promise.all`, so the first rejection discards the report
|
|
56
|
+
* of everything already deleted — unrecoverable for an operation with no undo. The removals are
|
|
57
|
+
* driven one at a time here instead, through the same `upload.remove` service, which deletes the
|
|
58
|
+
* provider file and every generated format, emits `media.delete`, and then deletes the row.
|
|
59
|
+
*
|
|
60
|
+
* The deletions are sequential on purpose: each one performs provider I/O, and a bounded batch
|
|
61
|
+
* (100 ids max, per the input schema) is not worth firing at a provider in parallel.
|
|
62
|
+
*/
|
|
63
|
+
export declare const createMediaDeleteAssetsHandler: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext) => ({ args, }: {
|
|
64
|
+
args: Record<string, unknown>;
|
|
65
|
+
}) => Promise<Modules.MCP.McpToolHandlerReturn>;
|
|
66
|
+
//# sourceMappingURL=write-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-handlers.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/handlers/write-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAiEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,GACxC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CA4C7C,CAAC;AA8BF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAgF7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,8BAA8B,GACzC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAIxB,WAEX;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAmF7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AACpG,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Core, Modules } from '@strapi/types';
|
|
2
|
+
/**
|
|
3
|
+
* Builds an admin permissions manager for a media model bound to the MCP session's ability.
|
|
4
|
+
*
|
|
5
|
+
* MCP tool handlers have no Koa context, so they cannot rely on route policies: each handler must
|
|
6
|
+
* re-check permissions itself, exactly as the admin controllers do via `ctx.state.userAbility`.
|
|
7
|
+
* The declarative `auth.policies` on a tool definition already gates registration and invocation;
|
|
8
|
+
* this second check is what keeps a handler safe if it is ever called from another entry point.
|
|
9
|
+
*
|
|
10
|
+
* It is also the only check bound to a model. `plugin::upload.read` is registered in the
|
|
11
|
+
* `plugins` section with no subject (see the upload plugin bootstrap), so a tool's policies
|
|
12
|
+
* carry an action only — a subject-less grant registers as CASL `subject: 'all'`. Passing a
|
|
13
|
+
* model UID as the policy subject is rejected by the admin-token validation, so the file /
|
|
14
|
+
* folder distinction is enforced here, where the permissions manager is bound to the UID.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createMediaPermissionsManager: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext, action: string, model: string) => any;
|
|
17
|
+
/**
|
|
18
|
+
* Throws `ForbiddenError` unless the session's ability permits `action` on `model`.
|
|
19
|
+
* Mirrors the `if (!pm.isAllowed) return ctx.forbidden()` guard in the admin controllers.
|
|
20
|
+
*/
|
|
21
|
+
export declare const assertMediaPermission: (strapi: Core.Strapi, context: Modules.MCP.McpHandlerContext, action: string, model: string) => any;
|
|
22
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../server/src/mcp/permissions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,6BAA6B,GACxC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,EACtC,QAAQ,MAAM,EACd,OAAO,MAAM,QAMX,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,IAAI,CAAC,MAAM,EACnB,SAAS,OAAO,CAAC,GAAG,CAAC,iBAAiB,EACtC,QAAQ,MAAM,EACd,OAAO,MAAM,QASd,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
import type { UploadMcpTool } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The Media Library MCP tools.
|
|
5
|
+
*
|
|
6
|
+
* Folder writes inherit the same `plugin::upload.assets.update` action rather than introducing a
|
|
7
|
+
* folder-specific one, matching what the admin UI enforces today. MCP-specific folder RBAC is
|
|
8
|
+
* out of scope.
|
|
9
|
+
*
|
|
10
|
+
* Renaming and moving are separate tools for both objects — rename/update changes attributes,
|
|
11
|
+
* move changes location — so an agent selects by intent instead of assembling a combined patch.
|
|
12
|
+
*
|
|
13
|
+
* The asset and folder tools stay separate for both move and delete, even though
|
|
14
|
+
* `/actions/bulk-move` accepts both id lists at once and `/actions/bulk-delete` accepts `fileIds`
|
|
15
|
+
* and `folderIds` together. Asset ids and folder ids are indistinguishable integers from separate
|
|
16
|
+
* namespaces, and both `media_list_assets` and `media_list_folders` return a plain `id`, so a
|
|
17
|
+
* combined tool would let an agent pass folder ids where assets were meant with nothing to
|
|
18
|
+
* object. On the delete side that mistake is unrecoverable, and two tools also let each
|
|
19
|
+
* description carry the warning matched to its own blast radius.
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildUploadMcpToolDefinitions: () => UploadMcpTool[];
|
|
22
|
+
/**
|
|
23
|
+
* Registers the Media Library MCP tools via `strapi.ai.mcp.registerTool()`.
|
|
24
|
+
* Must be called from the plugin register phase, before the MCP HTTP server starts.
|
|
25
|
+
*/
|
|
26
|
+
export declare const registerUploadMcpTools: ({ strapi }: {
|
|
27
|
+
strapi: Core.Strapi;
|
|
28
|
+
}) => void;
|
|
29
|
+
//# sourceMappingURL=register-upload-mcp-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-upload-mcp-tools.d.ts","sourceRoot":"","sources":["../../../../server/src/mcp/register-upload-mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAmC7C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,6BAA6B,QAAO,aAAa,EAiH7D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,KAAG,IAO5E,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MediaFolderNode } from '../schemas';
|
|
2
|
+
type RawFolder = {
|
|
3
|
+
id?: unknown;
|
|
4
|
+
name?: unknown;
|
|
5
|
+
children?: unknown;
|
|
6
|
+
};
|
|
7
|
+
type RawAsset = Record<string, unknown> & {
|
|
8
|
+
folder?: RawFolder | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Projects a raw file row onto the MCP asset shape.
|
|
12
|
+
*
|
|
13
|
+
* This is an allowlist: every exposed key is named explicitly, so `provider`,
|
|
14
|
+
* `provider_metadata` (which can carry provider credentials), `hash`, `formats`, `related`,
|
|
15
|
+
* and the private `folderPath` never reach an MCP client — including after new fields are
|
|
16
|
+
* added to the file content-type.
|
|
17
|
+
*/
|
|
18
|
+
export declare const sanitizeMediaAsset: (asset: RawAsset) => {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
alternativeText: string | null;
|
|
22
|
+
caption: string | null;
|
|
23
|
+
url: string;
|
|
24
|
+
mime: string;
|
|
25
|
+
size: number;
|
|
26
|
+
width: number | null;
|
|
27
|
+
height: number | null;
|
|
28
|
+
ext: string | null;
|
|
29
|
+
folder: {
|
|
30
|
+
id: number;
|
|
31
|
+
name: string;
|
|
32
|
+
} | null;
|
|
33
|
+
createdAt: string | null;
|
|
34
|
+
updatedAt: string | null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Projects the recursive output of `folder.getStructure()` onto `{ id, name, children }`,
|
|
38
|
+
* dropping `path` and `pathId` (internal materialized-path bookkeeping).
|
|
39
|
+
*/
|
|
40
|
+
export declare const sanitizeMediaFolderTree: (nodes: unknown) => MediaFolderNode[];
|
|
41
|
+
/**
|
|
42
|
+
* Projects a raw folder row onto the MCP folder shape.
|
|
43
|
+
*
|
|
44
|
+
* An allowlist for the same reason as `sanitizeMediaAsset`: `path` and `pathId` are the internal
|
|
45
|
+
* materialized-path bookkeeping the folder service uses to cascade moves and deletes. Exposing
|
|
46
|
+
* them would invite an agent to treat them as addressable, and any field added to the folder
|
|
47
|
+
* content-type later stays invisible until it is named here on purpose.
|
|
48
|
+
*/
|
|
49
|
+
export declare const sanitizeMediaFolder: (folder: (RawFolder & Record<string, unknown>) | null | undefined) => {
|
|
50
|
+
createdAt: string | null;
|
|
51
|
+
updatedAt: string | null;
|
|
52
|
+
parent?: {
|
|
53
|
+
id: number;
|
|
54
|
+
name?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
id: number;
|
|
57
|
+
name: string;
|
|
58
|
+
} | null | undefined;
|
|
59
|
+
id: number;
|
|
60
|
+
name: string;
|
|
61
|
+
} | null;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=sanitize-media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize-media.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/sanitizers/sanitize-media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,SAAS,GAAG;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACxC,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC3B,CAAC;AAeF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,QAAQ;;;;;;;;;;;;;;;;;CAqBjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,OAAO,KAAG,eAAe,EAQvE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS;;;;;;;;;;;;QA+BjE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { mediaIdSchema, folderIdSchema, folderNameSchema, pageSchema, pageSizeSchema, sortSchema, mediaListAssetsInputSchema, mediaGetAssetInputSchema, mediaListFoldersInputSchema, mediaUpdateAssetInputSchema, mediaCreateFolderInputSchema, mediaRenameFolderInputSchema, mediaMoveFolderInputSchema, mediaDeleteFolderInputSchema, mediaMoveAssetsInputSchema, mediaDeleteAssetsInputSchema, } from './input-schemas';
|
|
2
|
+
export { mediaAssetOutputSchema, mediaGetAssetOutputSchema, mediaListAssetsOutputSchema, mediaFolderNodeSchema, mediaListFoldersOutputSchema, mediaUpdateAssetOutputSchema, mediaFolderOutputSchema, mediaCreateFolderOutputSchema, mediaRenameFolderOutputSchema, mediaMoveFolderOutputSchema, mediaDeleteFolderOutputSchema, mediaMoveAssetsFailureSchema, mediaMoveAssetsOutputSchema, mediaDeleteAssetsFailureSchema, mediaDeleteAssetsOutputSchema, type MediaFolderNode, } from './output-schemas';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../server/src/mcp/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,UAAU,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,6BAA6B,EAC7B,4BAA4B,EAC5B,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC"}
|