@tokenlabai/mcp-server 0.2.2 → 0.4.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 +80 -22
- package/contract/mcp-overlay.json +212 -0
- package/contract/openapi.json +12782 -0
- package/generated/tools.json +7230 -0
- package/llms-install.md +60 -0
- package/package.json +18 -3
- package/scripts/generate-contract.mjs +276 -0
- package/scripts/sync-contract.mjs +27 -0
- package/src/index.js +227 -273
- package/.github/workflows/publish-npm.yml +0 -29
- package/server.json +0 -36
- package/test/mcp-tools.test.js +0 -78
package/test/mcp-tools.test.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import { stat } from "node:fs/promises";
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
|
|
6
|
-
function startServer() {
|
|
7
|
-
const child = spawn(process.execPath, ["src/index.js"], {
|
|
8
|
-
cwd: process.cwd(),
|
|
9
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
10
|
-
});
|
|
11
|
-
let nextId = 1;
|
|
12
|
-
let buffer = "";
|
|
13
|
-
const pending = new Map();
|
|
14
|
-
|
|
15
|
-
child.stdout.setEncoding("utf8");
|
|
16
|
-
child.stdout.on("data", (chunk) => {
|
|
17
|
-
buffer += chunk;
|
|
18
|
-
const lines = buffer.split("\n");
|
|
19
|
-
buffer = lines.pop();
|
|
20
|
-
|
|
21
|
-
for (const line of lines) {
|
|
22
|
-
if (!line.trim()) continue;
|
|
23
|
-
const message = JSON.parse(line);
|
|
24
|
-
const resolve = pending.get(message.id);
|
|
25
|
-
if (resolve) {
|
|
26
|
-
pending.delete(message.id);
|
|
27
|
-
resolve(message);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
function request(method, params) {
|
|
33
|
-
const id = nextId++;
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
const timeout = setTimeout(() => {
|
|
36
|
-
pending.delete(id);
|
|
37
|
-
reject(new Error(`Timed out waiting for ${method}`));
|
|
38
|
-
}, 5_000);
|
|
39
|
-
pending.set(id, (message) => {
|
|
40
|
-
clearTimeout(timeout);
|
|
41
|
-
resolve(message);
|
|
42
|
-
});
|
|
43
|
-
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}\n`);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function notify(method, params) {
|
|
48
|
-
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method, params })}\n`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return { child, notify, request };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
test("advertises an OpenAI-compatible Chat Completions tool", async (t) => {
|
|
55
|
-
const server = startServer();
|
|
56
|
-
t.after(() => server.child.kill());
|
|
57
|
-
|
|
58
|
-
const initialized = await server.request("initialize", {
|
|
59
|
-
protocolVersion: "2025-11-25",
|
|
60
|
-
capabilities: {},
|
|
61
|
-
clientInfo: { name: "tokenlab-mcp-test", version: "0.0.0" }
|
|
62
|
-
});
|
|
63
|
-
assert.equal(initialized.error, undefined);
|
|
64
|
-
|
|
65
|
-
server.notify("notifications/initialized");
|
|
66
|
-
const listed = await server.request("tools/list", {});
|
|
67
|
-
const tool = listed.result.tools.find(({ name }) => name === "create_chat_completion");
|
|
68
|
-
|
|
69
|
-
assert.ok(tool);
|
|
70
|
-
assert.equal(tool.inputSchema.properties.model.type, "string");
|
|
71
|
-
assert.equal(tool.inputSchema.properties.messages.type, "array");
|
|
72
|
-
assert.equal(tool.inputSchema.properties.stream, undefined);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test("ships an executable npm binary", async () => {
|
|
76
|
-
const { mode } = await stat(new URL("../src/index.js", import.meta.url));
|
|
77
|
-
assert.notEqual(mode & 0o111, 0);
|
|
78
|
-
});
|