get_lunch_menu
Retrieve the daily lunch menu from the canteen for a specified date using a structured API, enabling easy integration and timely access to meal information.
Instructions
Get the lunch menu from the canteen for a specific date
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | The date to get the menu for (YYYY-MM-DD) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"date": {
"description": "The date to get the menu for (YYYY-MM-DD)",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"type": "string"
}
},
"required": [
"date"
],
"type": "object"
}
Implementation Reference
- src/server.ts:42-53 (handler)The execute handler for the get_lunch_menu tool. It fetches the lunch menu from an external API using axios for the specified date and returns the JSON response.execute: async (args) => { try { const response = await axios.get(process.env.API_URL!, { params: { date: args.date } }); return JSON.stringify(response.data, null, 2); } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to fetch menu: ${error.message}`); } throw error; }
- src/server.ts:56-58 (schema)Zod schema defining the input parameters for the get_lunch_menu tool, requiring a 'date' string that must be a valid date.parameters: z.object({ date: z.string().date(), }),
- src/server.ts:35-59 (registration)Registration of the get_lunch_menu tool via server.addTool, including annotations, description, name, parameters schema, and inline handler function.server.addTool({ annotations: { openWorldHint: true, // This tool interacts with external API readOnlyHint: true, // This tool doesn't modify anything title: "Lunch Menu", }, description: "Get the lunch menu from the canteen for a specific date", execute: async (args) => { try { const response = await axios.get(process.env.API_URL!, { params: { date: args.date } }); return JSON.stringify(response.data, null, 2); } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to fetch menu: ${error.message}`); } throw error; } }, name: "get_lunch_menu", parameters: z.object({ date: z.string().date(), }), });