mr-magic-mcp-server 0.2.6 → 0.3.1
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/.env.example +53 -24
- package/README.md +439 -143
- package/package.json +4 -2
- package/src/providers/genius.js +1 -1
- package/src/providers/musixmatch.js +2 -3
- package/src/scripts/fetch_genius_token.mjs +21 -4
- package/src/scripts/fetch_musixmatch_token.mjs +169 -23
- package/src/scripts/push_musixmatch_token.mjs +133 -0
- package/src/transport/mcp-tools.js +2 -3
- package/src/transport/token-startup-log.js +4 -5
- package/src/utils/config.js +1 -1
- package/src/utils/kv-store.js +157 -0
- package/src/utils/tokens/genius-token-manager.js +97 -22
- package/src/utils/tokens/musixmatch-token-manager.js +77 -36
package/.env.example
CHANGED
|
@@ -10,41 +10,65 @@
|
|
|
10
10
|
# OAuth client_credentials endpoint at runtime and refreshes the token in
|
|
11
11
|
# memory automatically. No disk, no scripts, no manual token copying needed.
|
|
12
12
|
#
|
|
13
|
-
#
|
|
14
|
-
# Set
|
|
13
|
+
# Direct token (env var) — static bearer token, no auto-refresh
|
|
14
|
+
# Set GENIUS_DIRECT_TOKEN. Works everywhere but the token must be
|
|
15
15
|
# manually updated on expiry (or redeploy with a new value).
|
|
16
16
|
# Use this only when client_credentials are unavailable.
|
|
17
17
|
#
|
|
18
|
-
# Cache token (on-disk) — local
|
|
18
|
+
# Cache token (on-disk) — local instance or persistent servers only
|
|
19
19
|
# Run `npm run fetch:genius-token` to write a token to
|
|
20
20
|
# `.cache/genius-token.json`. The server reads it on startup when a
|
|
21
21
|
# persistent, writable filesystem is available. Not suitable for
|
|
22
22
|
# ephemeral hosts.
|
|
23
23
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
24
|
-
GENIUS_CLIENT_ID=
|
|
25
|
-
GENIUS_CLIENT_SECRET=
|
|
26
|
-
|
|
24
|
+
GENIUS_CLIENT_ID=
|
|
25
|
+
GENIUS_CLIENT_SECRET=
|
|
26
|
+
GENIUS_DIRECT_TOKEN=
|
|
27
27
|
|
|
28
28
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
29
29
|
# REQUIRED (feature-specific) — Musixmatch
|
|
30
30
|
# At least one token source is needed for Musixmatch lyrics support.
|
|
31
31
|
# WARNING: Unauthorized Public API usage can result in a ban of your account!
|
|
32
32
|
# ───────────────────────────────────────────────────────────────────────────────
|
|
33
|
-
#
|
|
33
|
+
# Token resolution priority (1 = highest):
|
|
34
34
|
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
# free tier, serverless, containers without a mounted volume).
|
|
39
|
-
# Resolution order: MUSIXMATCH_FALLBACK_TOKEN (1st) → MUSIXMATCH_ALT_FALLBACK_TOKEN (2nd)
|
|
35
|
+
# 1. MUSIXMATCH_DIRECT_TOKEN (env var)
|
|
36
|
+
# Static bearer token. Works everywhere but must be manually updated on
|
|
37
|
+
# expiry. Use when no other option is available.
|
|
40
38
|
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
39
|
+
# 2. KV store — Upstash Redis or Cloudflare KV (recommended for ephemeral / npx)
|
|
40
|
+
# Run `npm run fetch:musixmatch-token` once to sign in and push the token
|
|
41
|
+
# to KV automatically. The server reads it from KV on startup.
|
|
42
|
+
# Works for npx installs and any deployment without a local filesystem.
|
|
43
|
+
# Configure with UPSTASH_REDIS_REST_URL/TOKEN (already used by the export
|
|
44
|
+
# backend) or the Cloudflare KV vars below.
|
|
45
|
+
#
|
|
46
|
+
# 3. On-disk cache token (local dev / persistent servers only)
|
|
47
|
+
# Run `npm run fetch:musixmatch-token` — writes .cache/musixmatch-token.json.
|
|
48
|
+
# The server reads it on startup when a writable filesystem is available.
|
|
45
49
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
MUSIXMATCH_DIRECT_TOKEN=
|
|
51
|
+
|
|
52
|
+
# KV store for Musixmatch token persistence (ephemeral deployments / npx installs)
|
|
53
|
+
# Priority: Upstash Redis (priority 1) → Cloudflare KV (priority 2)
|
|
54
|
+
# If both are set, Upstash Redis is used and Cloudflare KV is ignored.
|
|
55
|
+
#
|
|
56
|
+
# Upstash Redis: reuse the same creds as the export backend (see below) — no extra setup.
|
|
57
|
+
# Cloudflare KV: set the three CF_* vars; create a namespace at dash.cloudflare.com.
|
|
58
|
+
CF_API_TOKEN= # Cloudflare API token with KV:Edit permission (CF KV only)
|
|
59
|
+
CF_ACCOUNT_ID= # Cloudflare account ID (CF KV only)
|
|
60
|
+
CF_KV_NAMESPACE_ID= # KV namespace ID to store the token in (CF KV only)
|
|
61
|
+
# Optional overrides (defaults are sensible for most users)
|
|
62
|
+
MUSIXMATCH_TOKEN_KV_KEY= # KV key name (default: mr-magic:musixmatch-token)
|
|
63
|
+
MUSIXMATCH_TOKEN_KV_TTL_SECONDS= # Token TTL in seconds (default: 2592000 = 30 days)
|
|
64
|
+
|
|
65
|
+
# Headless / Render deployment — push a pre-captured token without opening a browser.
|
|
66
|
+
# run `npm run fetch:musixmatch-token` or sign into Musixmatch manually to get a token, then set it in the env to push it to the KV store without browser automation.
|
|
67
|
+
# Set MUSIXMATCH_DIRECT_TOKEN to the full musixmatchUserToken JSON payload (from fetch:musixmatch-token output),
|
|
68
|
+
# then run `npm run push:musixmatch-token` or prepend it to the start command:
|
|
69
|
+
# npm run push:musixmatch-token && npm run server:mcp:http
|
|
70
|
+
# If unset, push:musixmatch-token exits silently (safe no-op in start commands).
|
|
71
|
+
# MUSIXMATCH_DIRECT_TOKEN also serves as the runtime token override (highest env priority).
|
|
48
72
|
|
|
49
73
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
50
74
|
# REQUIRED (feature-specific) — Airtable
|
|
@@ -60,7 +84,7 @@ AIRTABLE_PERSONAL_ACCESS_TOKEN=
|
|
|
60
84
|
# ───────────────────────────────────────────────────────────────────────────────
|
|
61
85
|
# local — writes files to MR_MAGIC_EXPORT_DIR (default; requires writable FS)
|
|
62
86
|
# inline — embeds payload directly in the MCP response (no storage needed)
|
|
63
|
-
# redis — stores in Upstash Redis; best for production/ephemeral hosts
|
|
87
|
+
# redis — stores in Upstash Redis KV store; best for production/ephemeral hosts
|
|
64
88
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
65
89
|
MR_MAGIC_EXPORT_BACKEND= # local | inline | redis
|
|
66
90
|
|
|
@@ -68,6 +92,8 @@ MR_MAGIC_EXPORT_BACKEND= # local | inline | redis
|
|
|
68
92
|
MR_MAGIC_EXPORT_DIR= # Absolute path to the directory to write export files into
|
|
69
93
|
|
|
70
94
|
# Required when BACKEND=redis — get from https://console.upstash.com/redis/rest
|
|
95
|
+
# These same credentials are also used by the Musixmatch KV token store, so
|
|
96
|
+
# setting them once enables both features.
|
|
71
97
|
UPSTASH_REDIS_REST_URL=
|
|
72
98
|
UPSTASH_REDIS_REST_TOKEN=
|
|
73
99
|
|
|
@@ -93,10 +119,6 @@ MELON_COOKIE= # Pin a browser session cookie for consistent result
|
|
|
93
119
|
# Advanced / Debug (safe to leave unset in production)
|
|
94
120
|
# ═══════════════════════════════════════════════════════════════════════════════
|
|
95
121
|
|
|
96
|
-
# Override project root and .env file path resolution (rarely needed)
|
|
97
|
-
MR_MAGIC_ROOT=
|
|
98
|
-
MR_MAGIC_ENV_PATH=
|
|
99
|
-
|
|
100
122
|
# Inline payload size threshold: auto-promotes to reference transport when
|
|
101
123
|
# lyrics exceed this many characters and omitInlineLyrics is true (default: 1500)
|
|
102
124
|
MR_MAGIC_INLINE_PAYLOAD_MAX_CHARS=1500
|
|
@@ -104,7 +126,7 @@ MR_MAGIC_INLINE_PAYLOAD_MAX_CHARS=1500
|
|
|
104
126
|
# Export TTL in seconds for local and redis backends (default: 3600 / 1 hour)
|
|
105
127
|
MR_MAGIC_EXPORT_TTL_SECONDS=3600
|
|
106
128
|
|
|
107
|
-
# Override the on-disk cache token paths (local
|
|
129
|
+
# Override the on-disk cache token paths (local instances/ persistent servers only)
|
|
108
130
|
GENIUS_TOKEN_CACHE=.cache/genius-token.json
|
|
109
131
|
MUSIXMATCH_TOKEN_CACHE=.cache/musixmatch-token.json
|
|
110
132
|
|
|
@@ -112,6 +134,9 @@ MUSIXMATCH_TOKEN_CACHE=.cache/musixmatch-token.json
|
|
|
112
134
|
# automatically (headless) if no token is available
|
|
113
135
|
MUSIXMATCH_AUTO_FETCH=0
|
|
114
136
|
|
|
137
|
+
# Playwright Headless mode toggle for fetch scripts that require browser automation (default: false)
|
|
138
|
+
HEADLESS=
|
|
139
|
+
|
|
115
140
|
# MCP tool argument chunk logging — enable to debug truncation issues
|
|
116
141
|
MR_MAGIC_LOG_TOOL_ARGS_CHUNKS=0 # Set to 1 to emit per-chunk MCP tool argument previews
|
|
117
142
|
MR_MAGIC_TOOL_ARG_CHUNK_SIZE=400 # Chunk size in chars (only used when LOG_TOOL_ARGS_CHUNKS=1)
|
|
@@ -123,3 +148,7 @@ MR_MAGIC_SESSIONLESS=0 # Set to 1 to force sessionless mode (each req
|
|
|
123
148
|
|
|
124
149
|
# SDK repro harness verbose HTTP logging
|
|
125
150
|
MR_MAGIC_SDK_REPRO_HTTP_DEBUG=0 # Set to 1 for verbose HTTP previews in the SDK repro harness script
|
|
151
|
+
|
|
152
|
+
# Override project root and .env file path resolution (rarely needed)
|
|
153
|
+
MR_MAGIC_ROOT=
|
|
154
|
+
MR_MAGIC_ENV_PATH=
|