bbq_convert_temperature
Convert temperature between Fahrenheit and Celsius for BBQ cooking. Use this tool to translate temperature units for recipes, grill settings, or meat doneness guidelines.
Instructions
Convert temperature between Fahrenheit and Celsius.
Args:
temperature: Temperature value to convert
from_unit: Source unit ('fahrenheit' or 'celsius')
to_unit: Target unit ('fahrenheit' or 'celsius')
Examples:
"What is 225°F in Celsius?" -> temperature=225, from_unit='fahrenheit', to_unit='celsius'
"Convert 100°C to Fahrenheit" -> temperature=100, from_unit='celsius', to_unit='fahrenheit'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| temperature | Yes | Temperature value to convert | |
| from_unit | No | Source temperature unit | fahrenheit |
| to_unit | No | Target temperature unit | fahrenheit |
Implementation Reference
- src/index.ts:933-963 (handler)Main handler function for bbq_convert_temperature tool. Takes input params, calls convertTemperature helper, formats output with symbols, returns structured response or error.async (params: ConvertTemperatureInput) => { try { const result = convertTemperature(params.temperature, params.from_unit, params.to_unit); const fromSymbol = params.from_unit === "fahrenheit" ? "°F" : "°C"; const toSymbol = params.to_unit === "fahrenheit" ? "°F" : "°C"; const output = { original: { value: params.temperature, unit: params.from_unit, }, converted: { value: result, unit: params.to_unit, }, display: `${params.temperature}${fromSymbol} = ${result}${toSymbol}`, }; return { content: [{ type: "text", text: output.display }], structuredContent: output, }; } catch (error) { const message = error instanceof Error ? error.message : "Unknown error occurred"; return { isError: true, content: [{ type: "text", text: `Error converting temperature: ${message}` }], }; } }
- src/index.ts:911-932 (registration)Registration of the bbq_convert_temperature tool with server.registerTool, including title, detailed description, input schema, and annotations.server.registerTool( "bbq_convert_temperature", { title: "Convert Temperature", description: `Convert temperature between Fahrenheit and Celsius. Args: - temperature: Temperature value to convert - from_unit: Source unit ('fahrenheit' or 'celsius') - to_unit: Target unit ('fahrenheit' or 'celsius') Examples: - "What is 225°F in Celsius?" -> temperature=225, from_unit='fahrenheit', to_unit='celsius' - "Convert 100°C to Fahrenheit" -> temperature=100, from_unit='celsius', to_unit='fahrenheit'`, inputSchema: ConvertTemperatureSchema, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, },
- src/schemas/index.ts:258-266 (schema)Zod schema for input validation of the tool, defining temperature, from_unit, to_unit with descriptions. Exports type ConvertTemperatureInput.export const ConvertTemperatureSchema = z .object({ temperature: z.number().describe("Temperature value to convert"), from_unit: TemperatureUnitSchema.describe("Source temperature unit"), to_unit: TemperatureUnitSchema.describe("Target temperature unit"), }) .strict(); export type ConvertTemperatureInput = z.infer<typeof ConvertTemperatureSchema>;
- src/services/cooking.ts:502-514 (helper)Core helper function implementing F to C and C to F conversion with rounding to 1 decimal place.export function convertTemperature( temp: number, fromUnit: "fahrenheit" | "celsius", toUnit: "fahrenheit" | "celsius" ): number { if (fromUnit === toUnit) return temp; if (fromUnit === "fahrenheit" && toUnit === "celsius") { return Math.round(((temp - 32) * 5) / 9 * 10) / 10; } else { return Math.round((temp * 9) / 5 + 32); } }