get_upload_urls
Get signed upload URLs for media files. Upload the file via PUT to the returned URL, then use the key in post creation.
Instructions
Get signed upload URLs for media files. Upload your file to the returned URL via PUT, then use the key in create_posts mediaItems.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentType | Yes | MIME type of the file. Supported: image/jpeg, image/png, image/gif, image/webp, video/mp4, video/webm, video/quicktime | |
| count | No | Number of upload URLs (1-8 for images, 1 for videos) |
Implementation Reference
- src/tools/files.ts:38-71 (handler)Registration and handler for the 'get_upload_urls' MCP tool. Calls POST /file/get-signed-upload-urls on the PostFast API and returns signed upload URLs.
export function registerFileTools(server: McpServer, client: PostFastClient) { server.tool( 'get_upload_urls', 'Get signed upload URLs for media files. Upload your file to the returned URL via PUT, then use the key in create_posts mediaItems.', { contentType: z .string() .describe( `MIME type of the file. Supported: ${[...IMAGE_TYPES, ...VIDEO_TYPES].join(', ')}`, ), count: z .number() .int() .min(1) .max(8) .default(1) .describe('Number of upload URLs (1-8 for images, 1 for videos)'), }, async (input) => { const data = await client.post<SignedUploadUrl[]>( '/file/get-signed-upload-urls', { contentType: input.contentType, count: input.count, }, ); return { content: [ { type: 'text' as const, text: JSON.stringify(data, null, 2) }, ], }; }, ); - src/tools/files.ts:42-55 (schema)Input schema for get_upload_urls: contentType (MIME type) and count (1-8 for images, 1 for videos, defaults to 1).
{ contentType: z .string() .describe( `MIME type of the file. Supported: ${[...IMAGE_TYPES, ...VIDEO_TYPES].join(', ')}`, ), count: z .number() .int() .min(1) .max(8) .default(1) .describe('Number of upload URLs (1-8 for images, 1 for videos)'), }, - src/index.ts:17-19 (registration)Tool registration entry point: registerFileTools is called from index.ts to register get_upload_urls on the MCP server.
registerPostTools(server, client); registerAccountTools(server, client); registerFileTools(server, client); - src/types.ts:86-89 (helper)SignedUploadUrl type definition used as the return type of get_upload_urls (key + signedUrl).
export interface SignedUploadUrl { key: string; signedUrl: string; } - src/client.ts:72-72 (helper)PostFastClient.post method used by get_upload_urls handler to make the API request.
post<T>(path: string, body?: unknown): Promise<T> {