diff --git a/package.json b/package.json index 4a8766f..480dd97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@missionsquad/mcp-wordpress", - "version": "0.2.1", + "version": "0.2.2", "description": "A Model Context Protocol server for interacting with WordPress.", "type": "module", "main": "./build/server.js", diff --git a/src/tools/acf.ts b/src/tools/acf.ts index b9153ce..0e82096 100644 --- a/src/tools/acf.ts +++ b/src/tools/acf.ts @@ -13,21 +13,34 @@ type ToolWithZodSchema = Tool & { zodSchema?: z.ZodTypeAny } -const getAcfSchemaSchema = z +export const getAcfSchemaSchema = z .object({ target: z .enum(['content', 'term', 'user']) .describe('Schema target. Use content for posts/pages/CPTs, term for taxonomy terms, and user for users.'), content_type: z - .string() + .preprocess((value) => (typeof value === 'string' && value.trim() === '' ? undefined : value), z.string().optional()) .optional() .describe('Required only when target is content. WordPress post type slug, such as post, page, book, or product.'), taxonomy: z - .string() + .preprocess((value) => (typeof value === 'string' && value.trim() === '' ? undefined : value), z.string().optional()) .optional() .describe('Required only when target is term. WordPress taxonomy slug, such as category, post_tag, or genre.'), id: z - .union([z.number(), z.literal('me')]) + .preprocess((value) => { + if (typeof value === 'string') { + const trimmed = value.trim() + if (trimmed === '') { + return undefined + } + if (/^\d+$/.test(trimmed)) { + return Number(trimmed) + } + return trimmed + } + + return value + }, z.union([z.number(), z.literal('me')]).optional()) .optional() .describe('Optional target ID. For users, this may also be "me". Omit to inspect the collection schema.'), })