Skip to content

Commit 5c433b1

Browse files
feat(customer): add CustomerLookupToolSchema for MCP tools
xmcp requires .shape property for tool schema generation, which only ZodObject has. ZodUnion (CustomerLookupInputSchema) lacks .shape. Add CustomerLookupToolSchema as a flat object with all optional fields for MCP tools, while keeping the discriminated union for contract validation.
1 parent 65406b9 commit 5c433b1

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/contracts/customer.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type ListCustomersPaginatedOutput = z.infer<
3131
typeof ListCustomersPaginatedOutputSchema
3232
>;
3333

34-
// Customer lookup by exactly one identifier (discriminated union for JSON Schema compatibility)
34+
// Customer lookup by exactly one identifier (discriminated union for contract validation)
3535
const CustomerLookupByIdSchema = z.object({
3636
id: z.string().describe("The customer ID"),
3737
});
@@ -49,6 +49,13 @@ export const CustomerLookupInputSchema = z.union([
4949
]);
5050
export type CustomerLookupInput = z.infer<typeof CustomerLookupInputSchema>;
5151

52+
// Flat schema for MCP tools (xmcp needs .shape, unions don't have it)
53+
export const CustomerLookupToolSchema = z.object({
54+
id: z.string().optional().describe("The customer ID"),
55+
email: z.string().optional().describe("The customer email address"),
56+
externalId: z.string().optional().describe("The external ID from your system"),
57+
});
58+
5259
export const GetCustomerInputSchema = CustomerLookupInputSchema;
5360
export type GetCustomerInput = z.infer<typeof GetCustomerInputSchema>;
5461

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export {
6565
GetCustomerInputSchema,
6666
DeleteCustomerInputSchema,
6767
CustomerLookupInputSchema,
68+
CustomerLookupToolSchema,
6869
} from "./contracts/customer";
6970
export type { Checkout } from "./schemas/checkout";
7071
export { CheckoutSchema } from "./schemas/checkout";

0 commit comments

Comments
 (0)