Skip to main content
Glama
bakcoder

TypeScript MCP Server Boilerplate

by bakcoder

get-weather

Retrieve current weather conditions and daily forecasts by providing latitude and longitude coordinates. Uses Open-Meteo API without requiring API keys, supporting temperature units and forecast periods up to 16 days.

Instructions

위도·경도와 예보 기간을 입력받아 현재 날씨와 일별 예보를 반환합니다. (Open-Meteo API 사용, API 키 불필요)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes위도 (WGS84, -90 ~ 90)
longitudeYes경도 (WGS84, -180 ~ 180)
forecast_daysNo예보 기간 (일 수, 기본값: 7, 최대: 16)
temperature_unitNo온도 단위 (기본값: celsius)celsius

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dailyYes
contentYes
currentYes

Implementation Reference

  • The 'get-weather' tool is registered and implemented in src/index.ts, including its input schema and the asynchronous handler logic that calls the Open-Meteo API.
    server.registerTool(
        'get-weather',
        {
            description:
                '위도·경도와 예보 기간을 입력받아 현재 날씨와 일별 예보를 반환합니다. (Open-Meteo API 사용, API 키 불필요)',
            inputSchema: z.object({
                latitude: z
                    .number()
                    .min(-90)
                    .max(90)
                    .describe('위도 (WGS84, -90 ~ 90)'),
                longitude: z
                    .number()
                    .min(-180)
                    .max(180)
                    .describe('경도 (WGS84, -180 ~ 180)'),
                forecast_days: z
                    .number()
                    .int()
                    .min(1)
                    .max(16)
                    .optional()
                    .default(7)
                    .describe('예보 기간 (일 수, 기본값: 7, 최대: 16)'),
                temperature_unit: z
                    .enum(['celsius', 'fahrenheit'])
                    .optional()
                    .default('celsius')
                    .describe('온도 단위 (기본값: celsius)')
            }),
            outputSchema: z.object({
                content: z.array(
                    z.object({
                        type: z.literal('text'),
                        text: z.string().describe('날씨 요약 메시지')
                    })
                ),
                current: z.object({
                    time: z.string().describe('현재 시각'),
                    temperature: z.number().describe('현재 기온'),
                    apparentTemperature: z.number().describe('체감 기온'),
                    humidity: z.number().describe('상대 습도 (%)'),
                    weatherCode: z.number().describe('WMO 날씨 코드'),
                    weatherDescription: z.string().describe('날씨 설명'),
                    windSpeed: z.number().describe('풍속 (km/h)'),
                    precipitation: z.number().describe('강수량 (mm)'),
                    isDay: z.boolean().describe('낮 여부')
                }),
                daily: z.array(
                    z.object({
                        date: z.string().describe('날짜'),
                        weatherCode: z.number().describe('WMO 날씨 코드'),
                        weatherDescription: z.string().describe('날씨 설명'),
                        tempMax: z.number().describe('최고 기온'),
                        tempMin: z.number().describe('최저 기온'),
                        precipitationSum: z.number().describe('일 강수량 합계 (mm)'),
                        windSpeedMax: z.number().describe('최대 풍속 (km/h)')
                    })
                )
            })
        },
        async ({ latitude, longitude, forecast_days, temperature_unit }) => {
            const params = new URLSearchParams({
                latitude: String(latitude),
                longitude: String(longitude),
                current: [
                    'temperature_2m',
                    'apparent_temperature',
                    'relative_humidity_2m',
                    'weather_code',
                    'wind_speed_10m',
                    'precipitation',
                    'is_day'
                ].join(','),
                daily: [
                    'weather_code',
                    'temperature_2m_max',
                    'temperature_2m_min',
                    'precipitation_sum',
                    'wind_speed_10m_max'
                ].join(','),
                forecast_days: String(forecast_days),
                temperature_unit,
                wind_speed_unit: 'kmh',
                timezone: 'auto'
            })
    
            const response = await fetch(
                `https://api.open-meteo.com/v1/forecast?${params}`
            )
    
            if (!response.ok) {
                const err = (await response.json()) as { reason?: string }
                throw new Error(
                    `Open-Meteo API 오류: ${err.reason ?? response.statusText}`
                )
            }
    
            const data = (await response.json()) as {
                current: {
                    time: string
                    temperature_2m: number
                    apparent_temperature: number
                    relative_humidity_2m: number
                    weather_code: number
                    wind_speed_10m: number
                    precipitation: number
                    is_day: number
                }
                daily: {
                    time: string[]
                    weather_code: number[]
                    temperature_2m_max: number[]
                    temperature_2m_min: number[]
                    precipitation_sum: number[]
                    wind_speed_10m_max: number[]
                }
            }
    
            const unit = temperature_unit === 'fahrenheit' ? '°F' : '°C'
    
            const current = {
                time: data.current.time,
                temperature: data.current.temperature_2m,
                apparentTemperature: data.current.apparent_temperature,
                humidity: data.current.relative_humidity_2m,
                weatherCode: data.current.weather_code,
                weatherDescription: weatherCodeToDescription(
                    data.current.weather_code
                ),
                windSpeed: data.current.wind_speed_10m,
                precipitation: data.current.precipitation,
                isDay: data.current.is_day === 1
            }
    
            const daily = data.daily.time.map((date, i) => ({
                date,
                weatherCode: data.daily.weather_code[i],
                weatherDescription: weatherCodeToDescription(
                    data.daily.weather_code[i]
                ),
                tempMax: data.daily.temperature_2m_max[i],
                tempMin: data.daily.temperature_2m_min[i],
                precipitationSum: data.daily.precipitation_sum[i],
                windSpeedMax: data.daily.wind_speed_10m_max[i]
            }))
    
            const forecastLines = daily
                .map(
                    (d) =>
                        `  ${d.date}: ${d.weatherDescription}, 최고 ${d.tempMax}${unit} / 최저 ${d.tempMin}${unit}, 강수 ${d.precipitationSum}mm`
                )
                .join('\n')
    
            const message =
                `[현재 날씨] (${current.time})\n` +
                `  날씨: ${current.weatherDescription}\n` +
                `  기온: ${current.temperature}${unit} (체감 ${current.apparentTemperature}${unit})\n` +
                `  습도: ${current.humidity}%, 풍속: ${current.windSpeed}km/h, 강수: ${current.precipitation}mm\n\n` +
                `[${forecast_days}일 예보]\n` +
                forecastLines
    
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: message
                    }
                ],
                structuredContent: {
                    content: [
                        {
                            type: 'text' as const,
                            text: message
                        }
                    ],
                    current,
                    daily
                }
            }
        }
    )
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It successfully discloses the external API dependency (Open-Meteo) and authentication behavior (API key unnecessary), but omits other behavioral traits like rate limits, timeout behavior, or data freshness/caching policies.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely efficient single-sentence structure with high-density parenthetical addition. Every element earns its place: the main clause covers inputs/outputs, and the parenthetical covers critical behavioral context (API source and auth requirements) without clutter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Appropriate completeness given the tool's moderate complexity, 100% schema coverage, and existing output schema. The description covers the essential contract (inputs/outputs) and key operational note (no API key). Minor gap: does not explicitly declare read-only/safe nature absent annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing detailed constraints (WGS84 ranges, defaults, enums) for all 4 parameters. The description mentions latitude, longitude, and forecast period conceptually but adds no semantic details beyond what the schema already provides, earning the baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action (returns current weather and daily forecast) and required inputs (latitude, longitude, forecast period). However, it does not explicitly distinguish from siblings like 'geocode' (which complements this tool by converting addresses to coordinates), though the domains are distinct.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides useful context that the tool uses Open-Meteo API and requires no API key, which helps agents decide when to use it (free, accessible). However, it lacks explicit guidance on when NOT to use it (e.g., 'do not use for historical weather') or prerequisites (e.g., 'requires coordinates, not city names').

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bakcoder/my-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server