Skip to main content
Glama

wpnav_seed_test_data

Generate bulk WordPress test data including posts, comments, and users via REST API for development and testing purposes.

Instructions

Generate bulk test data (comments, posts, users) via REST API. Works with any WordPress instance (local, Hetzner, production).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
data_typeYesType of data to generate: comments (bulk comments on posts), posts (draft posts), users (subscriber accounts), all (mixed content)
amountNoNumber of items to create (1-50, default: 10)
post_idNoPost ID for comments (required if data_type is "comments")

Implementation Reference

  • Registers the wpnav_seed_test_data tool using toolRegistry.register, including the full definition (name, description, inputSchema) and handler function reference.
    toolRegistry.register({ definition: { name: 'wpnav_seed_test_data', description: 'Generate bulk test data (comments, posts, users) via REST API. Works with any WordPress instance (local, Hetzner, production).', inputSchema: { type: 'object', properties: { data_type: { type: 'string', enum: ['comments', 'posts', 'users', 'all'], description: 'Type of data to generate: comments (bulk comments on posts), posts (draft posts), users (subscriber accounts), all (mixed content)', }, amount: { type: 'integer', minimum: 1, maximum: 50, description: 'Number of items to create (1-50, default: 10)', default: 10, }, post_id: { type: 'integer', description: 'Post ID for comments (required if data_type is "comments")', }, }, required: ['data_type'], }, }, handler: async (args, context) => { validateRequired(args, ['data_type']); const amount = args.amount || 10; // Validate amount if (amount < 1 || amount > 50) { throw new Error('amount must be between 1 and 50'); } try { const results: any[] = []; switch (args.data_type) { case 'comments': // Validate post_id for comments if (!args.post_id) { throw new Error('post_id parameter required for comments data_type'); } // Generate bulk comments using REST API for (let i = 0; i < amount; i++) { const content = `Test comment #${i + 1} - Generated at ${new Date().toISOString()}`; const authorName = `TestUser${i + 1}`; const authorEmail = `testuser${i + 1}@example.com`; try { const result = await context.wpRequest('/wp/v2/comments', { method: 'POST', body: JSON.stringify({ post: args.post_id, content: content, author_name: authorName, author_email: authorEmail, status: 'approve', }), }); results.push({ type: 'comment', id: result.id, post_id: args.post_id, author_name: authorName, }); } catch (error: any) { results.push({ type: 'comment', error: error.message, }); } } break; case 'posts': // Generate bulk posts using REST API for (let i = 0; i < amount; i++) { const title = `Test Post #${i + 1} - ${new Date().toISOString()}`; const content = `This is test post #${i + 1} generated by wpnav_seed_test_data tool. Created at ${new Date().toISOString()}`; try { const result = await context.wpRequest('/wp/v2/posts', { method: 'POST', body: JSON.stringify({ title: title, content: content, status: 'draft', }), }); results.push({ type: 'post', id: result.id, title: result.title?.rendered || title, status: result.status, }); } catch (error: any) { results.push({ type: 'post', error: error.message, }); } } break; case 'users': // Generate bulk users using REST API for (let i = 0; i < amount; i++) { const timestamp = Date.now(); const username = `testuser_${timestamp}_${i}`; const email = `${username}@example.com`; const displayName = `Test User ${i + 1}`; try { const result = await context.wpRequest('/wp/v2/users', { method: 'POST', body: JSON.stringify({ username: username, email: email, password: 'TestPass123!', name: displayName, roles: ['subscriber'], }), }); results.push({ type: 'user', id: result.id, username: result.username, email: email, role: 'subscriber', }); } catch (error: any) { results.push({ type: 'user', error: error.message, }); } } break; case 'all': // Generate mix of content const mixAmount = Math.floor(amount / 3); // Create a post first let postId: number; try { const postResult = await context.wpRequest('/wp/v2/posts', { method: 'POST', body: JSON.stringify({ title: `Mixed Test Post - ${new Date().toISOString()}`, content: 'Test content for mixed data generation', status: 'draft', }), }); postId = postResult.id; results.push({ type: 'post', id: postId, title: postResult.title?.rendered || 'Mixed Test Post', }); } catch (error: any) { return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ error: 'Failed to create initial post for mixed data', message: error.message, }, null, 2)), }], isError: true, }; } // Create comments on the post for (let i = 0; i < mixAmount; i++) { try { const commentResult = await context.wpRequest('/wp/v2/comments', { method: 'POST', body: JSON.stringify({ post: postId, content: `Mixed test comment #${i + 1}`, author_name: `MixedUser${i + 1}`, author_email: `mixeduser${i + 1}@example.com`, status: 'approve', }), }); results.push({ type: 'comment', id: commentResult.id, post_id: postId, }); } catch (error: any) { results.push({ type: 'comment', error: error.message }); } } // Create users for (let i = 0; i < mixAmount; i++) { const timestamp = Date.now(); const username = `mixed_user_${timestamp}_${i}`; try { const userResult = await context.wpRequest('/wp/v2/users', { method: 'POST', body: JSON.stringify({ username: username, email: `${username}@example.com`, password: 'TestPass123!', name: `Mixed User ${i + 1}`, roles: ['subscriber'], }), }); results.push({ type: 'user', id: userResult.id, username: userResult.username, }); } catch (error: any) { results.push({ type: 'user', error: error.message }); } } break; default: throw new Error(`Unknown data_type: ${args.data_type}`); } const successCount = results.filter(r => !r.error).length; const failureCount = results.filter(r => r.error).length; return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ data_type: args.data_type, amount_requested: amount, items_created: successCount, failures: failureCount, results, message: `Seed data generation complete: ${successCount} items created, ${failureCount} failures`, }, null, 2)), }], }; } catch (error: any) { return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ error: 'Seed data generation failed', message: error.message || 'Unknown error', data_type: args.data_type, }, null, 2)), }], isError: true, }; } }, category: ToolCategory.CONTENT, });
  • Input schema defining the parameters: data_type (comments, posts, users, all), amount (1-50), post_id (for comments).
    inputSchema: { type: 'object', properties: { data_type: { type: 'string', enum: ['comments', 'posts', 'users', 'all'], description: 'Type of data to generate: comments (bulk comments on posts), posts (draft posts), users (subscriber accounts), all (mixed content)', }, amount: { type: 'integer', minimum: 1, maximum: 50, description: 'Number of items to create (1-50, default: 10)', default: 10, }, post_id: { type: 'integer', description: 'Post ID for comments (required if data_type is "comments")', }, }, required: ['data_type'],
  • Async handler function that validates inputs, then based on data_type, uses context.wpRequest to POST bulk data via WP REST API (/wp/v2/comments, /wp/v2/posts, /wp/v2/users), collects results with success/error tracking, returns JSON summary.
    handler: async (args, context) => { validateRequired(args, ['data_type']); const amount = args.amount || 10; // Validate amount if (amount < 1 || amount > 50) { throw new Error('amount must be between 1 and 50'); } try { const results: any[] = []; switch (args.data_type) { case 'comments': // Validate post_id for comments if (!args.post_id) { throw new Error('post_id parameter required for comments data_type'); } // Generate bulk comments using REST API for (let i = 0; i < amount; i++) { const content = `Test comment #${i + 1} - Generated at ${new Date().toISOString()}`; const authorName = `TestUser${i + 1}`; const authorEmail = `testuser${i + 1}@example.com`; try { const result = await context.wpRequest('/wp/v2/comments', { method: 'POST', body: JSON.stringify({ post: args.post_id, content: content, author_name: authorName, author_email: authorEmail, status: 'approve', }), }); results.push({ type: 'comment', id: result.id, post_id: args.post_id, author_name: authorName, }); } catch (error: any) { results.push({ type: 'comment', error: error.message, }); } } break; case 'posts': // Generate bulk posts using REST API for (let i = 0; i < amount; i++) { const title = `Test Post #${i + 1} - ${new Date().toISOString()}`; const content = `This is test post #${i + 1} generated by wpnav_seed_test_data tool. Created at ${new Date().toISOString()}`; try { const result = await context.wpRequest('/wp/v2/posts', { method: 'POST', body: JSON.stringify({ title: title, content: content, status: 'draft', }), }); results.push({ type: 'post', id: result.id, title: result.title?.rendered || title, status: result.status, }); } catch (error: any) { results.push({ type: 'post', error: error.message, }); } } break; case 'users': // Generate bulk users using REST API for (let i = 0; i < amount; i++) { const timestamp = Date.now(); const username = `testuser_${timestamp}_${i}`; const email = `${username}@example.com`; const displayName = `Test User ${i + 1}`; try { const result = await context.wpRequest('/wp/v2/users', { method: 'POST', body: JSON.stringify({ username: username, email: email, password: 'TestPass123!', name: displayName, roles: ['subscriber'], }), }); results.push({ type: 'user', id: result.id, username: result.username, email: email, role: 'subscriber', }); } catch (error: any) { results.push({ type: 'user', error: error.message, }); } } break; case 'all': // Generate mix of content const mixAmount = Math.floor(amount / 3); // Create a post first let postId: number; try { const postResult = await context.wpRequest('/wp/v2/posts', { method: 'POST', body: JSON.stringify({ title: `Mixed Test Post - ${new Date().toISOString()}`, content: 'Test content for mixed data generation', status: 'draft', }), }); postId = postResult.id; results.push({ type: 'post', id: postId, title: postResult.title?.rendered || 'Mixed Test Post', }); } catch (error: any) { return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ error: 'Failed to create initial post for mixed data', message: error.message, }, null, 2)), }], isError: true, }; } // Create comments on the post for (let i = 0; i < mixAmount; i++) { try { const commentResult = await context.wpRequest('/wp/v2/comments', { method: 'POST', body: JSON.stringify({ post: postId, content: `Mixed test comment #${i + 1}`, author_name: `MixedUser${i + 1}`, author_email: `mixeduser${i + 1}@example.com`, status: 'approve', }), }); results.push({ type: 'comment', id: commentResult.id, post_id: postId, }); } catch (error: any) { results.push({ type: 'comment', error: error.message }); } } // Create users for (let i = 0; i < mixAmount; i++) { const timestamp = Date.now(); const username = `mixed_user_${timestamp}_${i}`; try { const userResult = await context.wpRequest('/wp/v2/users', { method: 'POST', body: JSON.stringify({ username: username, email: `${username}@example.com`, password: 'TestPass123!', name: `Mixed User ${i + 1}`, roles: ['subscriber'], }), }); results.push({ type: 'user', id: userResult.id, username: userResult.username, }); } catch (error: any) { results.push({ type: 'user', error: error.message }); } } break; default: throw new Error(`Unknown data_type: ${args.data_type}`); } const successCount = results.filter(r => !r.error).length; const failureCount = results.filter(r => r.error).length; return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ data_type: args.data_type, amount_requested: amount, items_created: successCount, failures: failureCount, results, message: `Seed data generation complete: ${successCount} items created, ${failureCount} failures`, }, null, 2)), }], }; } catch (error: any) { return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ error: 'Seed data generation failed', message: error.message || 'Unknown error', data_type: args.data_type, }, null, 2)), }], isError: true, }; } },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/littlebearapps/wp-navigator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server