Skip to main content
Glama
dstotijn

KNMI MCP Server

by dstotijn

Get Weather

get_weather
Read-only

Retrieve current weather data for Dutch locations by entering city names like Amsterdam or De Bilt, which automatically convert to required grid identifiers.

Instructions

Get current weather information for a Dutch location. The location parameter accepts location names (e.g., 'Amsterdam', 'De Bilt') and automatically converts them to the required grid identifiers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesLocation name (e.g., 'Amsterdam', 'De Bilt')
regionNoOptional region number (0-15)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
sunNoSunrise and sunset times
windNoWind information for the current weather
dailyNoDaily forecast for the weather
alertsYesAlerts for this location in the next 48 hours
hourlyNoHourly forecast for the weather
uvIndexNoUV index data for the current weather
summariesYesSummary of the current weather conditions to be used
backgroundsNoThe weather backgrounds to be used

Implementation Reference

  • MCP tool handler for 'get_weather': resolves parameters, fetches weather data via KnmiApi, returns structured content or error.
    async ({ location, region }) => {
    	try {
    		const weatherData = await knmiApi.getWeather(location, region);
    		return {
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify(weatherData),
    				},
    			],
    			structuredContent: weatherData,
    		};
    	} catch (error) {
    		return {
    			content: [
    				{
    					type: "text",
    					text: `Error fetching weather data: ${error instanceof Error ? error.message : String(error)}`,
    				},
    			],
    			isError: true,
    		};
    	}
    },
  • Zod output schema for get_weather tool response, matching KNMI API Weather structure.
    const weatherOutputSchema = z.object({
    	backgrounds: z
    		.array(
    			z.object({
    				dateTime: z
    					.string()
    					.describe(
    						"Date of the background, the time from when this background is to be used",
    					),
    				sky: z.enum([
    					"dayClear",
    					"dayLightCloud",
    					"dayMediumCloud",
    					"dayHeavyCloud",
    					"nightClear",
    					"nightMediumCloud",
    					"nightHeavyCloud",
    				]),
    				celestial: z.enum(["sun", "moon"]).optional(),
    				clouds: z
    					.enum([
    						"dayMist",
    						"dayLightCloud",
    						"dayMediumCloud",
    						"dayHeavyCloud",
    						"dayHeavyCloudLightning",
    						"nightMist",
    						"nightLightCloud",
    						"nightMediumCloud",
    						"nightHeavyCloud",
    						"nightHeavyCloudLightning",
    					])
    					.optional(),
    				precipitation: z
    					.enum([
    						"lightRain",
    						"mediumRain",
    						"heavyRain",
    						"hail",
    						"lightSnow",
    						"mediumSnow",
    						"heavySnow",
    					])
    					.optional(),
    			}),
    		)
    		.optional()
    		.describe("The weather backgrounds to be used"),
    	summaries: z
    		.array(
    			z.object({
    				dateTime: z
    					.string()
    					.describe(
    						"Date of the summary, the time from when this summary is to be used",
    					),
    				temperature: z
    					.number()
    					.optional()
    					.describe("Current temperature in degrees Celsius"),
    			}),
    		)
    		.describe("Summary of the current weather conditions to be used"),
    	alerts: z
    		.array(
    			z.object({
    				level: z
    					.enum(["none", "potential", "yellow", "orange", "red"])
    					.describe("The alert level"),
    				title: z.string().describe("The title of the alert"),
    				description: z
    					.string()
    					.describe("The description of the alert"),
    			}),
    		)
    		.describe("Alerts for this location in the next 48 hours"),
    	hourly: z
    		.object({
    			forecast: z
    				.array(
    					z.object({
    						dateTime: z.string().describe("Date of the forecast"),
    						alertLevel: z
    							.enum([
    								"none",
    								"potential",
    								"yellow",
    								"orange",
    								"red",
    							])
    							.optional()
    							.describe(
    								"Highest alert level active for the hour",
    							),
    						weatherType: z
    							.number()
    							.describe("Type of weather condition"),
    						temperature: z
    							.number()
    							.describe("Temperature for the hour"),
    						precipitation: z
    							.object({
    								amount: z
    									.number()
    									.describe(
    										"Amount of rain in millimeter per hour",
    									),
    								chance: z
    									.number()
    									.describe("Chance of rain as a percentage"),
    							})
    							.describe("Precipitation information for the hour"),
    						wind: z
    							.object({
    								source: z.enum([
    									"N",
    									"NNE",
    									"NE",
    									"ENE",
    									"E",
    									"ESE",
    									"SE",
    									"SSE",
    									"S",
    									"SSW",
    									"SW",
    									"WSW",
    									"W",
    									"WNW",
    									"NW",
    									"NNW",
    									"VAR",
    								]),
    								speed: z
    									.number()
    									.describe(
    										"The wind speed in kilometers/hour",
    									),
    								gusts: z
    									.number()
    									.describe(
    										"The wind gusts in kilometers/hour",
    									),
    								degree: z
    									.number()
    									.optional()
    									.describe(
    										"Wind source in degrees (meteorological convention, 0 degrees represents north)",
    									),
    								beaufort: z
    									.number()
    									.describe(
    										"The wind speed according to the Beaufort scale",
    									),
    							})
    							.optional()
    							.describe("Wind information for the hour"),
    					}),
    				)
    				.describe("Entries with weather forecast"),
    		})
    		.optional()
    		.describe("Hourly forecast for the weather"),
    	daily: z
    		.object({
    			forecast: z
    				.array(
    					z.object({
    						date: z.string().describe("Date of the forecast"),
    						alertLevels: z
    							.array(
    								z.enum([
    									"none",
    									"potential",
    									"yellow",
    									"orange",
    									"red",
    								]),
    							)
    							.optional()
    							.describe("All alert levels active for the day"),
    						weatherType: z
    							.number()
    							.optional()
    							.describe("Type of weather condition"),
    						temperature: z
    							.object({
    								min: z
    									.number()
    									.optional()
    									.describe(
    										"The minimum temperature in degrees Celsius",
    									),
    								max: z
    									.number()
    									.optional()
    									.describe(
    										"The maximum temperature in degrees Celsius",
    									),
    							})
    							.describe("Temperature range for the day"),
    						precipitation: z
    							.object({
    								amount: z
    									.number()
    									.describe(
    										"Amount of rain in millimeter per hour",
    									),
    								chance: z
    									.number()
    									.describe("Chance of rain as a percentage"),
    							})
    							.describe("Precipitation information for the day"),
    					}),
    				)
    				.describe("Entries with weather forecast"),
    		})
    		.optional()
    		.describe("Daily forecast for the weather"),
    	sun: z
    		.object({
    			sunrise: z.string().describe("The time of sunrise"),
    			sunset: z.string().describe("The time of sunset"),
    		})
    		.optional()
    		.describe("Sunrise and sunset times"),
    	wind: z
    		.object({
    			source: z.enum([
    				"N",
    				"NNE",
    				"NE",
    				"ENE",
    				"E",
    				"ESE",
    				"SE",
    				"SSE",
    				"S",
    				"SSW",
    				"SW",
    				"WSW",
    				"W",
    				"WNW",
    				"NW",
    				"NNW",
    				"VAR",
    			]),
    			speed: z.number().describe("The wind speed in kilometers/hour"),
    			gusts: z.number().describe("The wind gusts in kilometers/hour"),
    			degree: z
    				.number()
    				.optional()
    				.describe(
    					"Wind source in degrees (meteorological convention, 0 degrees represents north)",
    				),
    			beaufort: z
    				.number()
    				.describe("The wind speed according to the Beaufort scale"),
    		})
    		.optional()
    		.describe("Wind information for the current weather"),
    	uvIndex: z
    		.object({
    			value: z.number().describe("UV index value"),
    			summary: z
    				.string()
    				.describe("A human-readable description of the UV index"),
    		})
    		.optional()
    		.describe("UV index data for the current weather"),
    });
  • src/index.ts:303-350 (registration)
    Registration of the 'get_weather' tool with MCP server, including title, description, input/output schemas, and handler.
    server.registerTool(
    	"get_weather",
    	{
    		title: "Get Weather",
    		description:
    			"Get current weather information for a Dutch location. The location parameter accepts location names (e.g., 'Amsterdam', 'De Bilt') and automatically converts them to the required grid identifiers.",
    		inputSchema: {
    			location: z
    				.string()
    				.describe("Location name (e.g., 'Amsterdam', 'De Bilt')"),
    			region: z
    				.number()
    				.int()
    				.min(0)
    				.max(15)
    				.optional()
    				.describe("Optional region number (0-15)"),
    		},
    		outputSchema: weatherOutputSchema.shape,
    		annotations: {
    			readOnlyHint: true,
    		},
    	},
    	async ({ location, region }) => {
    		try {
    			const weatherData = await knmiApi.getWeather(location, region);
    			return {
    				content: [
    					{
    						type: "text",
    						text: JSON.stringify(weatherData),
    					},
    				],
    				structuredContent: weatherData,
    			};
    		} catch (error) {
    			return {
    				content: [
    					{
    						type: "text",
    						text: `Error fetching weather data: ${error instanceof Error ? error.message : String(error)}`,
    					},
    				],
    				isError: true,
    			};
    		}
    	},
    );
  • KnmiApi.getWeather helper: resolves location ID, calls KNMI /weather endpoint, handles error.
    async getWeather(location: string, region?: number) {
    	// Resolve location name to grid identifier
    	const locationId = await resolveLocation(location);
    
    	const { data, error } = await this.client.GET("/weather", {
    		params: {
    			query: { location: locationId, region },
    		},
    	});
    	if (error) {
    		throw new Error(
    			`Failed to get weather: ${(error as components["schemas"]["ErrorResponse"]).title || "Unknown error"}`,
    		);
    	}
    	return data;
    }
Behavior3/5

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

The annotations provide readOnlyHint=true, indicating this is a safe read operation. The description adds value by explaining that location names are automatically converted to grid identifiers, which is useful behavioral context not covered by annotations. However, it does not disclose other potential traits like rate limits, error handling, or data freshness, leaving some gaps in transparency despite the annotation support.

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 concise and well-structured, consisting of two sentences that efficiently convey the tool's purpose and key behavioral detail (automatic conversion of location names). Every sentence adds value without redundancy, and the information is front-loaded, making it easy to grasp quickly. There is no wasted verbiage or unnecessary elaboration.

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 tool's moderate complexity (2 parameters, 1 required), the presence of annotations (readOnlyHint), and an output schema (which handles return values), the description is reasonably complete. It covers the core functionality and a key behavioral aspect (location conversion). However, it could be more comprehensive by addressing potential limitations or usage nuances, such as the scope of supported locations or the role of the optional region parameter.

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%, meaning the input schema fully documents both parameters (location and region). The description adds semantic context by clarifying that location names are accepted and automatically converted to grid identifiers, which enhances understanding beyond the schema's basic description. This provides some added value, but since the schema already covers the parameters well, the baseline score of 3 is appropriate.

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's purpose: 'Get current weather information for a Dutch location.' It specifies the verb ('Get'), resource ('weather information'), and geographic scope ('Dutch location'), making it easy to understand what the tool does. However, since there are no sibling tools, it cannot demonstrate differentiation from alternatives, which prevents a perfect score.

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 implies usage by specifying 'for a Dutch location,' which sets a geographic context. However, it does not provide explicit guidance on when to use this tool versus alternatives (e.g., other weather tools or methods), nor does it mention any exclusions or prerequisites. With no sibling tools, the lack of comparative guidance is less critical, but the description still only offers implied context without clear when/when-not instructions.

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/dstotijn/knmi-mcp'

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