@mrfentmen/epic-games-mcp 0.0.0-stage → 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 +22 -2
- package/dist/api.d.ts +12 -0
- package/dist/api.js +69 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +24 -0
- package/package.json +38 -4
- package/server.json +20 -0
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# epic-games-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for the Epic Games Store giveaways. Keyless: it reads the public free-games feed.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | What it returns |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `get_free_games` | Games free to keep right now, with the end date |
|
|
10
|
+
| `get_upcoming_free_games` | Games free next, with the start date |
|
|
11
|
+
|
|
12
|
+
## Run
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx -y @mrfentmen/epic-games-mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Build and test
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install
|
|
22
|
+
npm test
|
|
23
|
+
```
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class EpicGamesError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export interface Offer {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
url: string | null;
|
|
7
|
+
start: string | null;
|
|
8
|
+
end: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function formatOffers(heading: string, offers: Offer[]): string;
|
|
11
|
+
export declare function freeNow(): Promise<string>;
|
|
12
|
+
export declare function freeUpcoming(): Promise<string>;
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const FEED = "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions";
|
|
2
|
+
const STORE = "https://store.epicgames.com/en-US/p";
|
|
3
|
+
const H = {
|
|
4
|
+
"User-Agent": "mrfentmen-epic-games-mcp/1.0 (+https://github.com/mrfentmen/awesome-servers)",
|
|
5
|
+
Accept: "application/json",
|
|
6
|
+
};
|
|
7
|
+
export class EpicGamesError extends Error {
|
|
8
|
+
}
|
|
9
|
+
function windowOf(offer) {
|
|
10
|
+
const first = offer?.[0];
|
|
11
|
+
return { start: first?.startDate?.slice(0, 10) ?? null, end: first?.endDate?.slice(0, 10) ?? null };
|
|
12
|
+
}
|
|
13
|
+
async function fetchFeed() {
|
|
14
|
+
let json;
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch(FEED, { headers: H, signal: AbortSignal.timeout(20000) });
|
|
17
|
+
if (!response.ok)
|
|
18
|
+
throw new EpicGamesError(`Epic store answered ${response.status}`);
|
|
19
|
+
json = (await response.json());
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof EpicGamesError)
|
|
23
|
+
throw error;
|
|
24
|
+
throw new EpicGamesError(`Epic store unreachable: ${error instanceof Error ? error.message : String(error)}`);
|
|
25
|
+
}
|
|
26
|
+
const elements = json.data?.Catalog?.searchStore?.elements;
|
|
27
|
+
if (!elements)
|
|
28
|
+
throw new EpicGamesError("Epic store returned no catalog");
|
|
29
|
+
return elements;
|
|
30
|
+
}
|
|
31
|
+
function toOffer(element, groups) {
|
|
32
|
+
const slug = element.urlSlug ?? element.productSlug;
|
|
33
|
+
if (!element.title || !slug)
|
|
34
|
+
return null;
|
|
35
|
+
const window = windowOf(groups?.[0]?.promotionalOffers);
|
|
36
|
+
return {
|
|
37
|
+
title: element.title,
|
|
38
|
+
description: (element.description ?? "").replace(/<[^>]+>/g, "").trim(),
|
|
39
|
+
url: `${STORE}/${slug.split("/")[0]}`,
|
|
40
|
+
start: window.start,
|
|
41
|
+
end: window.end,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function formatOffers(heading, offers) {
|
|
45
|
+
if (offers.length === 0)
|
|
46
|
+
return `# ${heading}\n\nNothing matches right now.`;
|
|
47
|
+
const lines = offers.map((offer, index) => {
|
|
48
|
+
const when = offer.end ? `free until ${offer.end}` : "free now";
|
|
49
|
+
const start = offer.start ? `from ${offer.start}` : "";
|
|
50
|
+
const window = [when, start].filter(Boolean).join(", ");
|
|
51
|
+
return `${index + 1}. ${offer.title} — ${window}${offer.url ? ` — ${offer.url}` : ""}`;
|
|
52
|
+
});
|
|
53
|
+
return `# ${heading}\n\n${lines.join("\n")}`;
|
|
54
|
+
}
|
|
55
|
+
export async function freeNow() {
|
|
56
|
+
const elements = await fetchFeed();
|
|
57
|
+
const offers = elements
|
|
58
|
+
.filter((element) => (element.price?.totalPrice?.discountPrice ?? 1) === 0)
|
|
59
|
+
.map((element) => toOffer(element, element.promotions?.promotionalOffers))
|
|
60
|
+
.filter((offer) => offer !== null);
|
|
61
|
+
return formatOffers("Free on the Epic Games Store now", offers);
|
|
62
|
+
}
|
|
63
|
+
export async function freeUpcoming() {
|
|
64
|
+
const elements = await fetchFeed();
|
|
65
|
+
const offers = elements
|
|
66
|
+
.map((element) => toOffer(element, element.promotions?.upcomingPromotionalOffers))
|
|
67
|
+
.filter((offer) => offer !== null);
|
|
68
|
+
return formatOffers("Coming free on the Epic Games Store", offers);
|
|
69
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createServer } from "./server.js";
|
|
4
|
+
async function main() {
|
|
5
|
+
const server = createServer();
|
|
6
|
+
const transport = new StdioServerTransport();
|
|
7
|
+
await server.connect(transport);
|
|
8
|
+
console.error("epic-games-mcp running on stdio");
|
|
9
|
+
}
|
|
10
|
+
main().catch((error) => {
|
|
11
|
+
console.error("Fatal error:", error);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { freeNow, freeUpcoming } from "./api.js";
|
|
3
|
+
const text = (value) => ({ content: [{ type: "text", text: value }] });
|
|
4
|
+
const failed = (error) => text(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
5
|
+
export function createServer() {
|
|
6
|
+
const server = new McpServer({ name: "epic-games-mcp", version: "1.0.0" });
|
|
7
|
+
server.tool("get_free_games", "Games free to keep on the Epic Games Store right now, with the end date.", {}, async () => {
|
|
8
|
+
try {
|
|
9
|
+
return text(await freeNow());
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
return failed(error);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
server.tool("get_upcoming_free_games", "Games the Epic Games Store will give away next, with the start date.", {}, async () => {
|
|
16
|
+
try {
|
|
17
|
+
return text(await freeUpcoming());
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return failed(error);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return server;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrfentmen/epic-games-mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Epic Games Store MCP: the games free to keep now and next. Keyless.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"mcpName": "io.github.mrfentmen/epic-games-mcp",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mrfentmen/awesome-servers.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"epic-games-mcp": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"server.json",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"start": "node dist/index.js",
|
|
23
|
+
"test": "npm run build && node --test tests/tools.test.mjs"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"mcp",
|
|
27
|
+
"epic-games",
|
|
28
|
+
"free-games",
|
|
29
|
+
"video-games"
|
|
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
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.mrfentmen/epic-games-mcp",
|
|
4
|
+
"description": "Epic Games MCP: games free to keep on the Epic store now and next. Keyless.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/mrfentmen/awesome-servers",
|
|
7
|
+
"source": "github"
|
|
8
|
+
},
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"packages": [
|
|
11
|
+
{
|
|
12
|
+
"registryType": "npm",
|
|
13
|
+
"identifier": "@mrfentmen/epic-games-mcp",
|
|
14
|
+
"version": "1.0.0",
|
|
15
|
+
"transport": {
|
|
16
|
+
"type": "stdio"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|