Skip to main content
Glama
devbrother2024

TypeScript MCP Server Boilerplate

get-weather

Retrieve current weather conditions and daily forecasts by providing latitude and longitude coordinates with optional forecast duration.

Instructions

위도·경도 좌표와 예보 기간을 입력받아 현재 날씨와 일별 예보를 반환합니다. (Open-Meteo)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYesWGS84 위도
longitudeYesWGS84 경도
forecast_daysNo예보 일수 (기본값: 3, 최대: 7)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes날씨 정보

Implementation Reference

  • The implementation of the 'get-weather' tool, including tool registration, input/output schemas using Zod, and the handler function that fetches and processes data from the Open-Meteo API.
    server.registerTool(
        'get-weather',
        {
            description:
                '위도·경도 좌표와 예보 기간을 입력받아 현재 날씨와 일별 예보를 반환합니다. (Open-Meteo)',
            inputSchema: z.object({
                latitude: z.number().describe('WGS84 위도'),
                longitude: z.number().describe('WGS84 경도'),
                forecast_days: z
                    .number()
                    .int()
                    .min(1)
                    .max(7)
                    .optional()
                    .default(3)
                    .describe('예보 일수 (기본값: 3, 최대: 7)')
            }),
            outputSchema: z.object({
                content: z
                    .array(
                        z.object({
                            type: z.literal('text'),
                            text: z.string().describe('날씨 정보')
                        })
                    )
                    .describe('날씨 정보')
            })
        },
        async ({ latitude, longitude, forecast_days }) => {
            type WeatherResponse =
                | {
                      timezone: string
                      current: {
                          temperature_2m: number
                          relative_humidity_2m: number
                          weather_code: number
                          wind_speed_10m: number
                          precipitation: number
                      }
                      daily: {
                          time: string[]
                          temperature_2m_max: number[]
                          temperature_2m_min: number[]
                          precipitation_sum: number[]
                          weather_code: number[]
                      }
                  }
                | { error: true; reason: string }
    
            const url = new URL('https://api.open-meteo.com/v1/forecast')
            url.searchParams.set('latitude', String(latitude))
            url.searchParams.set('longitude', String(longitude))
            url.searchParams.set(
                'current',
                'temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m,precipitation'
            )
            url.searchParams.set(
                'daily',
                'temperature_2m_max,temperature_2m_min,precipitation_sum,weather_code'
            )
            url.searchParams.set('forecast_days', String(forecast_days))
            url.searchParams.set('timezone', 'auto')
    
            const res = await fetch(url.toString())
            const data = (await res.json()) as WeatherResponse
    
            if ('error' in data) throw new Error(data.reason)
    
            const DAY_NAMES = ['일', '월', '화', '수', '목', '금', '토']
            const { current, daily, timezone } = data
    
            const currentLines = [
                `현재 날씨 (${timezone})`,
                `  기온: ${current.temperature_2m}°C | 습도: ${current.relative_humidity_2m}% | 풍속: ${current.wind_speed_10m} km/h | 강수: ${current.precipitation}mm`
            ]
    
            const dailyLines = daily.time.map((date, i) => {
                const dayName = DAY_NAMES[new Date(date).getDay()]
                return `  ${date} (${dayName}): 최고 ${daily.temperature_2m_max[i]}°C / 최저 ${daily.temperature_2m_min[i]}°C, 강수 ${daily.precipitation_sum[i]}mm`
            })
    
            const text = [
                ...currentLines,
                '',
                '일별 예보:',
                ...dailyLines
            ].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?

No annotations provided, so description carries full burden. It discloses the Open-Meteo data source and specifies that both current weather and daily forecasts are returned. However, it omits behavioral details like rate limits, caching behavior, or error handling for invalid coordinates.

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?

Single efficient sentence with action front-loaded. The parenthetical data source '(Open-Meteo)' adds provenance without verbosity. No redundant or filler content.

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 existence of an output schema (per context signals) and 100% input schema coverage, the description appropriately summarizes the return value type (current + daily forecast) without enumerating fields. Adequate for a standard weather lookup tool.

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 adds conceptual context by grouping parameters as 'coordinates and forecast period' and explaining they are used to fetch weather data, but does not add syntax details beyond the schema (e.g., WGS84 format is only in schema).

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

Purpose5/5

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

Description clearly states the tool returns current weather and daily forecasts using coordinates and forecast periods. It effectively distinguishes from siblings (calc, generate-image, geocode, greet, time) by specifying the weather domain and Open-Meteo data source.

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?

Description implies usage context (weather lookup by coordinates) but provides no explicit when-to-use guidance versus alternatives. It does not mention coordinate prerequisites or suggest using the 'geocode' sibling tool first if the user only has an address string.

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

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