wpnav_get_post
Retrieve a WordPress post by ID to access content, metadata, categories, and tags for management or analysis.
Instructions
Get a single WordPress post by ID. Returns full post content, metadata, categories, and tags.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | WordPress post ID |
Implementation Reference
- src/tools/content/index.ts:426-440 (handler)The handler function for the wpnav_get_post tool. Validates the post ID, fetches the full post data from the WordPress REST API endpoint `/wp/v2/posts/${id}`, extracts a summary of key fields (id, title, content, excerpt, status, author, modified, link, categories, tags), and returns a formatted JSON response.handler: async (args, context) => { validateRequired(args, ['id']); const id = validateId(args.id, 'Post'); const post = await context.wpRequest(`/wp/v2/posts/${id}`); const summary = extractSummary(post, [ 'id', 'title.rendered', 'content.rendered', 'excerpt.rendered', 'status', 'author', 'modified', 'link', 'categories', 'tags', ]); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(summary, null, 2)) }], }; },
- src/tools/content/index.ts:415-424 (schema)The input schema definition for wpnav_get_post tool, specifying a required numeric 'id' parameter for the WordPress post ID.definition: { name: 'wpnav_get_post', description: 'Get a single WordPress post by ID. Returns full post content, metadata, categories, and tags.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress post ID' }, }, required: ['id'], },
- src/tools/content/index.ts:413-442 (registration)The complete registration of the wpnav_get_post tool using toolRegistry.register, including definition (name, description, schema), handler function, and category assignment within the registerContentTools function.toolRegistry.register({ definition: { name: 'wpnav_get_post', description: 'Get a single WordPress post by ID. Returns full post content, metadata, categories, and tags.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'WordPress post ID' }, }, required: ['id'], }, }, handler: async (args, context) => { validateRequired(args, ['id']); const id = validateId(args.id, 'Post'); const post = await context.wpRequest(`/wp/v2/posts/${id}`); const summary = extractSummary(post, [ 'id', 'title.rendered', 'content.rendered', 'excerpt.rendered', 'status', 'author', 'modified', 'link', 'categories', 'tags', ]); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(summary, null, 2)) }], }; }, category: ToolCategory.CONTENT, });
- src/tools.ts:206-219 (schema)The tool schema for wpnav_get_post exported in the main tools list, used for MCP client discovery of available tools.{ name: 'wpnav_get_post', description: 'Get a single WordPress post by ID. Returns full post content, metadata, categories, and tags.', inputSchema: { type: 'object' as const, properties: { id: { type: 'number' as const, description: 'WordPress post ID', }, }, required: ['id'], },