feat: list media via public API and MCP mediaListTool - #1926
Open
giladresisi wants to merge 2 commits into
Open
giladresisi wants to merge 2 commits into
giladresisi wants to merge 2 commits into
Conversation
Adds GET /public/v1/media?page=&search= and a read-only mediaListTool so agents can reuse already-uploaded media paths as attachments instead of re-uploading. getMedia select now also returns type, fileSize, createdAt. Tested: unauthenticated request returns 401; with an API key pagination (pages count, page 2), filename search and the new fields verified; mediaListTool appears in the MCP tools list, returns the same rows, and a draft scheduled through the MCP with a listed path stores that path as the post image. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Strix Security ReviewNo security issues found. Updated for Reviewed by Strix |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| @Get('/media') | ||
| getMedia( | ||
| @GetOrgFromRequest() org: Organization, | ||
| @Query('page') page: number, |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Collaborator
Author
There was a problem hiding this comment.
Partly confirmed: a non-numeric value or 0 fell back to page 1, but a negative value did produce a negative skip and a 500. Fixed in 063ee50 with a GetMediaDto (page: IsNumber, Min(1), parseInt transform, default 1; search: IsString), same pattern as GetNotificationsDto. Verified: page=abc, 0 and -3 now return 400, page=1.5 parses to 1, normal requests unchanged.
A negative page produced a negative Prisma skip and a 500. GetMediaDto (same shape as GetNotificationsDto) now rejects non-numeric or < 1 values with 400 and defaults to 1. Tested: page=abc / 0 / -3 return 400 with validation messages, page=1.5 parses to 1, no page / page=2 / search unchanged, unauthenticated still 401. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 task
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Feature
Why was this change needed?
An agency customer driving Postiz from the MCP had no way to discover media already uploaded to the library: the public API only exposed upload routes and the MCP only uploadFromUrlTool, so they copied URLs from the UI by hand.
Other information:
GET /public/v1/media?page=&search=(api-key guarded, Sentrypublic_api-requestmetric like the other routes) returns{ pages, results }from the existingMediaService.getMedia(org-scoped, non-deleted, 18/page, newest first, case-insensitive originalName search).mediaListToolwith the same input/output, registered intoolList, plus one system-prompt line telling the agent to reuse listed paths before asking for a URL or re-uploading.getMediaselect additionally returnstype,fileSize,createdAt(additive; the UI media grid uses the same method).Tested: unauthenticated request returns 401; with an API key, pagination (pages count, page 2), filename search and the new fields verified;
mediaListToolappears in the MCP tools list and returns the same rows via tools/call; a draft created through the MCP with a listedpathstores that path as the post image.Companion PRs (merge only after this one is deployed): gitroomhq/postiz-docs#239 and gitroomhq/postiz-agent#19.
Checklist: