slatebox-mcp 0.4.0 → 0.4.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/README.md +7 -7
- package/generated/client.json +58 -58
- package/generated/exec-tool.json +71 -53
- package/generated/slatebox.d.ts +32 -6
- package/package.json +5 -2
- package/src/cli.js +5 -2
- package/src/client/index.js +6 -1
- package/src/mcp.js +21 -0
- package/src/server.js +1 -1
package/src/client/index.js
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
// action, named by its action id (slatebox.slates.get(input)). Types: generated/slatebox.d.ts.
|
|
3
3
|
// Use it in your own code (an AI SDK tool, a script). Outside an exec run it sends no
|
|
4
4
|
// Slatebox-Exec-* headers, so each call is an ordinary API call.
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
5
6
|
import { defaultGenerated } from "../generated.js";
|
|
6
7
|
|
|
8
|
+
// Every call names this package (the server counts calls per client, never their content).
|
|
9
|
+
const { version } = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
10
|
+
export const USER_AGENT = `slatebox-mcp/${version}`;
|
|
11
|
+
|
|
7
12
|
export class SlateboxError extends Error {
|
|
8
13
|
constructor({ code = "error", status = 0, message, details, retryAfter } = {}) {
|
|
9
14
|
super(message || `Slatebox returned HTTP ${status}.`);
|
|
@@ -85,7 +90,7 @@ function retryAfterSeconds(payload, response) {
|
|
|
85
90
|
*/
|
|
86
91
|
export async function sendCall({ baseUrl, token, fetchImpl = fetch, method, input, headers = {} }) {
|
|
87
92
|
const { url, init } = buildRequest(baseUrl, method, input);
|
|
88
|
-
init.headers = { ...init.headers, authorization: `Bearer ${token}`, ...headers };
|
|
93
|
+
init.headers = { ...init.headers, "user-agent": USER_AGENT, authorization: `Bearer ${token}`, ...headers };
|
|
89
94
|
let response;
|
|
90
95
|
try {
|
|
91
96
|
response = await fetchImpl(url, init);
|
package/src/mcp.js
CHANGED
|
@@ -17,6 +17,27 @@ import { typedToolsEnabled } from "./typed-tools.js";
|
|
|
17
17
|
|
|
18
18
|
export const DEFAULT_HTTP_PORT = 3917;
|
|
19
19
|
|
|
20
|
+
/** `slatebox-mcp --help` (and `slatebox mcp --help`, with that name). */
|
|
21
|
+
export function mcpHelp(name = "slatebox-mcp") {
|
|
22
|
+
return `Usage: ${name} [--base-url ORIGIN] [--typed-tools on|off] [--http [--port N]]
|
|
23
|
+
${name === "slatebox-mcp" ? "slatebox-mcp exec | describe ... (the same as slatebox exec | describe; see slatebox-mcp exec --help)" : "slatebox exec | describe ... (see slatebox exec --help)"}
|
|
24
|
+
|
|
25
|
+
The Slatebox MCP server: exec and describe, one typed tool per client method, prompts and resources.
|
|
26
|
+
|
|
27
|
+
(no option) stdio, for agent hosts that start a command
|
|
28
|
+
--http [--port N] loopback Streamable HTTP at http://127.0.0.1:N/mcp (default port ${DEFAULT_HTTP_PORT});
|
|
29
|
+
needs SLATEBOX_API_TOKEN, sent as the bearer token
|
|
30
|
+
--typed-tools on|off list the typed tools (default on; or SLATEBOX_MCP_TYPED_TOOLS);
|
|
31
|
+
exec and describe are always listed
|
|
32
|
+
--base-url ORIGIN your Slatebox (or SLATEBOX_BASE_URL; default ${DEFAULT_ORIGIN})
|
|
33
|
+
--help this text
|
|
34
|
+
|
|
35
|
+
SLATEBOX_API_TOKEN is your personal access token (Profile > Developer in your Slatebox). Without
|
|
36
|
+
one the prompts and the client docs work and every tool says it needs a token. A script runs in
|
|
37
|
+
this process with your rights: there is no sandbox.
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
|
|
20
41
|
/** What every tool answers when the server started without a token. */
|
|
21
42
|
function tokenRequired() {
|
|
22
43
|
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 });
|
package/src/server.js
CHANGED
|
@@ -58,7 +58,7 @@ export function createSlateboxMcpServer({ exec, generated = defaultGenerated(),
|
|
|
58
58
|
const spec = generated.tools;
|
|
59
59
|
const instructions = typedTools ? spec.instructions : spec.instructionsExecOnly ?? spec.instructions;
|
|
60
60
|
const server = new Server(
|
|
61
|
-
{ name: "slatebox", version },
|
|
61
|
+
{ name: "slatebox", ...(spec.server ?? {}), version },
|
|
62
62
|
{ capabilities: { tools: {}, prompts: {}, resources: {} }, ...(instructions ? { instructions } : {}) },
|
|
63
63
|
);
|
|
64
64
|
const tools = toolDefinitions(generated, { typed: typedTools });
|