// src/tools/show-moon.ts
import { z } from "zod";
import { moonOn, parseDate } from "../lib/moon";
export const tool = {
title: "Show moon phase",
description: "Show the moon phase for a date. Use when the user asks about the moon on a date.",
resource: "moon", // render src/resources/moon as the UI
annotations: { readOnlyHint: true },
invoking: "Looking up", // ChatGPT status while running
invoked: "Here's the moon", // ...and after
};
export const schema = {
date: z.string().optional().describe("Date as YYYY-MM-DD. Defaults to today."),
};
export default async function showMoon({ date }: { date?: string }) {
return moonOn(parseDate(date)); // a plain object becomes structuredContent
}
// src/tools/moon-facts.ts
export const tool = { title: "Moon facts", description: "Answer a quick moon question in text." };
export default async function () {
return "The Moon is 384,400 km away on average.";
}
Input is validated against schema before your handler runs. A bad call returns a tool error naming the field, which moonpeak test and the inspector both show.