@mrfentmen/beatsaver-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 CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # beatsaver-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ MCP server for Beat Saber custom maps. Keyless: it reads the public BeatSaver API.
4
+
5
+ ## Tools
6
+
7
+ | Tool | What it returns |
8
+ | --- | --- |
9
+ | `get_latest_maps` | Newest maps with artist, mapper, duration, score and link |
10
+
11
+ ## Run
12
+
13
+ ```bash
14
+ npx -y @mrfentmen/beatsaver-mcp
15
+ ```
16
+
17
+ ## Build and test
18
+
19
+ ```bash
20
+ npm install
21
+ npm test
22
+ ```
package/dist/api.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export declare class BeatSaverError extends Error {
2
+ }
3
+ export interface BeatMap {
4
+ id: string;
5
+ song: string;
6
+ artist: string;
7
+ mapper: string;
8
+ duration: string;
9
+ score: string;
10
+ }
11
+ export declare function latestMaps(limit: number): Promise<BeatMap[]>;
12
+ export declare function formatMaps(list: BeatMap[]): string;
package/dist/api.js ADDED
@@ -0,0 +1,53 @@
1
+ const API = "https://api.beatsaver.com";
2
+ const H = {
3
+ "User-Agent": "mrfentmen-beatsaver-mcp/1.0 (+https://github.com/mrfentmen/awesome-servers)",
4
+ Accept: "application/json",
5
+ };
6
+ export class BeatSaverError extends Error {
7
+ }
8
+ function clock(seconds) {
9
+ if (typeof seconds !== "number" || seconds <= 0)
10
+ return "unknown";
11
+ const total = Math.round(seconds);
12
+ return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, "0")}`;
13
+ }
14
+ async function get(url) {
15
+ try {
16
+ const response = await fetch(url, { headers: H, signal: AbortSignal.timeout(20000) });
17
+ if (!response.ok)
18
+ throw new BeatSaverError(`BeatSaver answered ${response.status}`);
19
+ return (await response.json());
20
+ }
21
+ catch (error) {
22
+ if (error instanceof BeatSaverError)
23
+ throw error;
24
+ throw new BeatSaverError(`BeatSaver unreachable: ${error instanceof Error ? error.message : String(error)}`);
25
+ }
26
+ }
27
+ export async function latestMaps(limit) {
28
+ const url = new URL(`${API}/maps/latest`);
29
+ const json = await get(url);
30
+ const docs = json.docs;
31
+ if (!Array.isArray(docs))
32
+ throw new BeatSaverError("BeatSaver returned no maps");
33
+ return docs
34
+ .filter((map) => map.id && map.metadata?.songName)
35
+ .slice(0, limit)
36
+ .map((map) => {
37
+ const score = map.stats?.score;
38
+ return {
39
+ id: map.id,
40
+ song: map.metadata?.songName,
41
+ artist: map.metadata?.songAuthorName ?? "unknown artist",
42
+ mapper: map.metadata?.levelAuthorName ?? "unknown mapper",
43
+ duration: clock(map.metadata?.duration),
44
+ score: typeof score === "number" ? score.toFixed(1) : "unrated",
45
+ };
46
+ });
47
+ }
48
+ export function formatMaps(list) {
49
+ const lines = list.map((map, index) => {
50
+ return `${index + 1}. ${map.song} — ${map.artist} — mapped by ${map.mapper} — ${map.duration} — ${map.score}% — https://beatsaver.com/maps/${map.id}`;
51
+ });
52
+ return `# Latest Beat Saber maps\n\n${lines.join("\n")}`;
53
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
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("beatsaver-mcp running on stdio");
9
+ }
10
+ main().catch((error) => {
11
+ console.error("Fatal error:", error);
12
+ process.exit(1);
13
+ });
@@ -0,0 +1,2 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function createServer(): McpServer;
package/dist/server.js ADDED
@@ -0,0 +1,17 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { formatMaps, latestMaps } from "./api.js";
4
+ const text = (value) => ({ content: [{ type: "text", text: value }] });
5
+ const failed = (error) => text(`Error: ${error instanceof Error ? error.message : String(error)}`);
6
+ export function createServer() {
7
+ const server = new McpServer({ name: "beatsaver-mcp", version: "1.0.0" });
8
+ server.tool("get_latest_maps", "The newest Beat Saber maps on BeatSaver.", { limit: z.number().int().min(1).max(20).default(10) }, async ({ limit }) => {
9
+ try {
10
+ return text(formatMaps(await latestMaps(limit)));
11
+ }
12
+ catch (error) {
13
+ return failed(error);
14
+ }
15
+ });
16
+ return server;
17
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@mrfentmen/beatsaver-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "BeatSaver MCP: latest Beat Saber maps. Keyless.",
5
+ "type": "module",
6
+ "mcpName": "io.github.mrfentmen/beatsaver-mcp",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mrfentmen/awesome-servers.git"
10
+ },
11
+ "bin": {
12
+ "beatsaver-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
+ "beat-saber",
28
+ "beatsaver",
29
+ "maps",
30
+ "rhythm-games"
31
+ ],
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@modelcontextprotocol/sdk": "^1.0.4",
35
+ "zod": "^3.23.8"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.0.0",
39
+ "typescript": "^5.6.0"
40
+ }
41
+ }
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/beatsaver-mcp",
4
+ "description": "BeatSaver MCP: latest Beat Saber maps. 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/beatsaver-mcp",
14
+ "version": "1.0.0",
15
+ "transport": {
16
+ "type": "stdio"
17
+ }
18
+ }
19
+ ]
20
+ }