slatebox-mcp 0.3.4 → 0.3.5
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 +6 -6
- package/generated/client.json +4565 -411
- package/generated/exec-tool.json +1482 -45
- package/generated/guest-client.js +1 -1
- package/generated/slatebox.d.ts +1217 -19
- package/package.json +1 -1
- package/src/cli.js +15 -1
- package/src/describe.js +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slatebox-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"mcpName": "com.slatebox/slatebox",
|
|
5
5
|
"description": "Slatebox is an open source visual intelligence platform where you can invite any AI via MCP to collaborate with you and your team.",
|
|
6
6
|
"keywords": [
|
package/src/cli.js
CHANGED
|
@@ -18,6 +18,11 @@ import { typedToolsEnabled } from "./typed-tools.js";
|
|
|
18
18
|
|
|
19
19
|
export const DEFAULT_HTTP_PORT = 3917;
|
|
20
20
|
|
|
21
|
+
/** What every tool answers when the server started without a token. */
|
|
22
|
+
function tokenRequired() {
|
|
23
|
+
return Object.assign(new Error("No Slatebox token: set SLATEBOX_API_TOKEN to a personal access token from your Slatebox and restart this server. The prompts work without one."), { code: "sign_in_required", status: 401 });
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
async function main() {
|
|
22
27
|
let values;
|
|
23
28
|
try {
|
|
@@ -33,9 +38,18 @@ async function main() {
|
|
|
33
38
|
throw new UsageError("--typed-tools (or SLATEBOX_MCP_TYPED_TOOLS) is on or off.");
|
|
34
39
|
const typedTools = typedToolsEnabled(typedOption);
|
|
35
40
|
const token = process.env.SLATEBOX_API_TOKEN;
|
|
36
|
-
if (!token) throw new UsageError("Set SLATEBOX_API_TOKEN to a personal access token.");
|
|
37
41
|
const baseUrl = apiOrigin(values["base-url"] || process.env.SLATEBOX_BASE_URL || DEFAULT_ORIGIN);
|
|
38
42
|
const generated = defaultGenerated();
|
|
43
|
+
if (!token) {
|
|
44
|
+
// No Slatebox yet: the prompts and the client docs still work;
|
|
45
|
+
// every tool answers that it needs a token. The HTTP server always needs one: it is the bearer.
|
|
46
|
+
if (values.http) throw new UsageError("Set SLATEBOX_API_TOKEN to a personal access token.");
|
|
47
|
+
if (values.port !== undefined || values.host !== undefined) throw new UsageError("--port and --host go with --http.");
|
|
48
|
+
process.stderr.write("SLATEBOX_API_TOKEN is not set: the prompts and the client docs work; the tools need a personal access token.\n");
|
|
49
|
+
const exec = async () => { throw tokenRequired(); };
|
|
50
|
+
await createSlateboxMcpServer({ exec, generated, typedTools }).connect(new StdioServerTransport());
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
39
53
|
const client = createClient({ baseUrl, token, generated });
|
|
40
54
|
const exec = createExec({ baseUrl, token, generated });
|
|
41
55
|
const instance = client.instance?.describe ? () => client.instance.describe({}) : undefined;
|
package/src/describe.js
CHANGED
|
@@ -19,6 +19,15 @@ function checkInput(input) {
|
|
|
19
19
|
throw new DescribeInputError("methods is a list of at most 12 method names.");
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// The start of a summary, what the describe index shows so the index of every method stays within the budget: its
|
|
23
|
+
// first sentence, and the next one too when the first is short (under 60 characters).
|
|
24
|
+
const SENTENCES = /[^]*?[.!?](?=\s+[A-Z("“]|$)/g;
|
|
25
|
+
export function firstSentence(text) {
|
|
26
|
+
const whole = String(text ?? "");
|
|
27
|
+
const [first = whole, second = ""] = whole.match(SENTENCES) ?? [];
|
|
28
|
+
return (first.length < 60 ? first + second : first).trim();
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
export function describeClient(manifest, input = {}, { instance } = {}) {
|
|
23
32
|
const { query, methods: names } = input || {};
|
|
24
33
|
let chosen = manifest.methods;
|
|
@@ -44,7 +53,8 @@ export function describeClient(manifest, input = {}, { instance } = {}) {
|
|
|
44
53
|
methods: chosen.map((method) => ({
|
|
45
54
|
name: method.name,
|
|
46
55
|
title: method.title,
|
|
47
|
-
|
|
56
|
+
// The index (no methods, no query) gives each method's first sentence; a query or methods give the whole summary.
|
|
57
|
+
summary: detailed ? method.summary : firstSentence(method.summary),
|
|
48
58
|
kind: method.kind,
|
|
49
59
|
flags: [
|
|
50
60
|
method.readOnly ? "read" : "write",
|