@workpowers/speckle 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/bin/speckle-mcp.mjs +26 -0
- package/dist/cli-entry.d.ts +2 -0
- package/dist/cli-entry.d.ts.map +1 -0
- package/dist/cli-entry.js +10 -0
- package/dist/cli-entry.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +150 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +52 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +24 -0
- package/dist/errors.js.map +1 -0
- package/dist/headers.d.ts +25 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/headers.js +27 -0
- package/dist/headers.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/marker.d.ts +37 -0
- package/dist/marker.d.ts.map +1 -0
- package/dist/marker.js +169 -0
- package/dist/marker.js.map +1 -0
- package/dist/proxy.d.ts +18 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +49 -0
- package/dist/proxy.js.map +1 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +14 -0
- package/dist/run.js.map +1 -0
- package/dist/workspace.d.ts +45 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +138 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Published entry — pulls compiled JS out of dist/. The TS sources in src/
|
|
4
|
+
* are kept for tests + development (`tsx plugins/speckle-mcp/src/run.ts`),
|
|
5
|
+
* but installed users always run through this shim against dist/.
|
|
6
|
+
*/
|
|
7
|
+
import { startRouter, reportFatal } from "../dist/index.js";
|
|
8
|
+
import { runCli } from "../dist/cli.js";
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const sub = args[0];
|
|
12
|
+
|
|
13
|
+
const isCliSubcommand =
|
|
14
|
+
sub === "init" || sub === "doctor" || sub === "help" || sub === "--help" || sub === "-h";
|
|
15
|
+
|
|
16
|
+
if (isCliSubcommand) {
|
|
17
|
+
runCli(args).catch((err) => {
|
|
18
|
+
reportFatal(err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
startRouter().catch((err) => {
|
|
23
|
+
reportFatal(err);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-entry.d.ts","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI entry — invoked by `bin/speckle-mcp.mjs` for non-default subcommands.
|
|
3
|
+
*/
|
|
4
|
+
import { runCli } from "./cli.js";
|
|
5
|
+
import { reportFatal } from "./index.js";
|
|
6
|
+
runCli(process.argv.slice(2)).catch((err) => {
|
|
7
|
+
reportFatal(err);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=cli-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-entry.js","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC1C,WAAW,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `speckle mcp` CLI subcommands.
|
|
3
|
+
*
|
|
4
|
+
* speckle mcp init --project <id> [--slug <slug>] [--url <speckle_url>]
|
|
5
|
+
* Writes a `.speckle` marker at the repo root.
|
|
6
|
+
*
|
|
7
|
+
* speckle mcp doctor
|
|
8
|
+
* Resolves marker + workspace + env and prints a diagnostic
|
|
9
|
+
* summary. Never sends a network request — diagnoses local config
|
|
10
|
+
* only. Intended to be the first command users run when something
|
|
11
|
+
* feels off.
|
|
12
|
+
*/
|
|
13
|
+
export declare function runCli(args: string[]): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB1D"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `speckle mcp` CLI subcommands.
|
|
3
|
+
*
|
|
4
|
+
* speckle mcp init --project <id> [--slug <slug>] [--url <speckle_url>]
|
|
5
|
+
* Writes a `.speckle` marker at the repo root.
|
|
6
|
+
*
|
|
7
|
+
* speckle mcp doctor
|
|
8
|
+
* Resolves marker + workspace + env and prints a diagnostic
|
|
9
|
+
* summary. Never sends a network request — diagnoses local config
|
|
10
|
+
* only. Intended to be the first command users run when something
|
|
11
|
+
* feels off.
|
|
12
|
+
*/
|
|
13
|
+
import { writeFileSync, existsSync } from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { renderSpeckleMarker } from "./marker.js";
|
|
16
|
+
import { resolveWorkspace } from "./workspace.js";
|
|
17
|
+
import { loadRouterConfig, resolveSpeckleHost } from "./config.js";
|
|
18
|
+
import { SpeckleRouterError } from "./errors.js";
|
|
19
|
+
export async function runCli(args) {
|
|
20
|
+
const [cmd, ...rest] = args;
|
|
21
|
+
switch (cmd) {
|
|
22
|
+
case "init":
|
|
23
|
+
return runInit(rest);
|
|
24
|
+
case "doctor":
|
|
25
|
+
return runDoctor();
|
|
26
|
+
case "help":
|
|
27
|
+
case "--help":
|
|
28
|
+
case undefined:
|
|
29
|
+
printHelp();
|
|
30
|
+
return;
|
|
31
|
+
default:
|
|
32
|
+
printHelp();
|
|
33
|
+
throw new SpeckleRouterError("config_missing", `Unknown subcommand: ${cmd}`, "Try `speckle mcp init --project <id>` or `speckle mcp doctor`.");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function runInit(args) {
|
|
37
|
+
const parsed = parseInitArgs(args);
|
|
38
|
+
const target = path.resolve(process.cwd(), ".speckle");
|
|
39
|
+
if (existsSync(target) && !parsed.force) {
|
|
40
|
+
throw new SpeckleRouterError("marker_invalid", `A .speckle file already exists at ${target}.`, "Pass --force to overwrite, or edit the existing marker by hand.");
|
|
41
|
+
}
|
|
42
|
+
const marker = {
|
|
43
|
+
version: 1,
|
|
44
|
+
projectId: parsed.projectId,
|
|
45
|
+
projectSlug: parsed.slug,
|
|
46
|
+
speckleUrl: parsed.url,
|
|
47
|
+
};
|
|
48
|
+
writeFileSync(target, renderSpeckleMarker(marker));
|
|
49
|
+
process.stdout.write(`Wrote ${target}\n`);
|
|
50
|
+
process.stdout.write("Commit this file. It contains no secrets — only the project id and optional metadata.\n");
|
|
51
|
+
}
|
|
52
|
+
function parseInitArgs(args) {
|
|
53
|
+
const out = { force: false };
|
|
54
|
+
for (let i = 0; i < args.length; i++) {
|
|
55
|
+
const a = args[i];
|
|
56
|
+
if (a === "--project" || a === "-p") {
|
|
57
|
+
const v = args[++i];
|
|
58
|
+
const n = Number.parseInt(v, 10);
|
|
59
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
60
|
+
throw new SpeckleRouterError("config_missing", `--project requires a positive integer (got ${JSON.stringify(v)}).`, "Pass the numeric Speckle project id, e.g. `speckle mcp init --project 42`.");
|
|
61
|
+
}
|
|
62
|
+
out.projectId = n;
|
|
63
|
+
}
|
|
64
|
+
else if (a === "--slug") {
|
|
65
|
+
out.slug = args[++i];
|
|
66
|
+
}
|
|
67
|
+
else if (a === "--url") {
|
|
68
|
+
out.url = args[++i];
|
|
69
|
+
}
|
|
70
|
+
else if (a === "--force") {
|
|
71
|
+
out.force = true;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
throw new SpeckleRouterError("config_missing", `Unknown argument: ${a}`, "See `speckle mcp help` for valid flags.");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (out.projectId === undefined) {
|
|
78
|
+
throw new SpeckleRouterError("config_missing", "`speckle mcp init` requires --project <id>.", "Pass the numeric Speckle project id, e.g. `speckle mcp init --project 42`.");
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function runDoctor() {
|
|
83
|
+
const report = {};
|
|
84
|
+
let config;
|
|
85
|
+
try {
|
|
86
|
+
config = loadRouterConfig();
|
|
87
|
+
report.config = { baseUrl: config.baseUrl, keyConfigured: Boolean(config.apiKey) };
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
report.config = formatError(err);
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const workspace = resolveWorkspace({
|
|
94
|
+
cwd: process.cwd(),
|
|
95
|
+
allowRepoMismatch: config?.allowRepoMismatch ?? false,
|
|
96
|
+
});
|
|
97
|
+
report.workspace = {
|
|
98
|
+
workspaceRoot: workspace.workspaceRoot,
|
|
99
|
+
markerPath: workspace.markerPath,
|
|
100
|
+
projectId: workspace.marker.marker.projectId,
|
|
101
|
+
projectSlug: workspace.marker.marker.projectSlug,
|
|
102
|
+
markerSpeckleUrl: workspace.marker.marker.speckleUrl,
|
|
103
|
+
canonicalRemote: workspace.canonicalRemote,
|
|
104
|
+
workspaceRootHash: workspace.workspaceRootHash,
|
|
105
|
+
markerHash: workspace.marker.contentHash,
|
|
106
|
+
};
|
|
107
|
+
if (config) {
|
|
108
|
+
try {
|
|
109
|
+
const host = resolveSpeckleHost(config, workspace.marker.marker.speckleUrl);
|
|
110
|
+
report.host = host;
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
report.host = formatError(err);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
report.workspace = formatError(err);
|
|
119
|
+
}
|
|
120
|
+
process.stdout.write(JSON.stringify(report, null, 2) + "\n");
|
|
121
|
+
}
|
|
122
|
+
function formatError(err) {
|
|
123
|
+
if (err instanceof SpeckleRouterError) {
|
|
124
|
+
return { error: err.code, message: err.message, hint: err.hint, details: err.details };
|
|
125
|
+
}
|
|
126
|
+
if (err instanceof Error)
|
|
127
|
+
return { error: "unknown", message: err.message };
|
|
128
|
+
return { error: "unknown", message: String(err) };
|
|
129
|
+
}
|
|
130
|
+
function printHelp() {
|
|
131
|
+
process.stdout.write([
|
|
132
|
+
"speckle-mcp — local MCP router for Speckle (npm: @workpowers/speckle)",
|
|
133
|
+
"",
|
|
134
|
+
"Usage:",
|
|
135
|
+
" speckle-mcp Start the stdio MCP router (default — used by MCP clients).",
|
|
136
|
+
" speckle-mcp init --project <id> Write a .speckle marker at the repo root.",
|
|
137
|
+
" --slug <slug> Optional human-readable project slug.",
|
|
138
|
+
" --url <speckle_url> Optional Speckle host URL when not using the default.",
|
|
139
|
+
" --force Overwrite an existing .speckle file.",
|
|
140
|
+
" speckle-mcp doctor Diagnose local config and marker state (no network).",
|
|
141
|
+
" speckle-mcp help Show this message.",
|
|
142
|
+
"",
|
|
143
|
+
"Environment:",
|
|
144
|
+
" SPECKLE_MCP_BASE_URL Speckle host (e.g. http://localhost:3000).",
|
|
145
|
+
" SPECKLE_MCP_KEY User-scoped MCP API key (lsk_...).",
|
|
146
|
+
" SPECKLE_MCP_ALLOW_REPO_MISMATCH=1 Bypass the marker-vs-checkout remote safety check.",
|
|
147
|
+
"",
|
|
148
|
+
].join("\n"));
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAsB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc;IACzC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5B,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,KAAK,QAAQ;YACX,OAAO,SAAS,EAAE,CAAC;QACrB,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,SAAS,EAAE,CAAC;YACZ,OAAO;QACT;YACE,SAAS,EAAE,CAAC;YACZ,MAAM,IAAI,kBAAkB,CAC1B,gBAAgB,EAChB,uBAAuB,GAAG,EAAE,EAC5B,gEAAgE,CACjE,CAAC;IACN,CAA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AC;AAED,SAAS,WAAW,CAAC,GAAY;IAC/B,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;QACtC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IACzF,CAAC;IACD,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5E,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB;QACE,uEAAuE;QACvE,EAAE;QACF,QAAQ;QACR,iGAAiG;QACjG,+EAA+E;QAC/E,2EAA2E;QAC3E,2FAA2F;QAC3F,0EAA0E;QAC1E,0FAA0F;QAC1F,wDAAwD;QACxD,EAAE;QACF,cAAc;QACd,gFAAgF;QAChF,wEAAwE;QACxE,wFAAwF;QACxF,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router configuration assembled from environment variables.
|
|
3
|
+
*
|
|
4
|
+
* The router accepts only one secret (`SPECKLE_MCP_KEY`) and one optional
|
|
5
|
+
* host hint (`SPECKLE_MCP_BASE_URL`). Everything else — project context,
|
|
6
|
+
* repo identity — comes from the committed `.speckle` marker.
|
|
7
|
+
*/
|
|
8
|
+
export interface RouterConfig {
|
|
9
|
+
/** Speckle MCP base URL — `<host>/mcp` is constructed from this. */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/** User-scoped API key. Never logged or echoed. */
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** SPECKLE_MCP_ALLOW_REPO_MISMATCH=1 escape hatch state. */
|
|
14
|
+
allowRepoMismatch: boolean;
|
|
15
|
+
/** Process cwd at startup (workspace fallback when MCP roots are absent). */
|
|
16
|
+
cwd: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function loadRouterConfig(env?: NodeJS.ProcessEnv): RouterConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Pick the Speckle host this MCP call should hit. The marker's
|
|
21
|
+
* `speckle_url` wins over the global `SPECKLE_MCP_BASE_URL` so a repo can
|
|
22
|
+
* intentionally tie itself to a non-default host. If both are set and
|
|
23
|
+
* disagree, that is fail-closed (host scope mismatch).
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveSpeckleHost(config: RouterConfig, markerSpeckleUrl: string | undefined): {
|
|
26
|
+
hostUrl: string;
|
|
27
|
+
usingMarker: boolean;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,iBAAiB,EAAE,OAAO,CAAC;IAC3B,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,YAAY,CAsBnF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,gBAAgB,EAAE,MAAM,GAAG,SAAS,GACnC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAc3C"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Router configuration assembled from environment variables.
|
|
3
|
+
*
|
|
4
|
+
* The router accepts only one secret (`SPECKLE_MCP_KEY`) and one optional
|
|
5
|
+
* host hint (`SPECKLE_MCP_BASE_URL`). Everything else — project context,
|
|
6
|
+
* repo identity — comes from the committed `.speckle` marker.
|
|
7
|
+
*/
|
|
8
|
+
import { SpeckleRouterError } from "./errors.js";
|
|
9
|
+
export function loadRouterConfig(env = process.env) {
|
|
10
|
+
const baseUrl = (env.SPECKLE_MCP_BASE_URL ?? "").trim();
|
|
11
|
+
const apiKey = (env.SPECKLE_MCP_KEY ?? "").trim();
|
|
12
|
+
const missing = [];
|
|
13
|
+
if (!baseUrl)
|
|
14
|
+
missing.push("SPECKLE_MCP_BASE_URL");
|
|
15
|
+
if (!apiKey)
|
|
16
|
+
missing.push("SPECKLE_MCP_KEY");
|
|
17
|
+
if (missing.length > 0) {
|
|
18
|
+
throw new SpeckleRouterError("config_missing", `Speckle MCP router is missing required environment variable(s): ${missing.join(", ")}.`, "Set these in your global MCP client config. The base URL is the Speckle host (no `/mcp` suffix), and the key is a user-scoped MCP API key.", { missing });
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
22
|
+
apiKey,
|
|
23
|
+
allowRepoMismatch: env.SPECKLE_MCP_ALLOW_REPO_MISMATCH === "1",
|
|
24
|
+
cwd: process.cwd(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Pick the Speckle host this MCP call should hit. The marker's
|
|
29
|
+
* `speckle_url` wins over the global `SPECKLE_MCP_BASE_URL` so a repo can
|
|
30
|
+
* intentionally tie itself to a non-default host. If both are set and
|
|
31
|
+
* disagree, that is fail-closed (host scope mismatch).
|
|
32
|
+
*/
|
|
33
|
+
export function resolveSpeckleHost(config, markerSpeckleUrl) {
|
|
34
|
+
if (markerSpeckleUrl) {
|
|
35
|
+
const fromMarker = markerSpeckleUrl.replace(/\/+$/, "");
|
|
36
|
+
if (config.baseUrl && normalizeOrigin(fromMarker) !== normalizeOrigin(config.baseUrl)) {
|
|
37
|
+
throw new SpeckleRouterError("marker_host_mismatch", `.speckle selects ${fromMarker}, but SPECKLE_MCP_BASE_URL is ${config.baseUrl}.`, "The key is scoped to one Speckle host. Either issue a key for the marker's host, or align SPECKLE_MCP_BASE_URL with the marker.", { markerHost: fromMarker, configuredHost: config.baseUrl });
|
|
38
|
+
}
|
|
39
|
+
return { hostUrl: fromMarker, usingMarker: true };
|
|
40
|
+
}
|
|
41
|
+
return { hostUrl: config.baseUrl, usingMarker: false };
|
|
42
|
+
}
|
|
43
|
+
function normalizeOrigin(url) {
|
|
44
|
+
try {
|
|
45
|
+
const u = new URL(url);
|
|
46
|
+
return `${u.protocol}//${u.host}`.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return url.toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAajD,MAAM,UAAU,gBAAgB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACnE,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAElD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,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AAG,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured errors thrown by the local Speckle MCP router.
|
|
3
|
+
*
|
|
4
|
+
* Every error carries a stable `code` so MCP clients (and tests) can react
|
|
5
|
+
* to specific failure modes without parsing prose. The `hint` field is
|
|
6
|
+
* user-facing actionable text — exactly what an agent should surface back
|
|
7
|
+
* to the developer.
|
|
8
|
+
*/
|
|
9
|
+
export type SpeckleRouterErrorCode = "marker_not_found" | "marker_invalid" | "marker_remote_mismatch" | "marker_host_mismatch" | "workspace_ambiguous" | "workspace_unresolved" | "remote_unauthorized" | "remote_forbidden" | "remote_unreachable" | "remote_bad_response" | "config_missing";
|
|
10
|
+
export declare class SpeckleRouterError extends Error {
|
|
11
|
+
readonly code: SpeckleRouterErrorCode;
|
|
12
|
+
readonly hint: string;
|
|
13
|
+
readonly details?: Record<string, unknown>;
|
|
14
|
+
constructor(code: SpeckleRouterErrorCode, message: string, hint: string, details?: Record<string, unknown>);
|
|
15
|
+
toUserFacing(): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,sBAAsB,GAC9B,kBAAkB,GAClB,gBAAgB,GAChB,wBAAwB,GACxB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,GAClB,oBAAoB,GACpB,qBAAqB,GACrB,gBAAgB,CAAC;AAErB,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGzC,IAAI,EAAE,sBAAsB,EAC5B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IASnC,YAAY,IAAI,MAAM;CAGvB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured errors thrown by the local Speckle MCP router.
|
|
3
|
+
*
|
|
4
|
+
* Every error carries a stable `code` so MCP clients (and tests) can react
|
|
5
|
+
* to specific failure modes without parsing prose. The `hint` field is
|
|
6
|
+
* user-facing actionable text — exactly what an agent should surface back
|
|
7
|
+
* to the developer.
|
|
8
|
+
*/
|
|
9
|
+
export class SpeckleRouterError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
hint;
|
|
12
|
+
details;
|
|
13
|
+
constructor(code, message, hint, details) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "SpeckleRouterError";
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.hint = hint;
|
|
18
|
+
this.details = details;
|
|
19
|
+
}
|
|
20
|
+
toUserFacing() {
|
|
21
|
+
return `${this.message}\n\n${this.hint}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAeH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAyB;IAC7B,IAAI,CAAS;IACb,OAAO,CAA2B;IAE3C,YACE,IAA4B,EAC5B,OAAe,EACf,IAAY,EACZ,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,YAAY;QACV,OAAO,GAAG,IAAI,CAAC,OAAO,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the HTTP header set sent to the remote `/mcp` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* The router communicates project context to the server through dedicated
|
|
5
|
+
* `X-Speckle-*` headers rather than tool arguments, so public tool schemas
|
|
6
|
+
* stay clean and the server can authorize before constructing an MCP
|
|
7
|
+
* session for the wrong project.
|
|
8
|
+
*/
|
|
9
|
+
import type { ResolvedWorkspace } from "./workspace.js";
|
|
10
|
+
export declare const ROUTER_CLIENT_NAME = "@workpowers/speckle";
|
|
11
|
+
export declare const ROUTER_CLIENT_VERSION = "0.1.0";
|
|
12
|
+
export interface RouterRequestHeaders {
|
|
13
|
+
Authorization: string;
|
|
14
|
+
"X-Speckle-Project-Id": string;
|
|
15
|
+
"X-Speckle-Client": string;
|
|
16
|
+
"X-Speckle-Marker-Hash": string;
|
|
17
|
+
"X-Speckle-Workspace-Hash": string;
|
|
18
|
+
"X-Speckle-Project-Slug"?: string;
|
|
19
|
+
"X-Speckle-Repo-Remote"?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function buildRouterHeaders(args: {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
workspace: ResolvedWorkspace;
|
|
24
|
+
}): RouterRequestHeaders;
|
|
25
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAE7C,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,EAAE,MAAM,CAAC;IAChC,0BAA0B,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,iBAAiB,CAAC;CAC9B,GAAG,oBAAoB,CAavB"}
|
package/dist/headers.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the HTTP header set sent to the remote `/mcp` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* The router communicates project context to the server through dedicated
|
|
5
|
+
* `X-Speckle-*` headers rather than tool arguments, so public tool schemas
|
|
6
|
+
* stay clean and the server can authorize before constructing an MCP
|
|
7
|
+
* session for the wrong project.
|
|
8
|
+
*/
|
|
9
|
+
export const ROUTER_CLIENT_NAME = "@workpowers/speckle";
|
|
10
|
+
export const ROUTER_CLIENT_VERSION = "0.1.0";
|
|
11
|
+
export function buildRouterHeaders(args) {
|
|
12
|
+
const { apiKey, workspace } = args;
|
|
13
|
+
const m = workspace.marker.marker;
|
|
14
|
+
const headers = {
|
|
15
|
+
Authorization: `Bearer ${apiKey}`,
|
|
16
|
+
"X-Speckle-Project-Id": String(m.projectId),
|
|
17
|
+
"X-Speckle-Client": `${ROUTER_CLIENT_NAME}/${ROUTER_CLIENT_VERSION}`,
|
|
18
|
+
"X-Speckle-Marker-Hash": `sha256:${workspace.marker.contentHash}`,
|
|
19
|
+
"X-Speckle-Workspace-Hash": `sha256:${workspace.workspaceRootHash}`,
|
|
20
|
+
};
|
|
21
|
+
if (m.projectSlug)
|
|
22
|
+
headers["X-Speckle-Project-Slug"] = m.projectSlug;
|
|
23
|
+
if (workspace.canonicalRemote)
|
|
24
|
+
headers["X-Speckle-Repo-Remote"] = workspace.canonicalRemote;
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AACxD,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAY7C,MAAM,UAAU,kBAAkB,CAAC,IAGlC;IACC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACnC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,MAAM,OAAO,GAAyB;QACpC,aAAa,EAAE,UAAU,MAAM,EAAE;QACjC,sBAAsB,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3C,kBAAkB,EAAE,GAAG,kBAAkB,IAAI,qBAAqB,EAAE;QACpE,uBAAuB,EAAE,UAAU,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE;QACjE,0BAA0B,EAAE,UAAU,SAAS,CAAC,iBAAiB,EAAE;KACpE,CAAC;IACF,IAAI,CAAC,CAAC,WAAW;QAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC;IACrE,IAAI,SAAS,CAAC,eAAe;QAAE,OAAO,CAAC,uBAAuB,CAAC,GAAG,SAAS,CAAC,eAAe,CAAC;IAC5F,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Speckle MCP router — entry point.
|
|
3
|
+
*
|
|
4
|
+
* Boots a stdio MCP server that proxies every supported request to the
|
|
5
|
+
* remote Speckle `/mcp` endpoint, injecting project context resolved from
|
|
6
|
+
* the nearest committed `.speckle` marker.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. Load env config (`SPECKLE_MCP_BASE_URL`, `SPECKLE_MCP_KEY`).
|
|
10
|
+
* 2. Resolve workspace + marker (cwd-based v1; MCP-roots support is a TODO).
|
|
11
|
+
* 3. Pick the Speckle host (marker `speckle_url` wins over env baseUrl).
|
|
12
|
+
* 4. Connect upstream MCP client over StreamableHTTP, with auth + context headers.
|
|
13
|
+
* 5. Mirror upstream capabilities downstream and wire pass-through handlers.
|
|
14
|
+
* 6. Connect the stdio server transport. The agent now talks to us as if
|
|
15
|
+
* we were Speckle.
|
|
16
|
+
*
|
|
17
|
+
* Any boot failure prints the user-facing error to stderr and exits non-zero
|
|
18
|
+
* so the host MCP client surfaces the cause instead of silently hanging.
|
|
19
|
+
*/
|
|
20
|
+
export declare function startRouter(): Promise<void>;
|
|
21
|
+
export declare function reportFatal(err: unknown): void;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAYH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA+CjD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAQ9C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Speckle MCP router — entry point.
|
|
3
|
+
*
|
|
4
|
+
* Boots a stdio MCP server that proxies every supported request to the
|
|
5
|
+
* remote Speckle `/mcp` endpoint, injecting project context resolved from
|
|
6
|
+
* the nearest committed `.speckle` marker.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. Load env config (`SPECKLE_MCP_BASE_URL`, `SPECKLE_MCP_KEY`).
|
|
10
|
+
* 2. Resolve workspace + marker (cwd-based v1; MCP-roots support is a TODO).
|
|
11
|
+
* 3. Pick the Speckle host (marker `speckle_url` wins over env baseUrl).
|
|
12
|
+
* 4. Connect upstream MCP client over StreamableHTTP, with auth + context headers.
|
|
13
|
+
* 5. Mirror upstream capabilities downstream and wire pass-through handlers.
|
|
14
|
+
* 6. Connect the stdio server transport. The agent now talks to us as if
|
|
15
|
+
* we were Speckle.
|
|
16
|
+
*
|
|
17
|
+
* Any boot failure prints the user-facing error to stderr and exits non-zero
|
|
18
|
+
* so the host MCP client surfaces the cause instead of silently hanging.
|
|
19
|
+
*/
|
|
20
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
21
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
22
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
23
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
24
|
+
import { loadRouterConfig, resolveSpeckleHost } from "./config.js";
|
|
25
|
+
import { resolveWorkspace } from "./workspace.js";
|
|
26
|
+
import { buildRouterHeaders, ROUTER_CLIENT_NAME, ROUTER_CLIENT_VERSION } from "./headers.js";
|
|
27
|
+
import { wireProxyHandlers } from "./proxy.js";
|
|
28
|
+
import { SpeckleRouterError } from "./errors.js";
|
|
29
|
+
export async function startRouter() {
|
|
30
|
+
const config = loadRouterConfig();
|
|
31
|
+
const workspace = resolveWorkspace({
|
|
32
|
+
cwd: config.cwd,
|
|
33
|
+
allowRepoMismatch: config.allowRepoMismatch,
|
|
34
|
+
});
|
|
35
|
+
const host = resolveSpeckleHost(config, workspace.marker.marker.speckleUrl);
|
|
36
|
+
const headers = buildRouterHeaders({ apiKey: config.apiKey, workspace });
|
|
37
|
+
const upstream = new Client({ name: ROUTER_CLIENT_NAME, version: ROUTER_CLIENT_VERSION }, { capabilities: {} });
|
|
38
|
+
const httpTransport = new StreamableHTTPClientTransport(new URL(`${host.hostUrl}/mcp`), {
|
|
39
|
+
requestInit: { headers: headers },
|
|
40
|
+
});
|
|
41
|
+
await upstream.connect(httpTransport);
|
|
42
|
+
const capabilities = upstream.getServerCapabilities() ?? {};
|
|
43
|
+
const downstream = new Server({ name: ROUTER_CLIENT_NAME, version: ROUTER_CLIENT_VERSION }, { capabilities });
|
|
44
|
+
wireProxyHandlers(downstream, upstream, capabilities);
|
|
45
|
+
const stdio = new StdioServerTransport();
|
|
46
|
+
await downstream.connect(stdio);
|
|
47
|
+
// Forward shutdown so the upstream socket is closed when the agent disconnects.
|
|
48
|
+
const teardown = async () => {
|
|
49
|
+
try {
|
|
50
|
+
await downstream.close();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
/* ignore */
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
await upstream.close();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* ignore */
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
stdio.onclose = teardown;
|
|
63
|
+
process.on("SIGINT", () => void teardown().then(() => process.exit(0)));
|
|
64
|
+
process.on("SIGTERM", () => void teardown().then(() => process.exit(0)));
|
|
65
|
+
}
|
|
66
|
+
export function reportFatal(err) {
|
|
67
|
+
if (err instanceof SpeckleRouterError) {
|
|
68
|
+
process.stderr.write(`speckle-mcp: ${err.toUserFacing()}\n`);
|
|
69
|
+
}
|
|
70
|
+
else if (err instanceof Error) {
|
|
71
|
+
process.stderr.write(`speckle-mcp: ${err.message}\n`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
process.stderr.write(`speckle-mcp: unknown error: ${String(err)}\n`);
|
|
75
|
+
}
|
|
76
|
+
}
|
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,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;QACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;SAAM,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
|
package/dist/marker.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `.speckle` marker — committed, nonsecret repo metadata declaring the
|
|
3
|
+
* Speckle project this checkout maps to.
|
|
4
|
+
*
|
|
5
|
+
* The marker is TOML by design: human-readable, comment-friendly, and
|
|
6
|
+
* extensible without ad-hoc env parsing. The parser implemented here
|
|
7
|
+
* targets only the small subset we actually need so we ship zero
|
|
8
|
+
* third-party dependencies. If the marker grows beyond top-level scalars
|
|
9
|
+
* and a `[repo]` section, switch to a real TOML library and delete this.
|
|
10
|
+
*
|
|
11
|
+
* Required fields: `version`, `project_id`.
|
|
12
|
+
* Optional fields: `project_slug`, `speckle_url`, `[repo].remote`.
|
|
13
|
+
*/
|
|
14
|
+
export interface SpeckleMarker {
|
|
15
|
+
version: number;
|
|
16
|
+
projectId: number;
|
|
17
|
+
projectSlug?: string;
|
|
18
|
+
speckleUrl?: string;
|
|
19
|
+
repo?: {
|
|
20
|
+
remote?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface ParsedMarker {
|
|
24
|
+
marker: SpeckleMarker;
|
|
25
|
+
/** SHA-256 of the raw marker text (lowercase hex). */
|
|
26
|
+
contentHash: string;
|
|
27
|
+
/** Raw source for diagnostics. */
|
|
28
|
+
raw: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function parseSpeckleMarker(raw: string, sourcePath?: string): ParsedMarker;
|
|
31
|
+
/**
|
|
32
|
+
* Render a marker back to canonical TOML — used by `speckle mcp init` and
|
|
33
|
+
* the project UI snippet. Keeps formatting stable so committed markers
|
|
34
|
+
* have predictable diffs.
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderSpeckleMarker(marker: SpeckleMarker): string;
|
|
37
|
+
//# sourceMappingURL=marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../src/marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;CACb;AAID,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAKjF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAYjE"}
|
package/dist/marker.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `.speckle` marker — committed, nonsecret repo metadata declaring the
|
|
3
|
+
* Speckle project this checkout maps to.
|
|
4
|
+
*
|
|
5
|
+
* The marker is TOML by design: human-readable, comment-friendly, and
|
|
6
|
+
* extensible without ad-hoc env parsing. The parser implemented here
|
|
7
|
+
* targets only the small subset we actually need so we ship zero
|
|
8
|
+
* third-party dependencies. If the marker grows beyond top-level scalars
|
|
9
|
+
* and a `[repo]` section, switch to a real TOML library and delete this.
|
|
10
|
+
*
|
|
11
|
+
* Required fields: `version`, `project_id`.
|
|
12
|
+
* Optional fields: `project_slug`, `speckle_url`, `[repo].remote`.
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { SpeckleRouterError } from "./errors.js";
|
|
16
|
+
const SUPPORTED_VERSIONS = new Set([1]);
|
|
17
|
+
export function parseSpeckleMarker(raw, sourcePath) {
|
|
18
|
+
const flat = parseToml(raw, sourcePath);
|
|
19
|
+
const marker = validateMarker(flat, sourcePath);
|
|
20
|
+
const contentHash = createHash("sha256").update(raw).digest("hex");
|
|
21
|
+
return { marker, contentHash, raw };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Render a marker back to canonical TOML — used by `speckle mcp init` and
|
|
25
|
+
* the project UI snippet. Keeps formatting stable so committed markers
|
|
26
|
+
* have predictable diffs.
|
|
27
|
+
*/
|
|
28
|
+
export function renderSpeckleMarker(marker) {
|
|
29
|
+
const lines = [];
|
|
30
|
+
lines.push(`version = ${marker.version}`);
|
|
31
|
+
lines.push(`project_id = ${marker.projectId}`);
|
|
32
|
+
if (marker.projectSlug)
|
|
33
|
+
lines.push(`project_slug = ${quoteString(marker.projectSlug)}`);
|
|
34
|
+
if (marker.speckleUrl)
|
|
35
|
+
lines.push(`speckle_url = ${quoteString(marker.speckleUrl)}`);
|
|
36
|
+
if (marker.repo?.remote) {
|
|
37
|
+
lines.push("");
|
|
38
|
+
lines.push("[repo]");
|
|
39
|
+
lines.push(`remote = ${quoteString(marker.repo.remote)}`);
|
|
40
|
+
}
|
|
41
|
+
return lines.join("\n") + "\n";
|
|
42
|
+
}
|
|
43
|
+
function parseToml(raw, sourcePath) {
|
|
44
|
+
const out = {};
|
|
45
|
+
let section;
|
|
46
|
+
const lines = raw.split(/\r?\n/);
|
|
47
|
+
for (let i = 0; i < lines.length; i++) {
|
|
48
|
+
const lineRaw = lines[i];
|
|
49
|
+
const line = stripComment(lineRaw).trim();
|
|
50
|
+
if (!line)
|
|
51
|
+
continue;
|
|
52
|
+
const sectionMatch = /^\[([A-Za-z0-9_]+)\]$/.exec(line);
|
|
53
|
+
if (sectionMatch) {
|
|
54
|
+
section = sectionMatch[1];
|
|
55
|
+
if (!(section in out))
|
|
56
|
+
out[section] = {};
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const kv = /^([A-Za-z0-9_]+)\s*=\s*(.+)$/.exec(line);
|
|
60
|
+
if (!kv) {
|
|
61
|
+
throw markerSyntaxError(`Unrecognized line: ${JSON.stringify(line)}`, i + 1, sourcePath);
|
|
62
|
+
}
|
|
63
|
+
const [, key, rawValue] = kv;
|
|
64
|
+
const value = parseValue(rawValue.trim(), i + 1, sourcePath);
|
|
65
|
+
if (section) {
|
|
66
|
+
out[section][key] = value;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
out[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
function stripComment(line) {
|
|
75
|
+
// Strip `#` comments unless inside a string. The marker grammar doesn't
|
|
76
|
+
// permit `#` inside strings in practice; this stays simple and explicit.
|
|
77
|
+
let inString = false;
|
|
78
|
+
for (let i = 0; i < line.length; i++) {
|
|
79
|
+
const ch = line[i];
|
|
80
|
+
if (ch === '"' && line[i - 1] !== "\\")
|
|
81
|
+
inString = !inString;
|
|
82
|
+
if (ch === "#" && !inString)
|
|
83
|
+
return line.slice(0, i);
|
|
84
|
+
}
|
|
85
|
+
return line;
|
|
86
|
+
}
|
|
87
|
+
function parseValue(src, lineNum, sourcePath) {
|
|
88
|
+
if (src.startsWith('"') && src.endsWith('"') && src.length >= 2) {
|
|
89
|
+
return unquoteString(src, lineNum, sourcePath);
|
|
90
|
+
}
|
|
91
|
+
if (src === "true")
|
|
92
|
+
return true;
|
|
93
|
+
if (src === "false")
|
|
94
|
+
return false;
|
|
95
|
+
if (/^-?\d+$/.test(src))
|
|
96
|
+
return Number.parseInt(src, 10);
|
|
97
|
+
throw markerSyntaxError(`Unsupported value: ${src}`, lineNum, sourcePath);
|
|
98
|
+
}
|
|
99
|
+
function unquoteString(src, lineNum, sourcePath) {
|
|
100
|
+
const body = src.slice(1, -1);
|
|
101
|
+
let out = "";
|
|
102
|
+
for (let i = 0; i < body.length; i++) {
|
|
103
|
+
const ch = body[i];
|
|
104
|
+
if (ch === "\\") {
|
|
105
|
+
const next = body[i + 1];
|
|
106
|
+
if (next === "\\" || next === '"') {
|
|
107
|
+
out += next;
|
|
108
|
+
i++;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (next === "n") {
|
|
112
|
+
out += "\n";
|
|
113
|
+
i++;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
throw markerSyntaxError(`Unsupported escape: \\${next}`, lineNum, sourcePath);
|
|
117
|
+
}
|
|
118
|
+
out += ch;
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
function quoteString(value) {
|
|
123
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
124
|
+
}
|
|
125
|
+
function markerSyntaxError(detail, lineNum, sourcePath) {
|
|
126
|
+
const where = sourcePath ? `${sourcePath}:${lineNum}` : `line ${lineNum}`;
|
|
127
|
+
return new SpeckleRouterError("marker_invalid", `Invalid .speckle marker at ${where}: ${detail}`, "Check the file's syntax. The marker uses TOML: top-level `key = value` pairs and an optional `[repo]` section.", { lineNum, sourcePath });
|
|
128
|
+
}
|
|
129
|
+
// ── Validation ──────────────────────────────────────────────────────────────
|
|
130
|
+
function validateMarker(flat, sourcePath) {
|
|
131
|
+
const version = flat["version"];
|
|
132
|
+
if (typeof version !== "number" || !SUPPORTED_VERSIONS.has(version)) {
|
|
133
|
+
throw new SpeckleRouterError("marker_invalid", sourcePath
|
|
134
|
+
? `.speckle at ${sourcePath} is missing or has unsupported \`version\` (got ${JSON.stringify(version)})`
|
|
135
|
+
: `.speckle is missing or has unsupported \`version\` (got ${JSON.stringify(version)})`, "Set `version = 1` at the top of the marker.");
|
|
136
|
+
}
|
|
137
|
+
const projectId = flat["project_id"];
|
|
138
|
+
if (typeof projectId !== "number" || !Number.isInteger(projectId) || projectId <= 0) {
|
|
139
|
+
throw new SpeckleRouterError("marker_invalid", `.speckle has missing or invalid \`project_id\` (got ${JSON.stringify(projectId)})`, "Set `project_id = <integer>` to the numeric Speckle project id (visible in the project URL).");
|
|
140
|
+
}
|
|
141
|
+
const projectSlug = flat["project_slug"];
|
|
142
|
+
if (projectSlug !== undefined && typeof projectSlug !== "string") {
|
|
143
|
+
throw new SpeckleRouterError("marker_invalid", `.speckle has invalid \`project_slug\` (must be a string)`, "Quote the slug, e.g. `project_slug = \"fundpilot\"`.");
|
|
144
|
+
}
|
|
145
|
+
const speckleUrl = flat["speckle_url"];
|
|
146
|
+
if (speckleUrl !== undefined && typeof speckleUrl !== "string") {
|
|
147
|
+
throw new SpeckleRouterError("marker_invalid", `.speckle has invalid \`speckle_url\` (must be a string)`, "Quote the URL, e.g. `speckle_url = \"https://speckle.workpowers.ai\"`.");
|
|
148
|
+
}
|
|
149
|
+
let repo;
|
|
150
|
+
const repoSection = flat["repo"];
|
|
151
|
+
if (repoSection !== undefined) {
|
|
152
|
+
if (typeof repoSection !== "object" || repoSection === null) {
|
|
153
|
+
throw new SpeckleRouterError("marker_invalid", `.speckle has invalid \`[repo]\` section`, "Use a TOML table: `[repo]\\nremote = \"github.com:org/repo\"`.");
|
|
154
|
+
}
|
|
155
|
+
const remote = repoSection["remote"];
|
|
156
|
+
if (remote !== undefined && typeof remote !== "string") {
|
|
157
|
+
throw new SpeckleRouterError("marker_invalid", `.speckle has invalid \`[repo].remote\` (must be a string)`, "Quote the value, e.g. `remote = \"github.com:org/repo\"`.");
|
|
158
|
+
}
|
|
159
|
+
repo = remote ? { remote } : undefined;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
version,
|
|
163
|
+
projectId,
|
|
164
|
+
projectSlug: projectSlug,
|
|
165
|
+
speckleUrl: speckleUrl,
|
|
166
|
+
repo,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker.js","sourceRoot":"","sources":["../src/marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAoBjD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAExC,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,UAAmB;IACjE,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAqB;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1C,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,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AC3D,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QACD,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACzC,CAAC;IAED,OAAO;QACL,OAAO;QACP,SAAS;QACT,WAAW,EAAE,WAAiC;QAC9C,UAAU,EAAE,UAAgC;QAC5C,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/dist/proxy.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transparent MCP proxy wiring.
|
|
3
|
+
*
|
|
4
|
+
* The router exposes an MCP server over stdio (the agent connects to it) and
|
|
5
|
+
* forwards each method to a single upstream MCP client connected to Speckle's
|
|
6
|
+
* remote `/mcp` endpoint. Each forwardable method is registered explicitly —
|
|
7
|
+
* we do not pretend to be a general-purpose MCP proxy. This keeps the seam
|
|
8
|
+
* narrow and easy to reason about.
|
|
9
|
+
*
|
|
10
|
+
* Important: do not hardcode tool schemas here. `tools/list` should return
|
|
11
|
+
* whatever the upstream server reports, so adding `speckle_inform_v2` or a
|
|
12
|
+
* new spec-branch tool on the server does not require a router release.
|
|
13
|
+
*/
|
|
14
|
+
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
15
|
+
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
16
|
+
import { type ServerCapabilities } from "@modelcontextprotocol/sdk/types.js";
|
|
17
|
+
export declare function wireProxyHandlers(server: Server, client: Client, capabilities: ServerCapabilities): void;
|
|
18
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EASL,KAAK,kBAAkB,EACxB,MAAM,oCAAoC,CAAC;AAE5C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,GAAG,IAAI,CAoCxG"}
|
package/dist/proxy.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transparent MCP proxy wiring.
|
|
3
|
+
*
|
|
4
|
+
* The router exposes an MCP server over stdio (the agent connects to it) and
|
|
5
|
+
* forwards each method to a single upstream MCP client connected to Speckle's
|
|
6
|
+
* remote `/mcp` endpoint. Each forwardable method is registered explicitly —
|
|
7
|
+
* we do not pretend to be a general-purpose MCP proxy. This keeps the seam
|
|
8
|
+
* narrow and easy to reason about.
|
|
9
|
+
*
|
|
10
|
+
* Important: do not hardcode tool schemas here. `tools/list` should return
|
|
11
|
+
* whatever the upstream server reports, so adding `speckle_inform_v2` or a
|
|
12
|
+
* new spec-branch tool on the server does not require a router release.
|
|
13
|
+
*/
|
|
14
|
+
import { CallToolRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, PingRequestSchema, ReadResourceRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
15
|
+
export function wireProxyHandlers(server, client, capabilities) {
|
|
16
|
+
// Ping is always available — agents use it to keep the link alive.
|
|
17
|
+
server.setRequestHandler(PingRequestSchema, async () => {
|
|
18
|
+
await client.ping();
|
|
19
|
+
return {};
|
|
20
|
+
});
|
|
21
|
+
if (capabilities.tools !== undefined) {
|
|
22
|
+
server.setRequestHandler(ListToolsRequestSchema, async (req) => {
|
|
23
|
+
return await client.listTools(req.params);
|
|
24
|
+
});
|
|
25
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
26
|
+
return await client.callTool(req.params);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (capabilities.prompts !== undefined) {
|
|
30
|
+
server.setRequestHandler(ListPromptsRequestSchema, async (req) => {
|
|
31
|
+
return await client.listPrompts(req.params);
|
|
32
|
+
});
|
|
33
|
+
server.setRequestHandler(GetPromptRequestSchema, async (req) => {
|
|
34
|
+
return await client.getPrompt(req.params);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (capabilities.resources !== undefined) {
|
|
38
|
+
server.setRequestHandler(ListResourcesRequestSchema, async (req) => {
|
|
39
|
+
return await client.listResources(req.params);
|
|
40
|
+
});
|
|
41
|
+
server.setRequestHandler(ListResourceTemplatesRequestSchema, async (req) => {
|
|
42
|
+
return await client.listResourceTemplates(req.params);
|
|
43
|
+
});
|
|
44
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (req) => {
|
|
45
|
+
return await client.readResource(req.params);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kCAAkC,EAClC,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,MAAc,EAAE,YAAgC;IAChG,mEAAmE;IACnE,MAAM,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,IAAI,YAAY,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7D,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C,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":""}
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct entry — `tsx plugins/speckle-mcp/src/run.ts` boots the stdio router.
|
|
3
|
+
*
|
|
4
|
+
* Used by the in-repo `.mcp.json` during development. A future build step
|
|
5
|
+
* will emit a plain-Node `dist/` and the published `bin/speckle-mcp.mjs`
|
|
6
|
+
* will route through that; this file remains the canonical source of the
|
|
7
|
+
* one-line entry shape.
|
|
8
|
+
*/
|
|
9
|
+
import { startRouter, reportFatal } from "./index.js";
|
|
10
|
+
startRouter().catch((err) => {
|
|
11
|
+
reportFatal(err);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC1B,WAAW,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace resolution for the local Speckle MCP router.
|
|
3
|
+
*
|
|
4
|
+
* Given a starting directory (the active workspace root, or process cwd as
|
|
5
|
+
* fallback), walks upward to find the nearest `.speckle` marker. Optionally
|
|
6
|
+
* cross-checks the marker's declared repo remote against the current
|
|
7
|
+
* checkout's canonicalized origin URL.
|
|
8
|
+
*
|
|
9
|
+
* No filesystem mutation. No network. Pure resolution + diagnostics.
|
|
10
|
+
*/
|
|
11
|
+
import { type ParsedMarker } from "./marker.js";
|
|
12
|
+
export interface ResolvedWorkspace {
|
|
13
|
+
/** Absolute path to the workspace root that owned the marker. */
|
|
14
|
+
workspaceRoot: string;
|
|
15
|
+
/** Absolute path to the `.speckle` file we read. */
|
|
16
|
+
markerPath: string;
|
|
17
|
+
/** Parsed marker with content hash. */
|
|
18
|
+
marker: ParsedMarker;
|
|
19
|
+
/** SHA-256 of the workspace root path (avoids logging absolute paths). */
|
|
20
|
+
workspaceRootHash: string;
|
|
21
|
+
/** Canonical origin remote if discoverable from git config. */
|
|
22
|
+
canonicalRemote?: string;
|
|
23
|
+
/** mtime ms of the marker file, used for cache invalidation. */
|
|
24
|
+
markerMtimeMs: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ResolveOptions {
|
|
27
|
+
/** Workspace root candidates, in priority order. Empty → fall back to `cwd`. */
|
|
28
|
+
workspaceRoots?: string[];
|
|
29
|
+
/** Override cwd for testing. */
|
|
30
|
+
cwd?: string;
|
|
31
|
+
/** Allow remote-mismatch via env (default off). */
|
|
32
|
+
allowRepoMismatch?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function resolveWorkspace(opts?: ResolveOptions): ResolvedWorkspace;
|
|
35
|
+
/**
|
|
36
|
+
* Canonical form: `host:org/repo` (lowercase host, no trailing `.git`,
|
|
37
|
+
* no protocol prefix, no `git@` user).
|
|
38
|
+
*
|
|
39
|
+
* https://github.com/x/y.git → github.com:x/y
|
|
40
|
+
* git@github.com:x/y.git → github.com:x/y
|
|
41
|
+
* ssh://git@github.com/x/y → github.com:x/y
|
|
42
|
+
* github.com/x/y → github.com:x/y
|
|
43
|
+
*/
|
|
44
|
+
export declare function canonicalizeGitRemote(remote: string): string | undefined;
|
|
45
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,EAAE,YAAY,CAAC;IACrB,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;CACvB;AAID,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,cAAmB,GAAG,iBAAiB,CA8D7E;AA0CD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiCxE"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace resolution for the local Speckle MCP router.
|
|
3
|
+
*
|
|
4
|
+
* Given a starting directory (the active workspace root, or process cwd as
|
|
5
|
+
* fallback), walks upward to find the nearest `.speckle` marker. Optionally
|
|
6
|
+
* cross-checks the marker's declared repo remote against the current
|
|
7
|
+
* checkout's canonicalized origin URL.
|
|
8
|
+
*
|
|
9
|
+
* No filesystem mutation. No network. Pure resolution + diagnostics.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { execFileSync } from "node:child_process";
|
|
14
|
+
import { SpeckleRouterError } from "./errors.js";
|
|
15
|
+
import { parseSpeckleMarker } from "./marker.js";
|
|
16
|
+
const MARKER_FILENAME = ".speckle";
|
|
17
|
+
export function resolveWorkspace(opts = {}) {
|
|
18
|
+
const roots = (opts.workspaceRoots ?? []).filter(Boolean);
|
|
19
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
20
|
+
const candidates = roots.length > 0 ? roots : [cwd];
|
|
21
|
+
// Resolve a marker per candidate root, then ensure they all agree.
|
|
22
|
+
const found = candidates.map((root) => ({
|
|
23
|
+
root: path.resolve(root),
|
|
24
|
+
marker: findMarkerUpwards(path.resolve(root)),
|
|
25
|
+
}));
|
|
26
|
+
const missing = found.filter((f) => !f.marker);
|
|
27
|
+
if (missing.length === found.length) {
|
|
28
|
+
throw new SpeckleRouterError("marker_not_found", "Speckle project context was not found for this workspace.", "Add a committed `.speckle` file at your repo root, or run `speckle mcp init --project <id>`.", { searched: candidates });
|
|
29
|
+
}
|
|
30
|
+
// If multiple roots provided some markers, every root that resolved must
|
|
31
|
+
// point at the same project. Different projects across roots is fail-closed.
|
|
32
|
+
const resolved = found.filter((f) => f.marker);
|
|
33
|
+
const distinctProjectIds = new Set(resolved.map((f) => f.marker.parsed.marker.projectId));
|
|
34
|
+
if (distinctProjectIds.size > 1) {
|
|
35
|
+
throw new SpeckleRouterError("workspace_ambiguous", "This workspace contains multiple .speckle markers pointing at different Speckle projects.", "Open a single project's repo per MCP session, or remove the ambiguous markers.", { projectIds: [...distinctProjectIds] });
|
|
36
|
+
}
|
|
37
|
+
const chosen = resolved[0];
|
|
38
|
+
const repoRemote = chosen.marker.parsed.marker.repo?.remote;
|
|
39
|
+
let canonicalRemote;
|
|
40
|
+
if (repoRemote) {
|
|
41
|
+
const actual = readGitOriginRemote(chosen.root);
|
|
42
|
+
canonicalRemote = actual ? canonicalizeGitRemote(actual) : undefined;
|
|
43
|
+
const expected = canonicalizeGitRemote(repoRemote);
|
|
44
|
+
if (canonicalRemote && expected && canonicalRemote !== expected && !opts.allowRepoMismatch) {
|
|
45
|
+
throw new SpeckleRouterError("marker_remote_mismatch", `.speckle belongs to ${expected}, but this checkout appears to be ${canonicalRemote}.`, "If this is intentional, set SPECKLE_MCP_ALLOW_REPO_MISMATCH=1 to bypass.", { expected, actual: canonicalRemote, markerPath: chosen.marker.markerPath });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
workspaceRoot: chosen.root,
|
|
50
|
+
markerPath: chosen.marker.markerPath,
|
|
51
|
+
marker: chosen.marker.parsed,
|
|
52
|
+
workspaceRootHash: chosen.marker.workspaceRootHash,
|
|
53
|
+
canonicalRemote,
|
|
54
|
+
markerMtimeMs: chosen.marker.markerMtimeMs,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function findMarkerUpwards(start) {
|
|
58
|
+
let dir = start;
|
|
59
|
+
for (;;) {
|
|
60
|
+
const candidate = path.join(dir, MARKER_FILENAME);
|
|
61
|
+
if (existsSync(candidate)) {
|
|
62
|
+
const raw = readFileSync(candidate, "utf8");
|
|
63
|
+
const parsed = parseSpeckleMarker(raw, candidate);
|
|
64
|
+
const stat = statSync(candidate);
|
|
65
|
+
return {
|
|
66
|
+
parsed,
|
|
67
|
+
markerPath: candidate,
|
|
68
|
+
workspaceRootHash: hashPath(dir),
|
|
69
|
+
markerMtimeMs: stat.mtimeMs,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const parent = path.dirname(dir);
|
|
73
|
+
if (parent === dir)
|
|
74
|
+
return undefined;
|
|
75
|
+
dir = parent;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function readGitOriginRemote(repoRoot) {
|
|
79
|
+
try {
|
|
80
|
+
const out = execFileSync("git", ["-C", repoRoot, "remote", "get-url", "origin"], {
|
|
81
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
82
|
+
encoding: "utf8",
|
|
83
|
+
});
|
|
84
|
+
return out.trim() || undefined;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Canonical form: `host:org/repo` (lowercase host, no trailing `.git`,
|
|
92
|
+
* no protocol prefix, no `git@` user).
|
|
93
|
+
*
|
|
94
|
+
* https://github.com/x/y.git → github.com:x/y
|
|
95
|
+
* git@github.com:x/y.git → github.com:x/y
|
|
96
|
+
* ssh://git@github.com/x/y → github.com:x/y
|
|
97
|
+
* github.com/x/y → github.com:x/y
|
|
98
|
+
*/
|
|
99
|
+
export function canonicalizeGitRemote(remote) {
|
|
100
|
+
const s = remote.trim();
|
|
101
|
+
if (!s)
|
|
102
|
+
return undefined;
|
|
103
|
+
// URL form: `https://`, `http://`, `ssh://`, `git://`. Protocol implies
|
|
104
|
+
// `:port` semantics on the host segment.
|
|
105
|
+
const urlMatch = /^(?:https?|ssh|git):\/\/(.+)$/i.exec(s);
|
|
106
|
+
if (urlMatch) {
|
|
107
|
+
const rest = urlMatch[1].replace(/^[^@/]+@/, "");
|
|
108
|
+
const slashIdx = rest.indexOf("/");
|
|
109
|
+
if (slashIdx < 0)
|
|
110
|
+
return undefined;
|
|
111
|
+
const host = rest.slice(0, slashIdx).replace(/:\d+$/, "").toLowerCase();
|
|
112
|
+
const pathPart = trimPath(rest.slice(slashIdx + 1));
|
|
113
|
+
return host && pathPart ? `${host}:${pathPart}` : undefined;
|
|
114
|
+
}
|
|
115
|
+
// scp form: `[user@]host:path` (the colon is the host/path separator).
|
|
116
|
+
const scp = /^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(s);
|
|
117
|
+
if (scp) {
|
|
118
|
+
const host = scp[1].toLowerCase();
|
|
119
|
+
const pathPart = trimPath(scp[2]);
|
|
120
|
+
return host && pathPart ? `${host}:${pathPart}` : undefined;
|
|
121
|
+
}
|
|
122
|
+
// Bare `host/path` form.
|
|
123
|
+
const slashIdx = s.indexOf("/");
|
|
124
|
+
if (slashIdx > 0) {
|
|
125
|
+
const host = s.slice(0, slashIdx).toLowerCase();
|
|
126
|
+
const pathPart = trimPath(s.slice(slashIdx + 1));
|
|
127
|
+
return host && pathPart ? `${host}:${pathPart}` : undefined;
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
function trimPath(p) {
|
|
132
|
+
return p.replace(/^\/+/, "").replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
133
|
+
}
|
|
134
|
+
import { createHash } from "node:crypto";
|
|
135
|
+
function hashPath(p) {
|
|
136
|
+
return createHash("sha256").update(p).digest("hex");
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAqB,MAAM,aAAa,CAAC;AAiBpE,MAAM,eAAe,GAAG,UAAU,CAAC;AAWnC,MAAM,UAAU,gBAAgB,CAAC,OAAuB,EAAE;IACxD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEpD,mEAAmE;IACnE,MA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CAAC,SAAS,CAAC;IAC9D,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@workpowers/speckle",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local MCP router for Speckle — resolves project context from a committed .speckle marker and forwards calls to the remote Speckle MCP endpoint.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"speckle-mcp": "./bin/speckle-mcp.mjs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"test": "vitest run"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.27.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^22.10.5",
|
|
26
|
+
"typescript": "^5.6.0",
|
|
27
|
+
"vitest": "^4.0.0"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=20"
|
|
31
|
+
},
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/workpowers/speckle.git",
|
|
36
|
+
"directory": "plugins/speckle-mcp"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://speckle.workpowers.ai",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"mcp",
|
|
44
|
+
"model-context-protocol",
|
|
45
|
+
"speckle",
|
|
46
|
+
"workpowers"
|
|
47
|
+
]
|
|
48
|
+
}
|