Skip to main content
Glama
JunWoo0406

TypeScript MCP Server Boilerplate

by JunWoo0406

get-weather

Retrieve current weather, air quality, and daily forecasts by providing latitude and longitude coordinates. Uses Open-Meteo API to deliver weather data for specified forecast periods.

Instructions

위도, 경도, 예보 기간을 입력하면 현재 날씨, 미세먼지, 일별 예보를 반환합니다. Open-Meteo API를 사용합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes위도 (예: 37.5665)
longitudeYes경도 (예: 126.9780)
forecast_daysNo예보 기간 (일수, 기본값: 3, 최대: 16)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes

Implementation Reference

  • The `get-weather` tool uses Open-Meteo API to fetch current weather, air quality, and daily forecasts, which are then formatted into a user-friendly text string.
    server.registerTool(
        'get-weather',
        {
            description: '위도, 경도, 예보 기간을 입력하면 현재 날씨, 미세먼지, 일별 예보를 반환합니다. Open-Meteo API를 사용합니다.',
            inputSchema: z.object({
                latitude: z.number().describe('위도 (예: 37.5665)'),
                longitude: z.number().describe('경도 (예: 126.9780)'),
                forecast_days: z
                    .number()
                    .int()
                    .min(1)
                    .max(16)
                    .optional()
                    .default(3)
                    .describe('예보 기간 (일수, 기본값: 3, 최대: 16)')
            }),
            outputSchema: z.object({
                content: z.array(
                    z.object({
                        type: z.literal('text'),
                        text: z.string().describe('날씨 및 미세먼지 정보')
                    })
                )
            })
        },
        async ({ latitude, longitude, forecast_days }) => {
            const weatherParams = new URLSearchParams({
                latitude: String(latitude),
                longitude: String(longitude),
                current: 'temperature_2m,relative_humidity_2m,apparent_temperature,precipitation,weather_code,wind_speed_10m,is_day',
                daily: 'weather_code,temperature_2m_max,temperature_2m_min,precipitation_sum,wind_speed_10m_max',
                forecast_days: String(forecast_days),
                timezone: 'auto'
            })
    
            const aqParams = new URLSearchParams({
                latitude: String(latitude),
                longitude: String(longitude),
                current: 'pm10,pm2_5'
            })
    
            const [weatherRes, aqRes] = await Promise.all([
                fetch(`https://api.open-meteo.com/v1/forecast?${weatherParams}`),
                fetch(`https://air-quality-api.open-meteo.com/v1/air-quality?${aqParams}`)
            ])
    
            if (!weatherRes.ok) {
                const errorText = `오류: 날씨 API 요청 실패 (상태 코드: ${weatherRes.status})`
                return {
                    content: [{ type: 'text' as const, text: errorText }],
                    structuredContent: { content: [{ type: 'text' as const, text: errorText }] }
                }
            }
    
            const data = (await weatherRes.json()) as {
                current: {
                    temperature_2m: number
                    relative_humidity_2m: number
                    apparent_temperature: number
                    precipitation: number
                    weather_code: number
                    wind_speed_10m: 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 c = data.current
            const currentLines = [
                `[현재 날씨]`,
                `기온: ${c.temperature_2m}°C (체감 ${c.apparent_temperature}°C)`,
                `습도: ${c.relative_humidity_2m}%`,
                `강수량: ${c.precipitation}mm`,
                `풍속: ${c.wind_speed_10m}km/h`,
                `날씨: ${getWeatherDesc(c.weather_code)} (${c.is_day ? '낮' : '밤'})`
            ]
    
            if (aqRes.ok) {
                const aq = (await aqRes.json()) as {
                    current: { pm10: number; pm2_5: number }
                }
                const { pm10, pm2_5 } = aq.current
                currentLines.push(
                    `\n[미세먼지]`,
                    `PM10: ${pm10}㎍/㎥ (${getPm10Grade(pm10)})`,
                    `PM2.5: ${pm2_5}㎍/㎥ (${getPm25Grade(pm2_5)})`
                )
            }
    
            const d = data.daily
            const forecastLines = [`\n[일별 예보 (${forecast_days}일)]`]
            for (let i = 0; i < d.time.length; i++) {
                const date = new Date(d.time[i])
                const dayName = DAY_NAMES[date.getDay()]
                forecastLines.push(
                    `${d.time[i]} (${dayName}): 최고 ${d.temperature_2m_max[i]}°C / 최저 ${d.temperature_2m_min[i]}°C, 강수 ${d.precipitation_sum[i]}mm, 풍속 ${d.wind_speed_10m_max[i]}km/h, ${getWeatherDesc(d.weather_code[i])}`
                )
            }
    
            const text = [...currentLines, ...forecastLines].join('\n')
            return {
                content: [{ type: 'text' as const, text }],
                structuredContent: { content: [{ type: 'text' as const, text }] }
            }
        }
    )
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 data source (Open-Meteo API) and the specific data types returned (current weather, fine dust, daily forecast). However, it lacks details on rate limits, caching behavior, error conditions, or whether the API call is synchronous/asynchronous.

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?

The description is a single efficient sentence structured as input-to-output mapping, followed by a data source disclosure. Every clause earns its place; there is no redundant or filler text.

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?

Given the output schema exists, the description appropriately summarizes the return values (weather, dust, forecast) without replicating the full schema structure. It covers the essential contract for a read-only weather tool, though it could mention that `forecast_days` defaults to 3.

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%, establishing a baseline of 3. The description lists the three parameters (latitude, longitude, forecast period) in the first clause, confirming their role as inputs, but adds no semantic details beyond what the schema already provides (e.g., no clarification on coordinate systems or the optional nature of forecast_days).

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 tool returns current weather, fine dust (air quality), and daily forecasts based on coordinates and forecast period. It uses specific verbs and resources. However, it does not explicitly distinguish from the `geocode` sibling tool, which users might need to call first if they only have an address.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, nor does it mention that `geocode` should be used first if the user provides a location name instead of coordinates. No rate limits, prerequisites, or exclusion criteria are mentioned.

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/JunWoo0406/my-mcp-server'

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