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,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.geodataTools = void 0;
|
|
4
|
+
exports.handleGeodata = handleGeodata;
|
|
5
|
+
const http_js_1 = require("../utils/http.js");
|
|
6
|
+
const BASE = "https://api3.geo.admin.ch";
|
|
7
|
+
exports.geodataTools = [
|
|
8
|
+
{
|
|
9
|
+
name: "geocode",
|
|
10
|
+
description: "Convert a Swiss address or place name to coordinates (swisstopo)",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
required: ["address"],
|
|
14
|
+
properties: {
|
|
15
|
+
address: { type: "string", description: "Swiss address or place name" },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "reverse_geocode",
|
|
21
|
+
description: "Convert coordinates to a Swiss address (swisstopo)",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
required: ["lat", "lng"],
|
|
25
|
+
properties: {
|
|
26
|
+
lat: { type: "number", description: "Latitude (WGS84)" },
|
|
27
|
+
lng: { type: "number", description: "Longitude (WGS84)" },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "search_places",
|
|
33
|
+
description: "Search Swiss place names, localities, mountains, and geographic features",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: "object",
|
|
36
|
+
required: ["query"],
|
|
37
|
+
properties: {
|
|
38
|
+
query: { type: "string", description: "Place name to search" },
|
|
39
|
+
type: { type: "string", description: "Type filter: locations, featuresearch" },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "get_solar_potential",
|
|
45
|
+
description: "Get rooftop solar energy potential for a location in Switzerland",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
required: ["lat", "lng"],
|
|
49
|
+
properties: {
|
|
50
|
+
lat: { type: "number", description: "Latitude (WGS84)" },
|
|
51
|
+
lng: { type: "number", description: "Longitude (WGS84)" },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "identify_location",
|
|
57
|
+
description: "Identify geographic features and data layers at a specific Swiss location",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: "object",
|
|
60
|
+
required: ["lat", "lng"],
|
|
61
|
+
properties: {
|
|
62
|
+
lat: { type: "number", description: "Latitude (WGS84)" },
|
|
63
|
+
lng: { type: "number", description: "Longitude (WGS84)" },
|
|
64
|
+
layers: { type: "string", description: "Comma-separated layer ids (default: all visible)" },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "get_municipality",
|
|
70
|
+
description: "Get information about a Swiss municipality by name",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: "object",
|
|
73
|
+
required: ["name"],
|
|
74
|
+
properties: {
|
|
75
|
+
name: { type: "string", description: "Municipality name" },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
// Convert WGS84 to LV95 (Swiss projection) — approximate
|
|
81
|
+
function wgs84ToLV95(lat, lng) {
|
|
82
|
+
// Approx conversion for API calls that need Swiss coords
|
|
83
|
+
const phiPrime = (lat * 3600 - 169028.66) / 10000;
|
|
84
|
+
const lambdaPrime = (lng * 3600 - 26782.5) / 10000;
|
|
85
|
+
const E = 2600072.37
|
|
86
|
+
+ 211455.93 * lambdaPrime
|
|
87
|
+
- 10938.51 * lambdaPrime * phiPrime
|
|
88
|
+
- 0.36 * lambdaPrime * phiPrime ** 2
|
|
89
|
+
- 44.54 * lambdaPrime ** 3;
|
|
90
|
+
const N = 1200147.07
|
|
91
|
+
+ 308807.95 * phiPrime
|
|
92
|
+
+ 3745.25 * lambdaPrime ** 2
|
|
93
|
+
+ 76.63 * phiPrime ** 2
|
|
94
|
+
- 194.56 * lambdaPrime ** 2 * phiPrime
|
|
95
|
+
+ 119.79 * phiPrime ** 3;
|
|
96
|
+
return { x: E, y: N };
|
|
97
|
+
}
|
|
98
|
+
async function handleGeodata(name, args) {
|
|
99
|
+
switch (name) {
|
|
100
|
+
case "geocode":
|
|
101
|
+
case "search_places": {
|
|
102
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/rest/services/api/SearchServer`, {
|
|
103
|
+
searchText: args.address ?? args.query,
|
|
104
|
+
type: args.type ?? "locations",
|
|
105
|
+
sr: 4326,
|
|
106
|
+
limit: 10,
|
|
107
|
+
});
|
|
108
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
109
|
+
return JSON.stringify(data, null, 2);
|
|
110
|
+
}
|
|
111
|
+
case "reverse_geocode": {
|
|
112
|
+
const lat = args.lat;
|
|
113
|
+
const lng = args.lng;
|
|
114
|
+
const { x, y } = wgs84ToLV95(lat, lng);
|
|
115
|
+
const extent = `${x - 100},${y - 100},${x + 100},${y + 100}`;
|
|
116
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/rest/services/api/SearchServer`, {
|
|
117
|
+
searchText: `${lat},${lng}`,
|
|
118
|
+
type: "locations",
|
|
119
|
+
sr: 4326,
|
|
120
|
+
limit: 5,
|
|
121
|
+
});
|
|
122
|
+
void extent; // extent used in identify, not reverse geocode search
|
|
123
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
124
|
+
return JSON.stringify(data, null, 2);
|
|
125
|
+
}
|
|
126
|
+
case "get_solar_potential": {
|
|
127
|
+
const lat = args.lat;
|
|
128
|
+
const lng = args.lng;
|
|
129
|
+
const extent = `${lng - 0.05},${lat - 0.05},${lng + 0.05},${lat + 0.05}`;
|
|
130
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/rest/services/all/MapServer/identify`, {
|
|
131
|
+
geometry: `${lng},${lat}`,
|
|
132
|
+
geometryType: "esriGeometryPoint",
|
|
133
|
+
layers: "all:ch.bfe.solarenergie-eignung-daecher",
|
|
134
|
+
mapExtent: extent,
|
|
135
|
+
imageDisplay: "500,500,96",
|
|
136
|
+
tolerance: 100,
|
|
137
|
+
sr: 4326,
|
|
138
|
+
returnGeometry: false,
|
|
139
|
+
});
|
|
140
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
141
|
+
return JSON.stringify(data, null, 2);
|
|
142
|
+
}
|
|
143
|
+
case "identify_location": {
|
|
144
|
+
const lat = args.lat;
|
|
145
|
+
const lng = args.lng;
|
|
146
|
+
const extent = `${lng - 0.05},${lat - 0.05},${lng + 0.05},${lat + 0.05}`;
|
|
147
|
+
const layers = args.layers ? `all:${args.layers}` : "all";
|
|
148
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/rest/services/all/MapServer/identify`, {
|
|
149
|
+
geometry: `${lng},${lat}`,
|
|
150
|
+
geometryType: "esriGeometryPoint",
|
|
151
|
+
layers,
|
|
152
|
+
mapExtent: extent,
|
|
153
|
+
imageDisplay: "500,500,96",
|
|
154
|
+
tolerance: 5,
|
|
155
|
+
sr: 4326,
|
|
156
|
+
returnGeometry: false,
|
|
157
|
+
});
|
|
158
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
159
|
+
return JSON.stringify(data, null, 2);
|
|
160
|
+
}
|
|
161
|
+
case "get_municipality": {
|
|
162
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/rest/services/api/SearchServer`, {
|
|
163
|
+
searchText: args.name,
|
|
164
|
+
type: "locations",
|
|
165
|
+
sr: 4326,
|
|
166
|
+
limit: 5,
|
|
167
|
+
});
|
|
168
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
169
|
+
return JSON.stringify(data, null, 2);
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
throw new Error(`Unknown geodata tool: ${name}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export declare const transportTools: ({
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
query: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
x: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
y: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
type: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
from?: undefined;
|
|
24
|
+
to?: undefined;
|
|
25
|
+
date?: undefined;
|
|
26
|
+
time?: undefined;
|
|
27
|
+
limit?: undefined;
|
|
28
|
+
isArrivalTime?: undefined;
|
|
29
|
+
station?: undefined;
|
|
30
|
+
datetime?: undefined;
|
|
31
|
+
distance?: undefined;
|
|
32
|
+
};
|
|
33
|
+
required?: undefined;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: string;
|
|
40
|
+
required: string[];
|
|
41
|
+
properties: {
|
|
42
|
+
from: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
to: {
|
|
47
|
+
type: string;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
date: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
time: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
limit: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
isArrivalTime: {
|
|
63
|
+
type: string;
|
|
64
|
+
description: string;
|
|
65
|
+
};
|
|
66
|
+
query?: undefined;
|
|
67
|
+
x?: undefined;
|
|
68
|
+
y?: undefined;
|
|
69
|
+
type?: undefined;
|
|
70
|
+
station?: undefined;
|
|
71
|
+
datetime?: undefined;
|
|
72
|
+
distance?: undefined;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
name: string;
|
|
77
|
+
description: string;
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: string;
|
|
80
|
+
required: string[];
|
|
81
|
+
properties: {
|
|
82
|
+
station: {
|
|
83
|
+
type: string;
|
|
84
|
+
description: string;
|
|
85
|
+
};
|
|
86
|
+
limit: {
|
|
87
|
+
type: string;
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
datetime: {
|
|
91
|
+
type: string;
|
|
92
|
+
description: string;
|
|
93
|
+
};
|
|
94
|
+
query?: undefined;
|
|
95
|
+
x?: undefined;
|
|
96
|
+
y?: undefined;
|
|
97
|
+
type?: undefined;
|
|
98
|
+
from?: undefined;
|
|
99
|
+
to?: undefined;
|
|
100
|
+
date?: undefined;
|
|
101
|
+
time?: undefined;
|
|
102
|
+
isArrivalTime?: undefined;
|
|
103
|
+
distance?: undefined;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: string;
|
|
111
|
+
required: string[];
|
|
112
|
+
properties: {
|
|
113
|
+
x: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
y: {
|
|
118
|
+
type: string;
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
limit: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
distance: {
|
|
126
|
+
type: string;
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
query?: undefined;
|
|
130
|
+
type?: undefined;
|
|
131
|
+
from?: undefined;
|
|
132
|
+
to?: undefined;
|
|
133
|
+
date?: undefined;
|
|
134
|
+
time?: undefined;
|
|
135
|
+
isArrivalTime?: undefined;
|
|
136
|
+
station?: undefined;
|
|
137
|
+
datetime?: undefined;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
})[];
|
|
141
|
+
export declare function handleTransport(name: string, args: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transportTools = void 0;
|
|
4
|
+
exports.handleTransport = handleTransport;
|
|
5
|
+
const http_js_1 = require("../utils/http.js");
|
|
6
|
+
const BASE = "https://transport.opendata.ch/v1";
|
|
7
|
+
exports.transportTools = [
|
|
8
|
+
{
|
|
9
|
+
name: "search_stations",
|
|
10
|
+
description: "Search for Swiss public transport stations/stops by name or coordinates",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
query: { type: "string", description: "Station name to search for" },
|
|
15
|
+
x: { type: "number", description: "Longitude (WGS84)" },
|
|
16
|
+
y: { type: "number", description: "Latitude (WGS84)" },
|
|
17
|
+
type: { type: "string", description: "Filter: all, station, poi, address" },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "get_connections",
|
|
23
|
+
description: "Get train/bus connections between two Swiss locations",
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
required: ["from", "to"],
|
|
27
|
+
properties: {
|
|
28
|
+
from: { type: "string", description: "Departure station/address" },
|
|
29
|
+
to: { type: "string", description: "Arrival station/address" },
|
|
30
|
+
date: { type: "string", description: "Date YYYY-MM-DD (default: today)" },
|
|
31
|
+
time: { type: "string", description: "Time HH:MM (default: now)" },
|
|
32
|
+
limit: { type: "number", description: "Number of connections (1-16, default: 4)" },
|
|
33
|
+
isArrivalTime: { type: "boolean", description: "True if time is arrival time" },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "get_departures",
|
|
39
|
+
description: "Get live departures from a Swiss transport station",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: "object",
|
|
42
|
+
required: ["station"],
|
|
43
|
+
properties: {
|
|
44
|
+
station: { type: "string", description: "Station name" },
|
|
45
|
+
limit: { type: "number", description: "Number of departures (default: 10)" },
|
|
46
|
+
datetime: { type: "string", description: "DateTime YYYY-MM-DDTHH:MM (default: now)" },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "get_arrivals",
|
|
52
|
+
description: "Get live arrivals at a Swiss transport station",
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: "object",
|
|
55
|
+
required: ["station"],
|
|
56
|
+
properties: {
|
|
57
|
+
station: { type: "string", description: "Station name" },
|
|
58
|
+
limit: { type: "number", description: "Number of arrivals (default: 10)" },
|
|
59
|
+
datetime: { type: "string", description: "DateTime YYYY-MM-DDTHH:MM (default: now)" },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "get_nearby_stations",
|
|
65
|
+
description: "Find Swiss public transport stations near given coordinates",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
required: ["x", "y"],
|
|
69
|
+
properties: {
|
|
70
|
+
x: { type: "number", description: "Longitude (WGS84)" },
|
|
71
|
+
y: { type: "number", description: "Latitude (WGS84)" },
|
|
72
|
+
limit: { type: "number", description: "Number of results (default: 10)" },
|
|
73
|
+
distance: { type: "number", description: "Max distance in meters" },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
async function handleTransport(name, args) {
|
|
79
|
+
switch (name) {
|
|
80
|
+
case "search_stations": {
|
|
81
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/locations`, {
|
|
82
|
+
query: args.query,
|
|
83
|
+
x: args.x,
|
|
84
|
+
y: args.y,
|
|
85
|
+
type: args.type,
|
|
86
|
+
});
|
|
87
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
88
|
+
return JSON.stringify(data.stations, null, 2);
|
|
89
|
+
}
|
|
90
|
+
case "get_connections": {
|
|
91
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/connections`, {
|
|
92
|
+
from: args.from,
|
|
93
|
+
to: args.to,
|
|
94
|
+
date: args.date,
|
|
95
|
+
time: args.time,
|
|
96
|
+
limit: args.limit,
|
|
97
|
+
isArrivalTime: args.isArrivalTime ? 1 : undefined,
|
|
98
|
+
});
|
|
99
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
100
|
+
return JSON.stringify(data.connections, null, 2);
|
|
101
|
+
}
|
|
102
|
+
case "get_departures": {
|
|
103
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/stationboard`, {
|
|
104
|
+
station: args.station,
|
|
105
|
+
limit: args.limit,
|
|
106
|
+
datetime: args.datetime,
|
|
107
|
+
type: "departure",
|
|
108
|
+
});
|
|
109
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
110
|
+
return JSON.stringify({ station: data.station, departures: data.stationboard }, null, 2);
|
|
111
|
+
}
|
|
112
|
+
case "get_arrivals": {
|
|
113
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/stationboard`, {
|
|
114
|
+
station: args.station,
|
|
115
|
+
limit: args.limit,
|
|
116
|
+
datetime: args.datetime,
|
|
117
|
+
type: "arrival",
|
|
118
|
+
});
|
|
119
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
120
|
+
return JSON.stringify({ station: data.station, arrivals: data.stationboard }, null, 2);
|
|
121
|
+
}
|
|
122
|
+
case "get_nearby_stations": {
|
|
123
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/locations`, {
|
|
124
|
+
x: args.x,
|
|
125
|
+
y: args.y,
|
|
126
|
+
type: "station",
|
|
127
|
+
});
|
|
128
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
129
|
+
return JSON.stringify(data.stations, null, 2);
|
|
130
|
+
}
|
|
131
|
+
default:
|
|
132
|
+
throw new Error(`Unknown transport tool: ${name}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const weatherTools: ({
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: string;
|
|
6
|
+
required: string[];
|
|
7
|
+
properties: {
|
|
8
|
+
station: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
start_date?: undefined;
|
|
13
|
+
end_date?: undefined;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
station?: undefined;
|
|
23
|
+
start_date?: undefined;
|
|
24
|
+
end_date?: undefined;
|
|
25
|
+
};
|
|
26
|
+
required?: undefined;
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: string;
|
|
33
|
+
required: string[];
|
|
34
|
+
properties: {
|
|
35
|
+
station: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
start_date: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
end_date: {
|
|
44
|
+
type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
})[];
|
|
50
|
+
export declare function handleWeather(name: string, args: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.weatherTools = void 0;
|
|
4
|
+
exports.handleWeather = handleWeather;
|
|
5
|
+
const http_js_1 = require("../utils/http.js");
|
|
6
|
+
const BASE = "https://api.existenz.ch/apiv1";
|
|
7
|
+
exports.weatherTools = [
|
|
8
|
+
{
|
|
9
|
+
name: "get_weather",
|
|
10
|
+
description: "Get current weather conditions at a Swiss MeteoSwiss station (e.g. BER=Bern, ZUE=Zürich, LUG=Lugano)",
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
required: ["station"],
|
|
14
|
+
properties: {
|
|
15
|
+
station: { type: "string", description: "Station code (e.g. BER, ZUE, LUG, GVE, SMA)" },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "list_weather_stations",
|
|
21
|
+
description: "List all available MeteoSwiss weather stations in Switzerland",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "get_weather_history",
|
|
29
|
+
description: "Get historical weather data for a Swiss station",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
required: ["station", "start_date", "end_date"],
|
|
33
|
+
properties: {
|
|
34
|
+
station: { type: "string", description: "Station code (e.g. BER)" },
|
|
35
|
+
start_date: { type: "string", description: "Start date YYYY-MM-DD" },
|
|
36
|
+
end_date: { type: "string", description: "End date YYYY-MM-DD" },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "get_water_level",
|
|
42
|
+
description: "Get current river or lake water level and temperature at a Swiss hydrological station",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
required: ["station"],
|
|
46
|
+
properties: {
|
|
47
|
+
station: { type: "string", description: "Hydro station ID (e.g. 2135 for Aare/Bern, 2243 for Rhine/Basel)" },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "list_hydro_stations",
|
|
53
|
+
description: "List all available BAFU hydrological monitoring stations (rivers and lakes) in Switzerland",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "get_water_history",
|
|
61
|
+
description: "Get historical river/lake water level data for a Swiss hydrological station",
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: "object",
|
|
64
|
+
required: ["station", "start_date", "end_date"],
|
|
65
|
+
properties: {
|
|
66
|
+
station: { type: "string", description: "Hydro station ID" },
|
|
67
|
+
start_date: { type: "string", description: "Start date YYYY-MM-DD" },
|
|
68
|
+
end_date: { type: "string", description: "End date YYYY-MM-DD" },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
async function handleWeather(name, args) {
|
|
74
|
+
switch (name) {
|
|
75
|
+
case "get_weather": {
|
|
76
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/smn/latest`, {
|
|
77
|
+
locations: args.station,
|
|
78
|
+
app: "mcp-swiss",
|
|
79
|
+
version: "0.1.0",
|
|
80
|
+
});
|
|
81
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
82
|
+
return JSON.stringify(data, null, 2);
|
|
83
|
+
}
|
|
84
|
+
case "list_weather_stations": {
|
|
85
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/smn/locations`, { app: "mcp-swiss" });
|
|
86
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
87
|
+
return JSON.stringify(data, null, 2);
|
|
88
|
+
}
|
|
89
|
+
case "get_weather_history": {
|
|
90
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/smn/daterange`, {
|
|
91
|
+
locations: args.station,
|
|
92
|
+
startdt: args.start_date,
|
|
93
|
+
enddt: args.end_date,
|
|
94
|
+
app: "mcp-swiss",
|
|
95
|
+
version: "0.1.0",
|
|
96
|
+
});
|
|
97
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
98
|
+
return JSON.stringify(data, null, 2);
|
|
99
|
+
}
|
|
100
|
+
case "get_water_level": {
|
|
101
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/hydro/latest`, {
|
|
102
|
+
locations: args.station,
|
|
103
|
+
app: "mcp-swiss",
|
|
104
|
+
version: "0.1.0",
|
|
105
|
+
});
|
|
106
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
107
|
+
return JSON.stringify(data, null, 2);
|
|
108
|
+
}
|
|
109
|
+
case "list_hydro_stations": {
|
|
110
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/hydro/locations`, { app: "mcp-swiss" });
|
|
111
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
112
|
+
return JSON.stringify(data, null, 2);
|
|
113
|
+
}
|
|
114
|
+
case "get_water_history": {
|
|
115
|
+
const url = (0, http_js_1.buildUrl)(`${BASE}/hydro/daterange`, {
|
|
116
|
+
locations: args.station,
|
|
117
|
+
startdt: args.start_date,
|
|
118
|
+
enddt: args.end_date,
|
|
119
|
+
app: "mcp-swiss",
|
|
120
|
+
version: "0.1.0",
|
|
121
|
+
});
|
|
122
|
+
const data = await (0, http_js_1.fetchJSON)(url);
|
|
123
|
+
return JSON.stringify(data, null, 2);
|
|
124
|
+
}
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unknown weather tool: ${name}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchJSON = fetchJSON;
|
|
4
|
+
exports.buildUrl = buildUrl;
|
|
5
|
+
async function fetchJSON(url, options) {
|
|
6
|
+
const response = await fetch(url, {
|
|
7
|
+
...options,
|
|
8
|
+
headers: {
|
|
9
|
+
"Accept": "application/json",
|
|
10
|
+
"User-Agent": "mcp-swiss/0.1.0",
|
|
11
|
+
...(options?.headers ?? {}),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText} — ${url}`);
|
|
16
|
+
}
|
|
17
|
+
return response.json();
|
|
18
|
+
}
|
|
19
|
+
function buildUrl(base, params) {
|
|
20
|
+
const url = new URL(base);
|
|
21
|
+
for (const [key, value] of Object.entries(params)) {
|
|
22
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
23
|
+
url.searchParams.set(key, String(value));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return url.toString();
|
|
27
|
+
}
|