/**
* Manage Media Feature
*
* Upload and manage media files - for authors and administrators
*/
export default {
name: 'manage-media',
description: 'Upload media files or get media library items',
inputSchema: {
type: 'object',
properties: {
action: {
type: 'string',
enum: ['list', 'upload_from_url'],
description: 'Media action to perform',
},
url: {
type: 'string',
description: 'URL of image to upload (for upload_from_url action)',
},
title: {
type: 'string',
description: 'Title for uploaded media',
},
alt_text: {
type: 'string',
description: 'Alt text for uploaded media',
},
per_page: {
type: 'number',
default: 10,
description: 'Number of media items to list',
},
},
required: ['action'],
},
async execute(params, context) {
const { wpClient } = context;
if (params.action === 'list') {
const media = await wpClient.request('/media', {
params: { per_page: params.per_page || 10 },
});
return {
success: true,
count: media.length,
media: media.map((item) => ({
id: item.id,
title: item.title.rendered,
url: item.source_url,
mime_type: item.mime_type,
alt_text: item.alt_text,
})),
};
}
if (params.action === 'upload_from_url') {
if (!params.url) {
throw new Error('URL is required for upload_from_url action');
}
// Note: Real implementation would download and upload the file
// This is a simplified version that would need proper implementation
return {
success: false,
message: 'URL upload requires server-side implementation with proper file handling',
};
}
},
};