plugmcp 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 +232 -2
- package/dist/agent.d.ts +20 -0
- package/dist/agent.js +35 -0
- package/dist/build.d.ts +13 -0
- package/dist/build.js +83 -0
- package/dist/cli/cloud.d.ts +20 -0
- package/dist/cli/cloud.js +56 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +326 -0
- package/dist/dev/api.d.ts +37 -0
- package/dist/dev/api.js +788 -0
- package/dist/dev/chat.d.ts +63 -0
- package/dist/dev/chat.js +159 -0
- package/dist/dev/dev.d.ts +22 -0
- package/dist/dev/dev.js +188 -0
- package/dist/dev/edit.d.ts +22 -0
- package/dist/dev/edit.js +147 -0
- package/dist/dev/generate.d.ts +21 -0
- package/dist/dev/generate.js +97 -0
- package/dist/dev/keys.d.ts +61 -0
- package/dist/dev/keys.js +55 -0
- package/dist/dev/project.d.ts +26 -0
- package/dist/dev/project.js +68 -0
- package/dist/dev/store.d.ts +61 -0
- package/dist/dev/store.js +113 -0
- package/dist/dev/views.d.ts +9 -0
- package/dist/dev/views.js +54 -0
- package/dist/http.d.ts +33 -0
- package/dist/http.js +79 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +118 -0
- package/dist/install.d.ts +13 -0
- package/dist/install.js +54 -0
- package/dist/landing.d.ts +3 -0
- package/dist/landing.js +62 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.js +5 -0
- package/dist/view/index.d.ts +34 -0
- package/dist/view/index.js +90 -0
- package/package.json +114 -4
- package/studio-dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/studio-dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/studio-dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/studio-dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/studio-dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/studio-dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/studio-dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/studio-dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/studio-dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/studio-dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/studio-dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/studio-dist/assets/index-BSR7LH_V.css +1 -0
- package/studio-dist/assets/index-D_yIYje_.js +137 -0
- package/studio-dist/index.html +15 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { createInterface } from "node:readline/promises";
|
|
5
|
+
import { slugify } from "../index.js";
|
|
6
|
+
import { DIRECTORY_URL, directoryPage, readmeBadge } from "../install.js";
|
|
7
|
+
import { ACCOUNT_MCP_URL, SUBMIT_URL, accountClient, canWrapUrl, readAccountKey, saveAccountKey, submitListing } from "./cloud.js";
|
|
8
|
+
const tty = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
9
|
+
const paint = (code) => (text) => (tty ? `\u001b[${code}m${text}\u001b[0m` : text);
|
|
10
|
+
const dim = paint(2);
|
|
11
|
+
const bold = paint(1);
|
|
12
|
+
const blue = paint(36);
|
|
13
|
+
const green = paint(32);
|
|
14
|
+
const red = paint(31);
|
|
15
|
+
function parse(argv) {
|
|
16
|
+
const [command = "help", ...rest] = argv;
|
|
17
|
+
const positional = [];
|
|
18
|
+
const flags = {};
|
|
19
|
+
for (let i = 0; i < rest.length; i++) {
|
|
20
|
+
const arg = rest[i];
|
|
21
|
+
if (!arg.startsWith("--")) {
|
|
22
|
+
positional.push(arg);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const [key, inline] = arg.slice(2).split("=", 2);
|
|
26
|
+
const next = rest[i + 1];
|
|
27
|
+
if (inline !== undefined)
|
|
28
|
+
flags[key] = inline;
|
|
29
|
+
else if (next !== undefined && !next.startsWith("--")) {
|
|
30
|
+
flags[key] = next;
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
flags[key] = true;
|
|
35
|
+
}
|
|
36
|
+
return { command, positional, flags };
|
|
37
|
+
}
|
|
38
|
+
const text = (value) => (typeof value === "string" ? value : undefined);
|
|
39
|
+
const HELP = `
|
|
40
|
+
${bold("plugmcp")} Build MCP servers and MCP Apps. https://plugmcp.ai
|
|
41
|
+
|
|
42
|
+
${bold("Build")}
|
|
43
|
+
plugmcp dev Run the server and open the Studio. No account needed.
|
|
44
|
+
plugmcp build Bundle the server and its views into dist/.
|
|
45
|
+
plugmcp start Run the build over HTTP. Add --stdio for stdio.
|
|
46
|
+
plugmcp test Run the tests saved in the Studio. Exits with 1 if one fails.
|
|
47
|
+
|
|
48
|
+
${bold("Directory")}
|
|
49
|
+
plugmcp search <words> Search 70,000+ MCP servers on plugmcp.ai.
|
|
50
|
+
plugmcp add <slug> Add a directory server to this project's Studio chat.
|
|
51
|
+
|
|
52
|
+
${bold("Ship")}
|
|
53
|
+
plugmcp list Give your server a page in the PlugMCP directory.
|
|
54
|
+
plugmcp login Save a plugmcp.ai account key on this machine.
|
|
55
|
+
plugmcp deploy --url <url> Put a server you already host behind plugmcp.ai.
|
|
56
|
+
|
|
57
|
+
${bold("Options")}
|
|
58
|
+
--port <n> Port for dev and start (default 3333)
|
|
59
|
+
--entry <file> Server file (default server.ts)
|
|
60
|
+
--dry-run For list and deploy: print what would be sent, send nothing
|
|
61
|
+
`;
|
|
62
|
+
function readPackage(root) {
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function ask(question) {
|
|
71
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
72
|
+
try {
|
|
73
|
+
return (await rl.question(question)).trim();
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
rl.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function main() {
|
|
80
|
+
const { command, positional, flags } = parse(process.argv.slice(2));
|
|
81
|
+
const root = resolve(text(flags.root) ?? process.cwd());
|
|
82
|
+
const port = flags.port ? Number(flags.port) : undefined;
|
|
83
|
+
const entry = text(flags.entry);
|
|
84
|
+
switch (command) {
|
|
85
|
+
case "dev": {
|
|
86
|
+
const { startDev } = await import("../dev/dev.js");
|
|
87
|
+
const dev = await startDev({ root, entry, port, studio: flags["no-studio"] !== true });
|
|
88
|
+
console.log(`
|
|
89
|
+
${bold("PlugMCP")} ${dim(`ready in ${dev.readyMs} ms`)}
|
|
90
|
+
|
|
91
|
+
${dim("Studio")} ${blue(`http://localhost:${dev.port}`)}
|
|
92
|
+
${dev.servers.map((server) => ` ${dim("MCP")} ${blue(server.mcpUrl)}${dev.servers.length > 1 ? dim(` ${server.id}`) : ""}`).join("\n")}
|
|
93
|
+
|
|
94
|
+
${dim("Edit server.ts or a file in views/ and it reloads. Ctrl+C to stop.")}
|
|
95
|
+
`);
|
|
96
|
+
if (flags.open === true) {
|
|
97
|
+
const { exec } = await import("node:child_process");
|
|
98
|
+
const opener = process.platform === "win32" ? "start \"\"" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
99
|
+
exec(`${opener} http://localhost:${dev.port}`);
|
|
100
|
+
}
|
|
101
|
+
const stop = () => void dev.close().finally(() => process.exit(0));
|
|
102
|
+
process.on("SIGINT", stop);
|
|
103
|
+
process.on("SIGTERM", stop);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
case "test": {
|
|
107
|
+
const { startDev } = await import("../dev/dev.js");
|
|
108
|
+
const dev = await startDev({ root, entry, port: port ?? 4733, studio: false });
|
|
109
|
+
let failed = 0;
|
|
110
|
+
let total = 0;
|
|
111
|
+
try {
|
|
112
|
+
for (const server of dev.servers) {
|
|
113
|
+
const response = await fetch(`http://127.0.0.1:${dev.port}/__studio/api/tests/run?mcp=${encodeURIComponent(server.id)}`, {
|
|
114
|
+
method: "POST",
|
|
115
|
+
headers: { "content-type": "application/json" },
|
|
116
|
+
body: "{}",
|
|
117
|
+
});
|
|
118
|
+
const { results = [], error } = (await response.json());
|
|
119
|
+
if (error)
|
|
120
|
+
throw new Error(error);
|
|
121
|
+
if (results.length && dev.servers.length > 1)
|
|
122
|
+
console.log(`\n ${bold(server.id)}`);
|
|
123
|
+
for (const result of results) {
|
|
124
|
+
total += 1;
|
|
125
|
+
if (!result.ok)
|
|
126
|
+
failed += 1;
|
|
127
|
+
console.log(` ${result.ok ? green("pass") : red("fail")} ${result.tool} ${dim(result.name)} ${dim(`${result.ms} ms`)}${result.ok ? "" : `\n ${result.reason}`}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
await dev.close();
|
|
133
|
+
}
|
|
134
|
+
if (total === 0)
|
|
135
|
+
console.log(` No tests yet. Run a tool in the Studio and press "Save as test".`);
|
|
136
|
+
else
|
|
137
|
+
console.log(`\n ${failed ? red(`${failed} of ${total} failed`) : green(`${total} passed`)}`);
|
|
138
|
+
process.exit(failed ? 1 : 0);
|
|
139
|
+
}
|
|
140
|
+
case "build": {
|
|
141
|
+
const { buildProject } = await import("../build.js");
|
|
142
|
+
const result = await buildProject(root, entry);
|
|
143
|
+
console.log(` ${green("Built")} dist/server.js and ${result.views.length} view${result.views.length === 1 ? "" : "s"} ${dim(`in ${result.ms} ms`)}`);
|
|
144
|
+
console.log(` ${dim("Run it with")} plugmcp start`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
case "start": {
|
|
148
|
+
const { loadBuilt } = await import("../build.js");
|
|
149
|
+
const { server, views } = await loadBuilt(root);
|
|
150
|
+
if (flags.stdio === true) {
|
|
151
|
+
const { serveStdio } = await import("../stdio.js");
|
|
152
|
+
serveStdio(server, { views });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const { serveHttp } = await import("../http.js");
|
|
156
|
+
// A host sets PORT. There the server must answer on every interface and any hostname.
|
|
157
|
+
const hosted = Boolean(process.env.PORT) || flags.host === "0.0.0.0";
|
|
158
|
+
const allowed = text(flags["allowed-hosts"]) ?? process.env.PLUGMCP_ALLOWED_HOSTS;
|
|
159
|
+
const running = await serveHttp(server, {
|
|
160
|
+
views,
|
|
161
|
+
port,
|
|
162
|
+
host: text(flags.host) ?? (hosted ? "0.0.0.0" : "127.0.0.1"),
|
|
163
|
+
allowedHosts: allowed ? allowed.split(",").map((h) => h.trim()) : hosted ? ["*"] : undefined,
|
|
164
|
+
});
|
|
165
|
+
console.log(` ${bold(server.info.name)} ${dim("is serving MCP at")} ${blue(running.url)}`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
case "search": {
|
|
169
|
+
const query = positional.join(" ");
|
|
170
|
+
if (!query)
|
|
171
|
+
throw new Error("Say what to search for: plugmcp search github");
|
|
172
|
+
const { directory } = await import("../dev/api.js");
|
|
173
|
+
const params = new URLSearchParams({ q: query });
|
|
174
|
+
if (flags.remote === true)
|
|
175
|
+
params.set("remote", "1");
|
|
176
|
+
const data = (await directory(`/servers?${params}`));
|
|
177
|
+
if (!data.servers.length) {
|
|
178
|
+
console.log(` Nothing matched "${query}". ${dim("That may be a gap worth filling.")}`);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
console.log(`\n ${data.total} server${data.total === 1 ? "" : "s"} for "${query}" ${dim("in the PlugMCP directory")}\n`);
|
|
182
|
+
for (const server of data.servers.slice(0, Number(flags.limit ?? 8))) {
|
|
183
|
+
const tags = [server.verified ? "verified" : "", server.remote ? "hosted" : "", server.stars ? `${server.stars} star${server.stars === 1 ? "" : "s"}` : ""].filter(Boolean).join(", ");
|
|
184
|
+
const summary = (server.summary ?? "").replace(/\s+/g, " ").slice(0, 110);
|
|
185
|
+
console.log(` ${bold(server.name)} ${dim(tags)}`);
|
|
186
|
+
if (summary)
|
|
187
|
+
console.log(` ${summary}`);
|
|
188
|
+
console.log(` ${blue(server.url)} ${dim(`plugmcp add ${server.slug}`)}\n`);
|
|
189
|
+
}
|
|
190
|
+
console.log(` ${dim("More at")} ${DIRECTORY_URL}/mcp?q=${encodeURIComponent(query)}\n`);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
case "add": {
|
|
194
|
+
const slug = positional[0];
|
|
195
|
+
if (!slug)
|
|
196
|
+
throw new Error("Give the server's slug: plugmcp add <slug>. Find one with plugmcp search.");
|
|
197
|
+
const { directory, writeServers } = await import("../dev/api.js");
|
|
198
|
+
const { resolveProject } = await import("../dev/project.js");
|
|
199
|
+
const record = (await directory(`/servers/${encodeURIComponent(slug)}`));
|
|
200
|
+
if (!record.remote_url) {
|
|
201
|
+
console.log(` ${record.name} is not hosted at an address, so it cannot join the Studio chat.`);
|
|
202
|
+
console.log(` Install steps: ${blue(record.url)}`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const project = resolveProject(root, entry);
|
|
206
|
+
const file = join(root, ".plugmcp", "servers.json");
|
|
207
|
+
const current = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : [];
|
|
208
|
+
const name = slugify(record.name).slice(0, 32);
|
|
209
|
+
writeServers(project, [...current.filter((s) => s.name !== name), { name, url: record.remote_url, slug }]);
|
|
210
|
+
console.log(` ${green("Added")} ${record.name}. Its tools are in the Studio chat next time you send a message.`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
case "list": {
|
|
214
|
+
const pkg = readPackage(root);
|
|
215
|
+
const repository = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url;
|
|
216
|
+
const listing = {
|
|
217
|
+
name: text(flags.name) ?? String(pkg.name ?? ""),
|
|
218
|
+
description: text(flags.description) ?? String(pkg.description ?? ""),
|
|
219
|
+
remoteUrl: text(flags.url),
|
|
220
|
+
repoUrl: text(flags.repo) ?? repository?.replace(/^git\+/, "").replace(/\.git$/, ""),
|
|
221
|
+
homepageUrl: text(flags.homepage) ?? (typeof pkg.homepage === "string" ? pkg.homepage : undefined),
|
|
222
|
+
npm: text(flags.npm) ?? (pkg.private ? undefined : pkg.name),
|
|
223
|
+
};
|
|
224
|
+
for (const key of Object.keys(listing))
|
|
225
|
+
if (!listing[key])
|
|
226
|
+
delete listing[key];
|
|
227
|
+
if (!listing.name || (listing.description ?? "").length < 10) {
|
|
228
|
+
throw new Error("A listing needs a name and a description of at least 10 characters. Set them in package.json or pass --name and --description.");
|
|
229
|
+
}
|
|
230
|
+
if (!listing.remoteUrl && !listing.repoUrl) {
|
|
231
|
+
throw new Error("A listing needs a public address or a repository. Pass --url https://... or --repo https://github.com/you/project.");
|
|
232
|
+
}
|
|
233
|
+
if (flags["dry-run"] === true) {
|
|
234
|
+
console.log(` ${dim("Would POST to")} ${SUBMIT_URL}\n`);
|
|
235
|
+
console.log(JSON.stringify(listing, null, 2));
|
|
236
|
+
console.log(`\n ${dim("Nothing was sent.")}`);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (flags.yes !== true) {
|
|
240
|
+
console.log(JSON.stringify(listing, null, 2));
|
|
241
|
+
const answer = await ask(`\n Publish this page in the public PlugMCP directory? (y/N) `);
|
|
242
|
+
if (!/^y(es)?$/i.test(answer))
|
|
243
|
+
return void console.log(" Nothing was sent.");
|
|
244
|
+
}
|
|
245
|
+
const result = await submitListing(listing);
|
|
246
|
+
const slug = String(result.slug ?? slugify(listing.name));
|
|
247
|
+
console.log(` ${green("Listed.")} ${blue(String(result.url ?? directoryPage(slug)))}`);
|
|
248
|
+
console.log(`\n ${dim("Badge for your README:")}\n ${readmeBadge(slug)}\n`);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
case "login": {
|
|
252
|
+
const key = text(flags.key) ?? (await ask(` Create an account key at ${DIRECTORY_URL}/app/settings/agent-access\n Paste it here: `));
|
|
253
|
+
saveAccountKey(key);
|
|
254
|
+
const client = await accountClient(key);
|
|
255
|
+
await client.close();
|
|
256
|
+
console.log(` ${green("Signed in.")} ${dim("The key is saved in ~/.plugmcp/credentials.json.")}`);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
case "deploy": {
|
|
260
|
+
const url = text(flags.url);
|
|
261
|
+
if (!url) {
|
|
262
|
+
console.log(`
|
|
263
|
+
PlugMCP does not run your code yet. Host the build anywhere that runs Node:
|
|
264
|
+
|
|
265
|
+
plugmcp build
|
|
266
|
+
plugmcp start ${dim("# reads PORT, serves /mcp")}
|
|
267
|
+
|
|
268
|
+
Then put it behind plugmcp.ai for a gateway address, keys and call logs:
|
|
269
|
+
|
|
270
|
+
plugmcp deploy --url https://your-host.example/mcp
|
|
271
|
+
`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (!/^https:\/\//.test(url))
|
|
275
|
+
throw new Error("The address must start with https://.");
|
|
276
|
+
const pkg = readPackage(root);
|
|
277
|
+
const payload = { name: text(flags.name) ?? String(pkg.name ?? "my-server"), description: String(pkg.description ?? ""), kind: "wrapped", upstream_url: url };
|
|
278
|
+
if (flags["dry-run"] === true) {
|
|
279
|
+
console.log(` ${dim("Would call create_server on")} ${ACCOUNT_MCP_URL}\n`);
|
|
280
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
281
|
+
console.log(`\n ${dim("Nothing was sent.")}`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const key = readAccountKey();
|
|
285
|
+
if (!key)
|
|
286
|
+
throw new Error("Sign in first: plugmcp login");
|
|
287
|
+
const client = await accountClient(key);
|
|
288
|
+
try {
|
|
289
|
+
if (!(await canWrapUrl(client))) {
|
|
290
|
+
console.log(`
|
|
291
|
+
plugmcp.ai cannot register an outside address from the command line yet.
|
|
292
|
+
Do it in the console, it takes a minute:
|
|
293
|
+
|
|
294
|
+
1. Open ${blue(`${DIRECTORY_URL}/app/servers`)}
|
|
295
|
+
2. Choose Add a server, then Connect existing MCP
|
|
296
|
+
3. Paste ${url}
|
|
297
|
+
`);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const result = (await client.callTool({ name: "create_server", arguments: payload }));
|
|
301
|
+
if (result.isError)
|
|
302
|
+
throw new Error(result.content?.[0]?.text ?? "plugmcp.ai refused the server.");
|
|
303
|
+
const server = result.structuredContent?.server;
|
|
304
|
+
console.log(` ${green("Created as a draft.")} Review and publish it:`);
|
|
305
|
+
console.log(` ${blue(`${DIRECTORY_URL}/app/servers/${server?.id ?? ""}`)}`);
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
await client.close();
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
case "version":
|
|
313
|
+
case "--version":
|
|
314
|
+
case "-v": {
|
|
315
|
+
const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
316
|
+
console.log(pkg.version);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
default:
|
|
320
|
+
console.log(HELP);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
main().catch((error) => {
|
|
324
|
+
console.error(`\n ${red("Error")} ${error instanceof Error ? error.message : String(error)}\n`);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { PlugServer } from "../index.js";
|
|
3
|
+
import type { RemoteServer } from "./chat.js";
|
|
4
|
+
import type { Project } from "./project.js";
|
|
5
|
+
/** Everything `plugmcp dev` serves: one or more MCP servers in one folder. */
|
|
6
|
+
export interface Hub {
|
|
7
|
+
home: string;
|
|
8
|
+
projects: () => Project[];
|
|
9
|
+
/** Look at the folder again, after a server was added. */
|
|
10
|
+
rescan: () => Project[];
|
|
11
|
+
contextFor: (project: Project) => ApiContext;
|
|
12
|
+
}
|
|
13
|
+
export interface ApiContext {
|
|
14
|
+
project: Project;
|
|
15
|
+
mcpUrl: () => string;
|
|
16
|
+
loadServer: () => Promise<PlugServer>;
|
|
17
|
+
/** Load the server again from disk, ignoring anything cached. Throws when the file is broken. */
|
|
18
|
+
reload: () => Promise<PlugServer>;
|
|
19
|
+
}
|
|
20
|
+
export declare function writeServers(project: Project, servers: RemoteServer[]): void;
|
|
21
|
+
/** Read the public PlugMCP directory. Answers are cached for five minutes. */
|
|
22
|
+
export declare function directory(path: string): Promise<unknown>;
|
|
23
|
+
export interface TestOutcome {
|
|
24
|
+
id: string;
|
|
25
|
+
tool: string;
|
|
26
|
+
name: string;
|
|
27
|
+
ok: boolean;
|
|
28
|
+
ms: number;
|
|
29
|
+
/** Why it failed, in words. Empty when it passed. */
|
|
30
|
+
reason: string;
|
|
31
|
+
/** The start of what the tool returned. */
|
|
32
|
+
output: string;
|
|
33
|
+
}
|
|
34
|
+
/** Run saved tests against the running server. With no ids, every test of the server. */
|
|
35
|
+
export declare function runSavedTests(context: ApiContext, ids?: string[]): Promise<TestOutcome[]>;
|
|
36
|
+
/** Handle one request under /__studio/api/. Returns false when the path is not ours. */
|
|
37
|
+
export declare function handleApi(req: IncomingMessage, res: ServerResponse, hub: Hub): Promise<boolean>;
|