mcp-speechmatics-transcribe 0.1.9 → 0.1.11
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 +9 -1
- package/mcp.js +2 -1
- package/modules/discovery-cache.js +24 -8
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -152,8 +152,16 @@ Tool descriptions reflect the defaults captured during that refresh. Environment
|
|
|
152
152
|
changes create a different cache entry; edits inside an env file take effect on
|
|
153
153
|
the next refresh or after invalidation.
|
|
154
154
|
|
|
155
|
+
Local expiry is independent of discovery response hints: even `ttlMs: 0` does
|
|
156
|
+
not disable the local cache. The complete final tool catalog and its metadata
|
|
157
|
+
are preserved without rewriting `ttlMs`, `cacheScope`, `resultType`, or `_meta`.
|
|
158
|
+
Discovery carrying request/session identifiers is returned intact and skips
|
|
159
|
+
disk caching. JSON-RPC request IDs are always supplied by the current exchange.
|
|
160
|
+
|
|
155
161
|
Cache filenames hash the CLI command, arguments, working directory, and complete
|
|
156
|
-
effective environment. `CODEX_TOOL_CALL_ID`
|
|
162
|
+
effective environment. `CODEX_TOOL_CALL_ID`, `PATH`, and names starting with
|
|
163
|
+
`INIT_` or `NPM_` are excluded from the hash (the PATH and prefix checks are
|
|
164
|
+
case-insensitive); additional
|
|
157
165
|
names can be listed in `SPEECHMATICS_DISCOVERY_CACHE_KEY_EXCLUDE`. These exclusions
|
|
158
166
|
never remove variables from the CLI environment. Windows environment names are
|
|
159
167
|
case-insensitive. Exclude only transient values that do not affect discovery.
|
package/mcp.js
CHANGED
|
@@ -45,7 +45,8 @@ async function createServer(context) {
|
|
|
45
45
|
await discovery.invalidate();
|
|
46
46
|
await server.sendToolListChanged();
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
const { protocol, serverInfo, ...result } = manifest;
|
|
49
|
+
return result;
|
|
49
50
|
});
|
|
50
51
|
server.setRequestHandler("tools/call", async ({ params }, context) => {
|
|
51
52
|
try {
|
|
@@ -7,20 +7,35 @@ import { z } from "zod";
|
|
|
7
7
|
const object = z.record(z.string(), z.json());
|
|
8
8
|
const manifestSchema = z.object({
|
|
9
9
|
protocol: z.literal(1),
|
|
10
|
-
serverInfo: z.object({ name: z.string().min(1), version: z.string().min(1), title: z.string().optional(), description: z.string().optional() }).
|
|
10
|
+
serverInfo: z.object({ name: z.string().min(1), version: z.string().min(1), title: z.string().optional(), description: z.string().optional() }).passthrough(),
|
|
11
11
|
tools: z.array(z.object({
|
|
12
12
|
name: z.string().min(1), title: z.string().optional(), description: z.string().optional(),
|
|
13
13
|
inputSchema: object.refine((value) => value.type === "object"),
|
|
14
14
|
outputSchema: object.optional(),
|
|
15
|
-
annotations: z.object({ title: z.string().optional(), readOnlyHint: z.boolean().optional(), destructiveHint: z.boolean().optional(), idempotentHint: z.boolean().optional(), openWorldHint: z.boolean().optional() }).
|
|
16
|
-
}).
|
|
17
|
-
}).
|
|
15
|
+
annotations: z.object({ title: z.string().optional(), readOnlyHint: z.boolean().optional(), destructiveHint: z.boolean().optional(), idempotentHint: z.boolean().optional(), openWorldHint: z.boolean().optional() }).passthrough().optional(),
|
|
16
|
+
}).passthrough()).refine((tools) => new Set(tools.map((tool) => tool.name)).size === tools.length),
|
|
17
|
+
}).passthrough();
|
|
18
|
+
|
|
19
|
+
function validateManifest(value) {
|
|
20
|
+
z.json().parse(value);
|
|
21
|
+
manifestSchema.parse(value);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Request/session-bound discovery is returned intact but cannot be replayed.
|
|
26
|
+
function hasRequestState(value) {
|
|
27
|
+
if (!value || typeof value !== "object") return false;
|
|
28
|
+
return Object.entries(value).some(([name, child]) =>
|
|
29
|
+
/(?:^|\/)(?:sessionId|session_id|progressToken|requestId|requestState|inputRequests|relatedTask|related-task)$/i.test(name)
|
|
30
|
+
|| (name === "cacheScope" && child === "session")
|
|
31
|
+
|| hasRequestState(child));
|
|
32
|
+
}
|
|
18
33
|
|
|
19
34
|
export function discoveryKey(launch, platform = process.platform) {
|
|
20
35
|
const normalize = (key) => platform === "win32" ? key.toUpperCase() : key;
|
|
21
36
|
const excluded = new Set(["CODEX_TOOL_CALL_ID", ...(launch.env.SPEECHMATICS_DISCOVERY_CACHE_KEY_EXCLUDE ?? "").split(",").map((key) => key.trim()).filter(Boolean)].map(normalize));
|
|
22
37
|
const env = Object.entries(launch.env).map(([key, value]) => [normalize(key), value])
|
|
23
|
-
.filter(([key]) => !excluded.has(key)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
38
|
+
.filter(([key]) => !excluded.has(key) && !/^(?:CODEX_TOOL_CALL_ID$|PATH$|INIT_|NPM_)/i.test(key)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
24
39
|
return createHash("sha256").update(JSON.stringify({ version: 1, command: launch.command, args: launch.args, cwd: launch.cwd, shell: launch.shell, env })).digest("hex");
|
|
25
40
|
}
|
|
26
41
|
|
|
@@ -40,19 +55,20 @@ export function createDiscoveryCache(launch, load, { directory = join(tmpdir(),
|
|
|
40
55
|
const entry = JSON.parse(bytes);
|
|
41
56
|
if (entry.version !== 1 || entry.key !== key || !Number.isFinite(entry.createdAt) || !Number.isFinite(entry.expiresAt)
|
|
42
57
|
|| entry.createdAt > now() || entry.expiresAt <= now() || entry.expiresAt - entry.createdAt > ttl) throw new Error("Expired cache.");
|
|
43
|
-
|
|
58
|
+
if (hasRequestState(entry.manifest)) throw new Error("Request-bound discovery.");
|
|
59
|
+
return validateManifest(entry.manifest);
|
|
44
60
|
} catch { /* Invalid or unavailable cache entries are misses. */ }
|
|
45
61
|
}
|
|
46
62
|
if (pending) return pending;
|
|
47
63
|
const revision = generation;
|
|
48
64
|
pending = (async () => {
|
|
49
|
-
const manifest =
|
|
65
|
+
const manifest = validateManifest(await load());
|
|
50
66
|
const serialized = JSON.stringify(manifest);
|
|
51
67
|
const privateValues = Object.entries(launch.env).filter(([name]) => /token|secret|password|session|CODEX_TOOL_CALL_ID/i.test(name))
|
|
52
68
|
.flatMap(([name, value]) => /SPEECHMATICS_TOKENS/i.test(name)
|
|
53
69
|
? [value, ...value.split(",").flatMap((entry) => entry.includes(":") ? [entry.slice(entry.indexOf(":") + 1)] : [entry])]
|
|
54
70
|
: [value]).filter((value) => value.length >= 8);
|
|
55
|
-
if (ttl && revision === generation && !privateValues.some((value) => serialized.includes(value))) {
|
|
71
|
+
if (ttl && revision === generation && !hasRequestState(manifest) && !privateValues.some((value) => serialized.includes(value))) {
|
|
56
72
|
const temporary = file + "." + randomUUID() + ".tmp";
|
|
57
73
|
try {
|
|
58
74
|
await mkdir(directory, { recursive: true, mode: 0o700 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-speechmatics-transcribe",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Transcribe audio and video files with Speechmatics through a CLI and MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,5 +50,8 @@
|
|
|
50
50
|
"dotenv": "^18.0.10",
|
|
51
51
|
"proper-lockfile": "^4.1.2",
|
|
52
52
|
"zod": "^4.6.7"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@modelcontextprotocol/client": "^2.4.0"
|
|
53
56
|
}
|
|
54
57
|
}
|