Skip to content

Commit 3af29f2

Browse files
committed
Testing PR that resolves $ref in inputSchemas
See modelcontextprotocol/inspector#889 * In tools.ts - modified AddSchema - tests simple primitive refs - extracted z.number() to a variable that is referenced for a and b properties - modified ComplexOrderSchema - tested object refs - extracted shipping address properties to address variable - referenced address from shippingAddress property - added billing address property that references address
1 parent b3bf784 commit 3af29f2

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

handlers/tools.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ const EchoSchema = z.object({
1818
message: z.string().describe("Message to echo back"),
1919
});
2020

21+
const number = z.number().describe("A number to add");
2122
const AddSchema = z.object({
22-
a: z.number().describe("First number"),
23-
b: z.number().describe("Second number"),
23+
a: number,
24+
b: number
2425
});
2526

2627
const GetCurrentTimeSchema = z.object({
@@ -45,18 +46,21 @@ const AnnotatedResponseSchema = z.object({
4546
includeMetadata: z.boolean().default(true).describe("Whether to include metadata"),
4647
});
4748

49+
const address = z.object({
50+
street: z.string().describe("Street address"),
51+
city: z.string().describe("City name"),
52+
state: z.string().describe("State or province"),
53+
zipCode: z.string().describe("ZIP or postal code"),
54+
country: z.string().default("US").describe("Country code (ISO 3166-1 alpha-2)"),
55+
}).describe("Address details");
56+
4857
// Testing Tools
4958
const ComplexOrderSchema = z.object({
5059
customerName: z.string().describe("Full customer name for the order"),
5160
customerTaxId: z.string().describe("Tax identification number (e.g., 123-45-6789)"),
5261
customerEmail: z.string().email().describe("Customer's email address for notifications"),
53-
shippingAddress: z.object({
54-
street: z.string().describe("Street address"),
55-
city: z.string().describe("City name"),
56-
state: z.string().describe("State or province"),
57-
zipCode: z.string().describe("ZIP or postal code"),
58-
country: z.string().default("US").describe("Country code (ISO 3166-1 alpha-2)"),
59-
}).describe("Shipping address details"),
62+
billingAddress: address,
63+
shippingAddress: address,
6064
items: z.array(z.object({
6165
productName: z.string().describe("Name of the product"),
6266
productSku: z.string().describe("Product SKU or identifier"),

0 commit comments

Comments
 (0)