mcp-swiss 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +61 -0
- package/dist/modules/companies.d.ts +83 -0
- package/dist/modules/companies.js +156 -0
- package/dist/modules/geodata.d.ts +109 -0
- package/dist/modules/geodata.js +174 -0
- package/dist/modules/transport.d.ts +141 -0
- package/dist/modules/transport.js +134 -0
- package/dist/modules/weather.d.ts +50 -0
- package/dist/modules/weather.js +128 -0
- package/dist/utils/http.d.ts +2 -0
- package/dist/utils/http.js +27 -0
- package/package.json +64 -0
- package/src/index.ts +70 -0
- package/src/modules/companies.ts +154 -0
- package/src/modules/geodata.ts +179 -0
- package/src/modules/transport.ts +138 -0
- package/src/modules/weather.ts +133 -0
- package/src/utils/http.ts +26 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { fetchJSON, buildUrl } from "../utils/http.js";
|
|
2
|
+
|
|
3
|
+
const BASE = "https://api.existenz.ch/apiv1";
|
|
4
|
+
|
|
5
|
+
export const weatherTools = [
|
|
6
|
+
{
|
|
7
|
+
name: "get_weather",
|
|
8
|
+
description: "Get current weather conditions at a Swiss MeteoSwiss station (e.g. BER=Bern, ZUE=Zürich, LUG=Lugano)",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
required: ["station"],
|
|
12
|
+
properties: {
|
|
13
|
+
station: { type: "string", description: "Station code (e.g. BER, ZUE, LUG, GVE, SMA)" },
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "list_weather_stations",
|
|
19
|
+
description: "List all available MeteoSwiss weather stations in Switzerland",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "get_weather_history",
|
|
27
|
+
description: "Get historical weather data for a Swiss station",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: "object",
|
|
30
|
+
required: ["station", "start_date", "end_date"],
|
|
31
|
+
properties: {
|
|
32
|
+
station: { type: "string", description: "Station code (e.g. BER)" },
|
|
33
|
+
start_date: { type: "string", description: "Start date YYYY-MM-DD" },
|
|
34
|
+
end_date: { type: "string", description: "End date YYYY-MM-DD" },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "get_water_level",
|
|
40
|
+
description: "Get current river or lake water level and temperature at a Swiss hydrological station",
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: "object",
|
|
43
|
+
required: ["station"],
|
|
44
|
+
properties: {
|
|
45
|
+
station: { type: "string", description: "Hydro station ID (e.g. 2135 for Aare/Bern, 2243 for Rhine/Basel)" },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "list_hydro_stations",
|
|
51
|
+
description: "List all available BAFU hydrological monitoring stations (rivers and lakes) in Switzerland",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "get_water_history",
|
|
59
|
+
description: "Get historical river/lake water level data for a Swiss hydrological station",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: "object",
|
|
62
|
+
required: ["station", "start_date", "end_date"],
|
|
63
|
+
properties: {
|
|
64
|
+
station: { type: "string", description: "Hydro station ID" },
|
|
65
|
+
start_date: { type: "string", description: "Start date YYYY-MM-DD" },
|
|
66
|
+
end_date: { type: "string", description: "End date YYYY-MM-DD" },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
export async function handleWeather(name: string, args: Record<string, unknown>): Promise<string> {
|
|
73
|
+
switch (name) {
|
|
74
|
+
case "get_weather": {
|
|
75
|
+
const url = buildUrl(`${BASE}/smn/latest`, {
|
|
76
|
+
locations: args.station as string,
|
|
77
|
+
app: "mcp-swiss",
|
|
78
|
+
version: "0.1.0",
|
|
79
|
+
});
|
|
80
|
+
const data = await fetchJSON<unknown>(url);
|
|
81
|
+
return JSON.stringify(data, null, 2);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
case "list_weather_stations": {
|
|
85
|
+
const url = buildUrl(`${BASE}/smn/locations`, { app: "mcp-swiss" });
|
|
86
|
+
const data = await fetchJSON<unknown>(url);
|
|
87
|
+
return JSON.stringify(data, null, 2);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
case "get_weather_history": {
|
|
91
|
+
const url = buildUrl(`${BASE}/smn/daterange`, {
|
|
92
|
+
locations: args.station as string,
|
|
93
|
+
startdt: args.start_date as string,
|
|
94
|
+
enddt: args.end_date as string,
|
|
95
|
+
app: "mcp-swiss",
|
|
96
|
+
version: "0.1.0",
|
|
97
|
+
});
|
|
98
|
+
const data = await fetchJSON<unknown>(url);
|
|
99
|
+
return JSON.stringify(data, null, 2);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
case "get_water_level": {
|
|
103
|
+
const url = buildUrl(`${BASE}/hydro/latest`, {
|
|
104
|
+
locations: args.station as string,
|
|
105
|
+
app: "mcp-swiss",
|
|
106
|
+
version: "0.1.0",
|
|
107
|
+
});
|
|
108
|
+
const data = await fetchJSON<unknown>(url);
|
|
109
|
+
return JSON.stringify(data, null, 2);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
case "list_hydro_stations": {
|
|
113
|
+
const url = buildUrl(`${BASE}/hydro/locations`, { app: "mcp-swiss" });
|
|
114
|
+
const data = await fetchJSON<unknown>(url);
|
|
115
|
+
return JSON.stringify(data, null, 2);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case "get_water_history": {
|
|
119
|
+
const url = buildUrl(`${BASE}/hydro/daterange`, {
|
|
120
|
+
locations: args.station as string,
|
|
121
|
+
startdt: args.start_date as string,
|
|
122
|
+
enddt: args.end_date as string,
|
|
123
|
+
app: "mcp-swiss",
|
|
124
|
+
version: "0.1.0",
|
|
125
|
+
});
|
|
126
|
+
const data = await fetchJSON<unknown>(url);
|
|
127
|
+
return JSON.stringify(data, null, 2);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
default:
|
|
131
|
+
throw new Error(`Unknown weather tool: ${name}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export async function fetchJSON<T>(url: string, options?: RequestInit): Promise<T> {
|
|
2
|
+
const response = await fetch(url, {
|
|
3
|
+
...options,
|
|
4
|
+
headers: {
|
|
5
|
+
"Accept": "application/json",
|
|
6
|
+
"User-Agent": "mcp-swiss/0.1.0",
|
|
7
|
+
...(options?.headers ?? {}),
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText} — ${url}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return response.json() as Promise<T>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildUrl(base: string, params: Record<string, string | number | boolean | undefined>): string {
|
|
19
|
+
const url = new URL(base);
|
|
20
|
+
for (const [key, value] of Object.entries(params)) {
|
|
21
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
22
|
+
url.searchParams.set(key, String(value));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return url.toString();
|
|
26
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|