Skip to content

Instantly share code, notes, and snippets.

@zackify
Created June 20, 2025 22:52
Show Gist options
  • Select an option

  • Save zackify/3121f7fdfb98a60442189e8f2aa9f6ca to your computer and use it in GitHub Desktop.

Select an option

Save zackify/3121f7fdfb98a60442189e8f2aa9f6ca to your computer and use it in GitHub Desktop.
// Async tool with external API call
server.registerTool(
"fetch-weather",
{
title: "Weather Fetcher",
description: "Get weather data for a city",
},
async () => {
const result = await server.server.elicitInput({
message: `No tables available. Would you like to check alternative dates?`,
requestedSchema: {
type: "object",
properties: {
checkAlternatives: {
type: "boolean",
title: "Check alternative dates",
description: "Would you like me to check other dates?",
},
flexibleDates: {
type: "string",
title: "Date flexibility",
description: "How flexible are your dates?",
enum: ["next_day", "same_week", "next_week"],
enumNames: ["Next day", "Same week", "Next week"],
},
},
required: ["checkAlternatives"],
},
});
return {
content: [
{
type: "text",
text: result.content?.checkAlternatives
? "will check alternatives"
: "will not check alternatives",
},
],
};
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment