@farming-labs/docs 0.2.32 → 0.2.33
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/dist/cli/index.mjs
CHANGED
|
@@ -62,7 +62,13 @@ async function main() {
|
|
|
62
62
|
apiRouteRoot: typeof flags["api-route-root"] === "string" ? flags["api-route-root"] : void 0,
|
|
63
63
|
cloud: typeof flags.cloud === "boolean" ? flags.cloud : void 0
|
|
64
64
|
};
|
|
65
|
-
const mcpOptions = {
|
|
65
|
+
const mcpOptions = {
|
|
66
|
+
configPath: typeof flags.config === "string" ? flags.config : void 0,
|
|
67
|
+
setup: subcommand === "setup",
|
|
68
|
+
deploymentId: typeof flags.deployment === "string" ? flags.deployment : void 0,
|
|
69
|
+
apiBaseUrl: typeof flags["api-base-url"] === "string" ? flags["api-base-url"] : typeof flags.url === "string" ? flags.url : void 0,
|
|
70
|
+
json: typeof flags.json === "boolean" ? flags.json : void 0
|
|
71
|
+
};
|
|
66
72
|
const devOptions = {
|
|
67
73
|
verbose: typeof flags.verbose === "boolean" ? flags.verbose : void 0,
|
|
68
74
|
port: typeof flags.port === "string" ? flags.port : void 0,
|
|
@@ -132,7 +138,7 @@ async function main() {
|
|
|
132
138
|
printCloudHelp();
|
|
133
139
|
process.exit(1);
|
|
134
140
|
} else if (parsedCommand.command === "mcp") {
|
|
135
|
-
const { runMcp } = await import("../mcp-
|
|
141
|
+
const { runMcp } = await import("../mcp-DaKlH38e.mjs");
|
|
136
142
|
await runMcp(mcpOptions);
|
|
137
143
|
} else if (parsedCommand.command === "agent" && subcommand === "compact") {
|
|
138
144
|
const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-BaiQvHO9.mjs");
|
|
@@ -298,6 +304,9 @@ ${pc.dim("Options for init:")}
|
|
|
298
304
|
|
|
299
305
|
${pc.dim("Options for mcp:")}
|
|
300
306
|
${pc.cyan("--config <path>")} Use a custom docs config path instead of ${pc.dim("docs.config.ts[x]")}
|
|
307
|
+
${pc.cyan("mcp setup --deployment <id>")} Print Docs Cloud hosted MCP setup for a deployment id
|
|
308
|
+
${pc.cyan("--api-base-url <url>")} Override the hosted Docs Cloud API base URL for ${pc.cyan("mcp setup")}
|
|
309
|
+
${pc.cyan("--json")} Print MCP client JSON only for ${pc.cyan("mcp setup")}
|
|
301
310
|
|
|
302
311
|
${pc.dim("Options for dev:")}
|
|
303
312
|
${pc.cyan("--port <number>")} Run the frameworkless preview on a custom port
|
|
@@ -5,9 +5,14 @@ import { createFilesystemDocsMcpSource, resolveDocsMcpConfig, runDocsMcpStdio }
|
|
|
5
5
|
import "./server.mjs";
|
|
6
6
|
import { c as readNavTitle, m as resolveDocsContentDir, n as extractObjectLiteral, o as readBooleanProperty, p as resolveDocsConfigPath, u as readStringProperty } from "./config-De5z-2LK.mjs";
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
|
+
import pc from "picocolors";
|
|
8
9
|
|
|
9
10
|
//#region src/cli/mcp.ts
|
|
10
11
|
async function runMcp(options = {}) {
|
|
12
|
+
if (options.setup) {
|
|
13
|
+
printHostedMcpSetup(options);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
11
16
|
const rootDir = process.cwd();
|
|
12
17
|
const content = readFileSync(resolveDocsConfigPath(rootDir, options.configPath), "utf-8");
|
|
13
18
|
const entry = readStringProperty(content, "entry") ?? "docs";
|
|
@@ -25,6 +30,49 @@ async function runMcp(options = {}) {
|
|
|
25
30
|
defaultName: navTitle ?? "@farming-labs/docs"
|
|
26
31
|
});
|
|
27
32
|
}
|
|
33
|
+
function normalizeApiBaseUrl(value) {
|
|
34
|
+
return (value?.trim() || "https://api.farming-labs.dev").replace(/\/+$/g, "");
|
|
35
|
+
}
|
|
36
|
+
function printHostedMcpSetup(options) {
|
|
37
|
+
const deploymentId = options.deploymentId?.trim();
|
|
38
|
+
if (!deploymentId) {
|
|
39
|
+
console.error(pc.red("Missing MCP deployment id."));
|
|
40
|
+
console.error();
|
|
41
|
+
console.error(`Run ${pc.cyan("npx @farming-labs/docs mcp setup --deployment <deployment-id>")}.`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const endpoint = `${normalizeApiBaseUrl(options.apiBaseUrl)}/v1/mcp/${deploymentId}`;
|
|
45
|
+
const jsonConfig = { mcpServers: { "docs-cloud": {
|
|
46
|
+
command: "npx",
|
|
47
|
+
args: [
|
|
48
|
+
"@farming-labs/docs",
|
|
49
|
+
"mcp",
|
|
50
|
+
"setup",
|
|
51
|
+
"--deployment",
|
|
52
|
+
deploymentId
|
|
53
|
+
]
|
|
54
|
+
} } };
|
|
55
|
+
if (options.json) {
|
|
56
|
+
console.log(JSON.stringify(jsonConfig, null, 2));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
console.log(pc.bold("Docs Cloud MCP deployment"));
|
|
60
|
+
console.log(pc.dim(`Deployment: ${deploymentId}`));
|
|
61
|
+
console.log();
|
|
62
|
+
console.log(pc.cyan("CLI stdio"));
|
|
63
|
+
console.log(` npx @farming-labs/docs mcp setup --deployment ${deploymentId}`);
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(pc.cyan("Streamable HTTP"));
|
|
66
|
+
console.log(` ${endpoint}`);
|
|
67
|
+
console.log();
|
|
68
|
+
console.log(pc.cyan("SSE"));
|
|
69
|
+
console.log(` ${endpoint}/sse`);
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(pc.cyan("MCP client JSON"));
|
|
72
|
+
console.log(JSON.stringify(jsonConfig, null, 2));
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(pc.dim("Set DOCS_CLOUD_API_KEY in the agent environment before connecting."));
|
|
75
|
+
}
|
|
28
76
|
function readMcpConfig(content) {
|
|
29
77
|
if (content.match(/mcp\s*:\s*false/)) return false;
|
|
30
78
|
if (content.match(/mcp\s*:\s*true/)) return true;
|