boat-mcp 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +105 -2
- package/dist/boat-api.js +112 -0
- package/dist/cli.js +45 -0
- package/dist/config.js +82 -0
- package/dist/generated/operations.js +5708 -0
- package/dist/http/handler.js +48 -0
- package/dist/http/serve.js +31 -0
- package/dist/http/token-verifier.js +63 -0
- package/dist/instructions.js +9 -0
- package/dist/operation.js +1 -0
- package/dist/server.js +8 -0
- package/dist/tools/api-tools.js +37 -0
- package/dist/tools/catalog.js +228 -0
- package/dist/tools/result.js +49 -0
- package/package.json +57 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amit Ray
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# boat-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for [boat.dev](https://boat.dev). Your AI client can create sandboxes, run commands, edit files, open desktops, and manage snapshots, using every boat API operation as a tool.
|
|
4
|
+
|
|
5
|
+
- **Local (stdio)** for Claude Code, Codex, Cursor, and Claude Desktop, with a boat API key.
|
|
6
|
+
- **Hosted (HTTP)** for Claude, ChatGPT, and Grok connectors. Users sign in with boat; the server stores no tokens.
|
|
7
|
+
|
|
8
|
+
## Quick start
|
|
9
|
+
|
|
10
|
+
Create an API key with the actions you want to allow:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
boat api-key create boat-mcp --ttl 90d \
|
|
14
|
+
--actions account.read,sandbox.read,sandbox.create,sandbox.update,sandbox.stop,sandbox.resume,sandbox.fork,sandbox.delete-own,exec,file.read,file.write,agent.prompt,desktop,host,snapshot.read,snapshot.write
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Claude Code:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
claude mcp add boat --env BOAT_API_KEY=boat_... -- npx -y boat-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Codex (`~/.codex/config.toml`):
|
|
24
|
+
|
|
25
|
+
```toml
|
|
26
|
+
[mcp_servers.boat]
|
|
27
|
+
command = "npx"
|
|
28
|
+
args = ["-y", "boat-mcp"]
|
|
29
|
+
env = { BOAT_API_KEY = "boat_..." }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Cursor, Claude Desktop, and other JSON configs:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"boat": {
|
|
38
|
+
"command": "npx",
|
|
39
|
+
"args": ["-y", "boat-mcp"],
|
|
40
|
+
"env": { "BOAT_API_KEY": "boat_..." }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Toolsets
|
|
47
|
+
|
|
48
|
+
The six default toolsets load 70 tools. Set `BOAT_MCP_TOOLSETS` to a comma list, or `all` for all 119.
|
|
49
|
+
|
|
50
|
+
| Toolset | Tools | Default |
|
|
51
|
+
| -------------- | ----: | :-----: |
|
|
52
|
+
| `sandboxes` | 17 | yes |
|
|
53
|
+
| `commands` | 7 | yes |
|
|
54
|
+
| `files` | 13 | yes |
|
|
55
|
+
| `agents` | 6 | yes |
|
|
56
|
+
| `snapshots` | 14 | yes |
|
|
57
|
+
| `account` | 13 | yes |
|
|
58
|
+
| `environments` | 11 | |
|
|
59
|
+
| `network` | 2 | |
|
|
60
|
+
| `credentials` | 17 | |
|
|
61
|
+
| `ci` | 5 | |
|
|
62
|
+
| `webhooks` | 6 | |
|
|
63
|
+
| `telemetry` | 3 | |
|
|
64
|
+
| `api_keys` | 5 | |
|
|
65
|
+
|
|
66
|
+
## Hosting
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
docker build -t boat-mcp .
|
|
70
|
+
docker run -p 3000:3000 -e BOAT_MCP_PUBLIC_URL=https://mcp.example.com/mcp boat-mcp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The server is an OAuth resource server. Clients discover boat.dev as the authorization server, sign the user in there, and send the boat token with each request.
|
|
74
|
+
|
|
75
|
+
| Variable | Default | |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `BOAT_MCP_PUBLIC_URL` | required | Public URL of the MCP endpoint |
|
|
78
|
+
| `PORT` | `3000` | |
|
|
79
|
+
| `BOAT_MCP_TOOLSETS` | defaults | |
|
|
80
|
+
| `BOAT_MCP_SCOPES` | everyday sandbox set | Scopes clients request at sign-in |
|
|
81
|
+
| `BOAT_OAUTH_ISSUER` | `https://boat.dev` | |
|
|
82
|
+
| `BOAT_API_URL` | `https://boat.dev/api/v1` | |
|
|
83
|
+
| `BOAT_MCP_TOKEN_CACHE_SECONDS` | `60` | How long a checked token is trusted |
|
|
84
|
+
|
|
85
|
+
boat doesn't support client self-registration yet, so each client needs its own boat OAuth app. For Claude:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
boat app create "Claude" --redirect-uri https://claude.ai/api/mcp/auth_callback
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Then enter the client ID and secret in Claude's custom connector settings.
|
|
92
|
+
|
|
93
|
+
Hosting it means users trust you with their boat tokens. For personal use, run it locally.
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
mise exec -- pnpm install
|
|
99
|
+
mise exec -- pnpm check # lint, types, tests
|
|
100
|
+
mise exec -- pnpm e2e # real sandbox lifecycle; needs BOAT_API_KEY in .env
|
|
101
|
+
mise exec -- pnpm sync-openapi --fetch # pull boat's latest API and regenerate
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
package/dist/boat-api.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const CONFIRM_DELETE_HEADER = "X-Ascii-Confirm-Delete";
|
|
2
|
+
export function createBoatApi(options) {
|
|
3
|
+
const send = options.fetch ?? fetch;
|
|
4
|
+
return {
|
|
5
|
+
async call(operation, input) {
|
|
6
|
+
const response = await send(buildUrl(options.baseUrl, operation, input), {
|
|
7
|
+
method: operation.method,
|
|
8
|
+
headers: buildHeaders(options, operation.request, input),
|
|
9
|
+
body: buildBody(operation.request, input),
|
|
10
|
+
});
|
|
11
|
+
return response.ok
|
|
12
|
+
? { ok: true, status: response.status, body: await readBody(response) }
|
|
13
|
+
: {
|
|
14
|
+
ok: false,
|
|
15
|
+
status: response.status,
|
|
16
|
+
error: await readError(response),
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function buildUrl(baseUrl, operation, input) {
|
|
22
|
+
const path = operation.path.replaceAll(/\{(?<name>\w+)\}/gu, (_, name) => encodeURIComponent(String(input[name])));
|
|
23
|
+
const url = new URL(`${baseUrl}${path}`);
|
|
24
|
+
for (const name of operation.request.query) {
|
|
25
|
+
const value = input[name];
|
|
26
|
+
if (value !== undefined && value !== null) {
|
|
27
|
+
url.searchParams.set(name, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return url.toString();
|
|
31
|
+
}
|
|
32
|
+
function buildHeaders(options, request, input) {
|
|
33
|
+
const headers = {
|
|
34
|
+
authorization: `Bearer ${options.token}`,
|
|
35
|
+
accept: "application/json",
|
|
36
|
+
"user-agent": options.userAgent,
|
|
37
|
+
};
|
|
38
|
+
if (request.body !== "none") {
|
|
39
|
+
headers["content-type"] = "application/json";
|
|
40
|
+
}
|
|
41
|
+
if (request.confirmDeleteWith) {
|
|
42
|
+
// The tool call is the confirmation: clients ask the user first because the tool is marked destructive.
|
|
43
|
+
headers[CONFIRM_DELETE_HEADER] = String(input[request.confirmDeleteWith]);
|
|
44
|
+
}
|
|
45
|
+
return headers;
|
|
46
|
+
}
|
|
47
|
+
function buildBody(request, input) {
|
|
48
|
+
if (request.body === "none") {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
if (request.body === "body") {
|
|
52
|
+
return JSON.stringify(input.body ?? {});
|
|
53
|
+
}
|
|
54
|
+
const routed = new Set([...request.path, ...request.query]);
|
|
55
|
+
return JSON.stringify(Object.fromEntries(Object.entries(input).filter(([key]) => !routed.has(key))));
|
|
56
|
+
}
|
|
57
|
+
async function readBody(response) {
|
|
58
|
+
const type = mediaType(response);
|
|
59
|
+
if (response.status === 204 ||
|
|
60
|
+
response.headers.get("content-length") === "0") {
|
|
61
|
+
return { kind: "empty" };
|
|
62
|
+
}
|
|
63
|
+
if (type === "application/json") {
|
|
64
|
+
return { kind: "json", value: await response.json() };
|
|
65
|
+
}
|
|
66
|
+
if (type === "application/x-ndjson") {
|
|
67
|
+
const text = await response.text();
|
|
68
|
+
const lines = text.split("\n").filter(Boolean);
|
|
69
|
+
return {
|
|
70
|
+
kind: "json",
|
|
71
|
+
value: lines.map((line) => JSON.parse(line)),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (type.startsWith("text/")) {
|
|
75
|
+
return { kind: "text", value: await response.text() };
|
|
76
|
+
}
|
|
77
|
+
const buffer = await response.arrayBuffer();
|
|
78
|
+
const bytes = Buffer.from(buffer);
|
|
79
|
+
return bytes.length === 0
|
|
80
|
+
? { kind: "empty" }
|
|
81
|
+
: {
|
|
82
|
+
kind: "binary",
|
|
83
|
+
base64: bytes.toString("base64"),
|
|
84
|
+
mimeType: type || "application/octet-stream",
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async function readError(response) {
|
|
88
|
+
const text = await response.text();
|
|
89
|
+
try {
|
|
90
|
+
const envelope = JSON.parse(text);
|
|
91
|
+
const detail = envelope.error ?? envelope;
|
|
92
|
+
return {
|
|
93
|
+
code: detail.code ?? `http_${response.status}`,
|
|
94
|
+
message: detail.message ?? response.statusText,
|
|
95
|
+
...(typeof detail.retryable === "boolean"
|
|
96
|
+
? { retryable: detail.retryable }
|
|
97
|
+
: {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return {
|
|
102
|
+
code: `http_${response.status}`,
|
|
103
|
+
message: text.slice(0, 500) || response.statusText,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function mediaType(response) {
|
|
108
|
+
return ((response.headers.get("content-type") ?? "")
|
|
109
|
+
.split(";")[0]
|
|
110
|
+
?.trim()
|
|
111
|
+
.toLowerCase() ?? "");
|
|
112
|
+
}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
4
|
+
import { createBoatApi } from "./boat-api.js";
|
|
5
|
+
import { loadHttpConfig, loadStdioConfig } from "./config.js";
|
|
6
|
+
import { serveHttp } from "./http/serve.js";
|
|
7
|
+
import { createServer } from "./server.js";
|
|
8
|
+
import { selectApiTools } from "./tools/api-tools.js";
|
|
9
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
10
|
+
const USAGE = `Usage:
|
|
11
|
+
boat-mcp Serve over stdio. Needs BOAT_API_KEY.
|
|
12
|
+
boat-mcp serve Serve Streamable HTTP as an OAuth resource server. Needs BOAT_MCP_PUBLIC_URL.`;
|
|
13
|
+
try {
|
|
14
|
+
await run(process.argv[2]);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error(error instanceof Error ? error.message : error);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
async function run(command) {
|
|
21
|
+
switch (command) {
|
|
22
|
+
case undefined: {
|
|
23
|
+
await serveStdio();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
case "serve": {
|
|
27
|
+
await serveHttp(loadHttpConfig(process.env), version);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
default: {
|
|
31
|
+
console.error(USAGE);
|
|
32
|
+
process.exit(command === "--help" || command === "-h" ? 0 : 1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function serveStdio() {
|
|
37
|
+
const config = loadStdioConfig(process.env);
|
|
38
|
+
const api = createBoatApi({
|
|
39
|
+
baseUrl: config.apiUrl,
|
|
40
|
+
token: config.apiKey,
|
|
41
|
+
userAgent: `boat-mcp/${version}`,
|
|
42
|
+
});
|
|
43
|
+
const tools = selectApiTools(config.toolsets);
|
|
44
|
+
await createServer({ api, tools, version }).connect(new StdioServerTransport());
|
|
45
|
+
}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { DEFAULT_TOOLSETS, TOOLSETS } from "./tools/catalog.js";
|
|
2
|
+
const DEFAULTS = {
|
|
3
|
+
apiUrl: "https://boat.dev/api/v1",
|
|
4
|
+
issuer: "https://boat.dev",
|
|
5
|
+
// Everyday sandbox work; deletes are limited to sandboxes the client created.
|
|
6
|
+
scopes: [
|
|
7
|
+
"account.read",
|
|
8
|
+
"sandbox.read",
|
|
9
|
+
"sandbox.create",
|
|
10
|
+
"sandbox.update",
|
|
11
|
+
"sandbox.stop",
|
|
12
|
+
"sandbox.resume",
|
|
13
|
+
"sandbox.fork",
|
|
14
|
+
"sandbox.delete-own",
|
|
15
|
+
"agent.prompt",
|
|
16
|
+
"exec",
|
|
17
|
+
"file.read",
|
|
18
|
+
"file.write",
|
|
19
|
+
"desktop",
|
|
20
|
+
"host",
|
|
21
|
+
"snapshot.read",
|
|
22
|
+
"snapshot.write",
|
|
23
|
+
],
|
|
24
|
+
host: "0.0.0.0",
|
|
25
|
+
port: 3000,
|
|
26
|
+
tokenCacheSeconds: 60,
|
|
27
|
+
};
|
|
28
|
+
export function loadStdioConfig(env) {
|
|
29
|
+
return {
|
|
30
|
+
apiUrl: env.BOAT_API_URL ?? DEFAULTS.apiUrl,
|
|
31
|
+
apiKey: required(env, "BOAT_API_KEY", "a boat API key (boat api-key create, or the dashboard)"),
|
|
32
|
+
toolsets: parseToolsets(env.BOAT_MCP_TOOLSETS),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function loadHttpConfig(env) {
|
|
36
|
+
return {
|
|
37
|
+
apiUrl: env.BOAT_API_URL ?? DEFAULTS.apiUrl,
|
|
38
|
+
toolsets: parseToolsets(env.BOAT_MCP_TOOLSETS),
|
|
39
|
+
resourceUrl: new URL(required(env, "BOAT_MCP_PUBLIC_URL", "the public URL of the MCP endpoint, such as https://mcp.example.com/mcp")),
|
|
40
|
+
issuer: env.BOAT_OAUTH_ISSUER ?? DEFAULTS.issuer,
|
|
41
|
+
scopes: env.BOAT_MCP_SCOPES?.split(/[\s,]+/u).filter(Boolean) ?? DEFAULTS.scopes,
|
|
42
|
+
host: env.HOST ?? DEFAULTS.host,
|
|
43
|
+
port: positiveInteger(env, "PORT", DEFAULTS.port),
|
|
44
|
+
tokenCacheMs: positiveInteger(env, "BOAT_MCP_TOKEN_CACHE_SECONDS", DEFAULTS.tokenCacheSeconds) * 1000,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** BOAT_MCP_TOOLSETS: a comma list of toolset names, or "all". Empty means the defaults. */
|
|
48
|
+
function parseToolsets(value) {
|
|
49
|
+
const names = (value ?? "")
|
|
50
|
+
.split(",")
|
|
51
|
+
.map((name) => name.trim())
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
if (names.length === 0) {
|
|
54
|
+
return DEFAULT_TOOLSETS;
|
|
55
|
+
}
|
|
56
|
+
if (names.includes("all")) {
|
|
57
|
+
return TOOLSETS;
|
|
58
|
+
}
|
|
59
|
+
const unknown = names.filter((name) => !TOOLSETS.includes(name));
|
|
60
|
+
if (unknown.length > 0) {
|
|
61
|
+
throw new Error(`Unknown toolset ${unknown.join(", ")} in BOAT_MCP_TOOLSETS. Choose from: all, ${TOOLSETS.join(", ")}.`);
|
|
62
|
+
}
|
|
63
|
+
return names;
|
|
64
|
+
}
|
|
65
|
+
function required(env, name, what) {
|
|
66
|
+
const value = env[name];
|
|
67
|
+
if (!value) {
|
|
68
|
+
throw new Error(`Set ${name} to ${what}.`);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function positiveInteger(env, name, fallback) {
|
|
73
|
+
const raw = env[name];
|
|
74
|
+
if (raw === undefined || raw === "") {
|
|
75
|
+
return fallback;
|
|
76
|
+
}
|
|
77
|
+
const value = Number(raw);
|
|
78
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
79
|
+
throw new Error(`${name} must be a positive integer, got "${raw}".`);
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|