Merge pull request #81 from jonathanhefner/examples-use-content-for-now
Use `content` instead of `structuredContent` in examples
This commit is contained in:
commit
437b9185cc
2 changed files with 65 additions and 150 deletions
|
|
@ -27,29 +27,6 @@ const GetCustomerDataInputSchema = z.object({
|
|||
.describe("Filter by segment (default: All)"),
|
||||
});
|
||||
|
||||
const CustomerSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
segment: z.string(),
|
||||
annualRevenue: z.number(),
|
||||
employeeCount: z.number(),
|
||||
accountAge: z.number(),
|
||||
engagementScore: z.number(),
|
||||
supportTickets: z.number(),
|
||||
nps: z.number(),
|
||||
});
|
||||
|
||||
const SegmentSummarySchema = z.object({
|
||||
name: z.string(),
|
||||
count: z.number(),
|
||||
color: z.string(),
|
||||
});
|
||||
|
||||
const GetCustomerDataOutputSchema = z.object({
|
||||
customers: z.array(CustomerSchema),
|
||||
segments: z.array(SegmentSummarySchema),
|
||||
});
|
||||
|
||||
// Cache generated data for session consistency
|
||||
let cachedCustomers: Customer[] | null = null;
|
||||
let cachedSegments: SegmentSummary[] | null = null;
|
||||
|
|
@ -92,15 +69,13 @@ const server = new McpServer({
|
|||
description:
|
||||
"Returns customer data with segment information for visualization. Optionally filter by segment.",
|
||||
inputSchema: GetCustomerDataInputSchema.shape,
|
||||
outputSchema: GetCustomerDataOutputSchema.shape,
|
||||
_meta: { [RESOURCE_URI_META_KEY]: resourceUri },
|
||||
},
|
||||
async ({ segment }): Promise<CallToolResult> => {
|
||||
const data = getCustomerData(segment);
|
||||
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
||||
structuredContent: data,
|
||||
content: [{ type: "text", text: JSON.stringify(data) }],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -336,7 +336,13 @@ async function fetchData(): Promise<void> {
|
|||
arguments: {},
|
||||
});
|
||||
|
||||
const data = result.structuredContent as unknown as {
|
||||
const text = result
|
||||
.content!.filter(
|
||||
(c): c is { type: "text"; text: string } => c.type === "text",
|
||||
)
|
||||
.map((c) => c.text)
|
||||
.join("");
|
||||
const data = JSON.parse(text) as {
|
||||
customers: Customer[];
|
||||
segments: SegmentSummary[];
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue