nager-mcp 1.0.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/README.md +13 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.js +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +57 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# nager-mcp
|
|
2
|
+
|
|
3
|
+
Fetch Nager.Date public holidays (keyless): countries, yearly holidays, upcoming holidays.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
- `list_countries` — Supported country codes.
|
|
8
|
+
- `get_holidays` — Holidays for a year and country.
|
|
9
|
+
- `next_holidays` — Next holidays for a country.
|
|
10
|
+
|
|
11
|
+
## Source
|
|
12
|
+
|
|
13
|
+
[nager-mcp](https://github.com/mrfentmen/premium-mcps/tree/main/servers/nager-mcp)
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class NagerError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare function errorMessage(e: unknown): string;
|
|
5
|
+
export declare function listCountries(): Promise<string>;
|
|
6
|
+
export declare function getHolidays(year: string, country: string): Promise<string>;
|
|
7
|
+
export declare function nextHolidays(country: string): Promise<string>;
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class NagerError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "NagerError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function errorMessage(e) {
|
|
8
|
+
return e instanceof Error ? e.message : String(e);
|
|
9
|
+
}
|
|
10
|
+
const UA = { "User-Agent": "awesome-mcps/1.0" };
|
|
11
|
+
async function get(path) {
|
|
12
|
+
let res;
|
|
13
|
+
try {
|
|
14
|
+
res = await fetch("https://date.nager.at/api/v3" + path, {
|
|
15
|
+
headers: { ...UA, Accept: "application/json" },
|
|
16
|
+
signal: AbortSignal.timeout(25000),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
throw new NagerError(`Network error: ${e.message}`);
|
|
21
|
+
}
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
const body = (await res.text()).slice(0, 300);
|
|
24
|
+
throw new NagerError(`HTTP ${res.status}: ${body}`);
|
|
25
|
+
}
|
|
26
|
+
return (await res.text()).slice(0, 12000);
|
|
27
|
+
}
|
|
28
|
+
export function listCountries() {
|
|
29
|
+
return get("/AvailableCountries");
|
|
30
|
+
}
|
|
31
|
+
export function getHolidays(year, country) {
|
|
32
|
+
return get(`/PublicHolidays/${encodeURIComponent(year)}/${encodeURIComponent(country)}`);
|
|
33
|
+
}
|
|
34
|
+
export function nextHolidays(country) {
|
|
35
|
+
return get(`/NextPublicHolidays/${encodeURIComponent(country)}`);
|
|
36
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
+
import { createServer } from "./server.js";
|
|
3
|
+
async function main() {
|
|
4
|
+
const server = createServer();
|
|
5
|
+
const transport = new StdioServerTransport();
|
|
6
|
+
await server.connect(transport);
|
|
7
|
+
console.error("MCP server running on stdio");
|
|
8
|
+
}
|
|
9
|
+
main().catch((err) => {
|
|
10
|
+
console.error("Fatal error:", err);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { errorMessage, listCountries, getHolidays, nextHolidays, } from "./api.js";
|
|
4
|
+
const text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
5
|
+
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
|
+
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
7
|
+
export function createServer() {
|
|
8
|
+
const server = new McpServer({
|
|
9
|
+
name: "nager-mcp",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
});
|
|
12
|
+
server.registerTool("list_countries", {
|
|
13
|
+
title: "List countries",
|
|
14
|
+
description: "Supported country codes.",
|
|
15
|
+
inputSchema: z.object({}),
|
|
16
|
+
annotations: READ_ONLY,
|
|
17
|
+
}, async ({}) => {
|
|
18
|
+
try {
|
|
19
|
+
return text(await listCountries());
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return textError(errorMessage(e));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
server.registerTool("get_holidays", {
|
|
26
|
+
title: "Year holidays",
|
|
27
|
+
description: "Holidays for a year and country.",
|
|
28
|
+
inputSchema: z.object({
|
|
29
|
+
year: z.string().describe("Year, e.g. 2026."),
|
|
30
|
+
country: z.string().describe("ISO code, e.g. US.")
|
|
31
|
+
}),
|
|
32
|
+
annotations: READ_ONLY,
|
|
33
|
+
}, async ({ year, country }) => {
|
|
34
|
+
try {
|
|
35
|
+
return text(await getHolidays(year, country));
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
return textError(errorMessage(e));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
server.registerTool("next_holidays", {
|
|
42
|
+
title: "Upcoming holidays",
|
|
43
|
+
description: "Next holidays for a country.",
|
|
44
|
+
inputSchema: z.object({
|
|
45
|
+
country: z.string().describe("ISO code, e.g. US.")
|
|
46
|
+
}),
|
|
47
|
+
annotations: READ_ONLY,
|
|
48
|
+
}, async ({ country }) => {
|
|
49
|
+
try {
|
|
50
|
+
return text(await nextHolidays(country));
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
return textError(errorMessage(e));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return server;
|
|
57
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nager-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Nager public holidays. Keyless.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"mcpName": "io.github.mrfentmen/nager-mcp",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/mrfentmen/premium-mcps.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"nager-mcp": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"dev": "rm -rf dist && tsc -p tsconfig.json && node dist/index.js",
|
|
22
|
+
"inspect": "npx @modelcontextprotocol/inspector node dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"holidays",
|
|
27
|
+
"calendar",
|
|
28
|
+
"countries",
|
|
29
|
+
"keyless"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
34
|
+
"zod": "^3.23.8"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^22.0.0",
|
|
38
|
+
"typescript": "^5.6.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
}
|
|
43
|
+
}
|