wpnav_gutenberg_list_patterns
Discover available Gutenberg block patterns and reusable blocks to quickly implement pre-designed layouts in WordPress content.
Instructions
List all available Gutenberg block patterns and reusable blocks. Patterns are pre-designed block combinations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/gutenberg/index.ts:508-539 (handler)The handler function executes the tool logic by fetching Gutenberg patterns from the WP REST API '/wpnav/v1/gutenberg/patterns', handles errors, formats the patterns summary, and returns a structured response.handler: async (args, context) => { const result = await context.wpRequest('/wpnav/v1/gutenberg/patterns'); if (!result.success) { return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ error: result.error }, null, 2)), }], isError: true, }; } // Format patterns for display const summary = result.patterns.map((p: any) => ({ id: p.id, title: p.title, type: p.type, categories: p.categories, })); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ success: true, count: result.patterns.length, patterns: summary, }, null, 2)), }], }; },
- src/tools/gutenberg/index.ts:499-507 (schema)The tool definition including name, description, and input schema (no required parameters).definition: { name: 'wpnav_gutenberg_list_patterns', description: 'List all available Gutenberg block patterns and reusable blocks. Patterns are pre-designed block combinations.', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/tools/gutenberg/index.ts:498-541 (registration)The registration of the 'wpnav_gutenberg_list_patterns' tool in the toolRegistry, including definition, handler, and category.toolRegistry.register({ definition: { name: 'wpnav_gutenberg_list_patterns', description: 'List all available Gutenberg block patterns and reusable blocks. Patterns are pre-designed block combinations.', inputSchema: { type: 'object', properties: {}, required: [], }, }, handler: async (args, context) => { const result = await context.wpRequest('/wpnav/v1/gutenberg/patterns'); if (!result.success) { return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ error: result.error }, null, 2)), }], isError: true, }; } // Format patterns for display const summary = result.patterns.map((p: any) => ({ id: p.id, title: p.title, type: p.type, categories: p.categories, })); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ success: true, count: result.patterns.length, patterns: summary, }, null, 2)), }], }; }, category: ToolCategory.CONTENT, });