@ctruhtech/verse-mcp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/http.d.ts +9 -0
- package/dist/http.js +11 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.js +26 -8
- package/dist/util.js +3 -2
- package/package.json +1 -1
- package/server.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- Hosted (Streamable HTTP) servers hand the agent links on their public origin (`publicBaseUrl`, derived from `X-Forwarded-Proto` / `X-Forwarded-Host` by default), never the API loopback.
|
|
6
|
+
- The hosted server's instructions no longer mention local file paths.
|
|
7
|
+
- Messages start with a capital and read as one sentence; a vowel kind gets "an"; upload progress never steps back.
|
|
8
|
+
|
|
3
9
|
## 0.1.0
|
|
4
10
|
|
|
5
11
|
First release.
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
package/dist/http.d.ts
CHANGED
|
@@ -8,7 +8,16 @@ export interface HttpHandlerOptions {
|
|
|
8
8
|
pollIntervalMs?: number;
|
|
9
9
|
/** Called once per JSON-RPC `tools/call` with the tool name (a short label), for adoption counters. Never receives arguments. */
|
|
10
10
|
onToolCall?: (tool: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* The origin written into links handed to the agent. A string, or a
|
|
13
|
+
* function of the request (default: the request's own public origin from
|
|
14
|
+
* X-Forwarded-Proto / X-Forwarded-Host / Host, so a server reached through
|
|
15
|
+
* an edge still writes links on its public address).
|
|
16
|
+
*/
|
|
17
|
+
publicBaseUrl?: string | ((req: IncomingMessage) => string | undefined);
|
|
11
18
|
}
|
|
19
|
+
/** The public origin a request arrived on, as the edge reports it. */
|
|
20
|
+
export declare function requestOrigin(req: IncomingMessage): string | undefined;
|
|
12
21
|
/** Credentials from the request headers; the caller's own key, never stored or logged. */
|
|
13
22
|
export declare function credentialsFromRequest(req: IncomingMessage): Credentials;
|
|
14
23
|
/**
|
package/dist/http.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
2
|
import { classifyKey } from "./config.js";
|
|
3
3
|
import { createVerseServer } from "./server.js";
|
|
4
|
+
/** The public origin a request arrived on, as the edge reports it. */
|
|
5
|
+
export function requestOrigin(req) {
|
|
6
|
+
const first = (v) => String(v ?? "").split(",")[0].trim();
|
|
7
|
+
const host = first(req.headers["x-forwarded-host"]) || first(req.headers["host"]);
|
|
8
|
+
if (!host)
|
|
9
|
+
return undefined;
|
|
10
|
+
const proto = first(req.headers["x-forwarded-proto"]) || "http";
|
|
11
|
+
return `${proto}://${host}`;
|
|
12
|
+
}
|
|
4
13
|
const send = (res, status, body, headers = {}) => {
|
|
5
14
|
res.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store", ...headers });
|
|
6
15
|
res.end(JSON.stringify(body));
|
|
@@ -56,7 +65,8 @@ export function createHttpHandler(o) {
|
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
|
-
const
|
|
68
|
+
const publicBaseUrl = (typeof o.publicBaseUrl === "function" ? o.publicBaseUrl(req) : o.publicBaseUrl) || requestOrigin(req) || o.baseUrl;
|
|
69
|
+
const server = createVerseServer({ baseUrl: o.baseUrl, credentials: creds, allowLocalFiles: false, fetch: o.fetch, pollIntervalMs: o.pollIntervalMs, publicBaseUrl });
|
|
60
70
|
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: false });
|
|
61
71
|
res.on("close", () => {
|
|
62
72
|
void transport.close();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createVerseServer, type ServerOptions } from "./server.js";
|
|
2
|
-
export { createHttpHandler, type HttpHandlerOptions } from "./http.js";
|
|
2
|
+
export { createHttpHandler, requestOrigin, type HttpHandlerOptions } from "./http.js";
|
|
3
3
|
export { classifyKey, credentialsFromEnv, baseUrlFromEnv, VERSION, DEFAULT_BASE_URL } from "./config.js";
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -8,5 +8,11 @@ export interface ServerOptions {
|
|
|
8
8
|
fetch?: typeof fetch;
|
|
9
9
|
/** Poll interval override (tests). */
|
|
10
10
|
pollIntervalMs?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The origin links are written with, when it differs from `baseUrl`: a
|
|
13
|
+
* hosted server talks to its own API over loopback but must hand the
|
|
14
|
+
* agent links on its public address. Default `baseUrl`.
|
|
15
|
+
*/
|
|
16
|
+
publicBaseUrl?: string;
|
|
11
17
|
}
|
|
12
18
|
export declare function createVerseServer(opts: ServerOptions): McpServer;
|
package/dist/server.js
CHANGED
|
@@ -7,22 +7,39 @@ import { basename, resolve } from "node:path";
|
|
|
7
7
|
import { VerseError } from "@ctruhtech/verse-sdk";
|
|
8
8
|
import { VERSION, makeClient } from "./config.js";
|
|
9
9
|
import { ToolError, plainError, sceneIdOf } from "./util.js";
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const instructionsFor = (localFiles) => "Verse turns 3D files (GLB, glTF, FBX, OBJ, IFC, USD/USDZ, PLY, SPLAT, SPZ-class captures, point clouds) into a shareable link that opens in any browser, with no app and no plugin. " +
|
|
11
|
+
(localFiles
|
|
12
|
+
? "Use upload_scene with a local file path or a public URL, then share the returned link or call get_embed_code for an iframe. "
|
|
13
|
+
: "Use upload_scene with a public http(s) URL (this hosted server cannot read local files), then share the returned link or call get_embed_code for an iframe. ") +
|
|
12
14
|
"Owner actions (list_scenes, visibility, private share links, camera paths) need the user's Verse account token in VERSE_API_KEY. " +
|
|
13
15
|
"Builds can take a minute or more for large files; if upload_scene returns before the build is done, poll get_scene_status.";
|
|
14
16
|
const sceneArg = z.string().min(3).max(600).describe("Scene id (e.g. palm-villa-0a1b2c3d4e5f), the job id returned by upload_scene, or a Verse share link.");
|
|
15
17
|
const KINDS = ["splat", "cloud", "ifc", "usd", "fbx", "obj"];
|
|
16
|
-
const
|
|
18
|
+
const okRaw = (text, data) => ({ content: [{ type: "text", text }], ...(data ? { structuredContent: data } : {}) });
|
|
17
19
|
export function createVerseServer(opts) {
|
|
18
20
|
const client = makeClient(opts.baseUrl, opts.credentials, opts.fetch);
|
|
19
21
|
if (opts.pollIntervalMs)
|
|
20
22
|
client.pollIntervalMs = opts.pollIntervalMs;
|
|
21
23
|
const hasAccount = !!opts.credentials.token;
|
|
22
|
-
const server = new McpServer({ name: "verse", version: VERSION }, { instructions:
|
|
24
|
+
const server = new McpServer({ name: "verse", version: VERSION }, { instructions: instructionsFor(opts.allowLocalFiles) });
|
|
25
|
+
const apiBase = opts.baseUrl.replace(/\/+$/, "");
|
|
26
|
+
const linkBase = (opts.publicBaseUrl || apiBase).replace(/\/+$/, "");
|
|
27
|
+
/** Rewrite the API origin to the public one in anything handed to the agent. */
|
|
28
|
+
const pub = (v) => {
|
|
29
|
+
if (linkBase === apiBase || v == null)
|
|
30
|
+
return v;
|
|
31
|
+
if (typeof v === "string")
|
|
32
|
+
return v.split(apiBase).join(linkBase);
|
|
33
|
+
if (Array.isArray(v))
|
|
34
|
+
return v.map(pub);
|
|
35
|
+
if (typeof v === "object")
|
|
36
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, pub(x)]));
|
|
37
|
+
return v;
|
|
38
|
+
};
|
|
39
|
+
const ok = (text, data) => okRaw(pub(text), data ? pub(data) : undefined);
|
|
23
40
|
const needAccount = (what) => {
|
|
24
41
|
if (!hasAccount)
|
|
25
|
-
throw new ToolError(`${what} needs a Verse key; set VERSE_API_KEY to an API key from your Account page (${
|
|
42
|
+
throw new ToolError(`${what} needs a Verse key; set VERSE_API_KEY to an API key from your Account page (${linkBase}/account, "API keys") or your account token.`);
|
|
26
43
|
};
|
|
27
44
|
/** Wrap a handler: any failure becomes one plain sentence with isError. */
|
|
28
45
|
const guard = (fn) => async (args, extra) => {
|
|
@@ -59,8 +76,8 @@ export function createVerseServer(opts) {
|
|
|
59
76
|
return async (progress, total, message) => {
|
|
60
77
|
if (token === undefined || token === null)
|
|
61
78
|
return;
|
|
62
|
-
if (progress
|
|
63
|
-
return;
|
|
79
|
+
if (progress <= last)
|
|
80
|
+
return; // never report a step backwards
|
|
64
81
|
last = progress;
|
|
65
82
|
try {
|
|
66
83
|
await extra.sendNotification({ method: "notifications/progress", params: { progressToken: token, progress, total, message } });
|
|
@@ -357,7 +374,8 @@ export function createVerseServer(opts) {
|
|
|
357
374
|
const r = await client.request(`/v1/scenes/${encodeURIComponent(id)}/paths/auto`, { method: "POST", retries: 0 });
|
|
358
375
|
const base = linkOf(await resolveScene(id));
|
|
359
376
|
const tourLink = `${base}${base.includes("?") ? "&" : "?"}autoplay=path`;
|
|
360
|
-
|
|
377
|
+
const article = /^[aeiou]/i.test(String(r.kind)) ? "an" : "a";
|
|
378
|
+
return ok(`Planned ${article} ${r.kind} tour "${r.name}" (${r.keys.length} keys). Tour link: ${tourLink}`, { scene: id, pathId: r.id, kind: r.kind, tourLink });
|
|
361
379
|
}));
|
|
362
380
|
return server;
|
|
363
381
|
}
|
package/dist/util.js
CHANGED
|
@@ -15,7 +15,8 @@ export class ToolError extends Error {
|
|
|
15
15
|
}
|
|
16
16
|
const sentence = (s) => {
|
|
17
17
|
const t = s.replace(/\s+/g, " ").trim();
|
|
18
|
-
|
|
18
|
+
const cap = t.charAt(0).toUpperCase() + t.slice(1);
|
|
19
|
+
return /[.!?]$/.test(cap) ? cap : `${cap}.`;
|
|
19
20
|
};
|
|
20
21
|
/** One plain sentence for any failure; never includes credentials. */
|
|
21
22
|
export function plainError(e, hasAccount) {
|
|
@@ -23,7 +24,7 @@ export function plainError(e, hasAccount) {
|
|
|
23
24
|
return sentence(e.message);
|
|
24
25
|
if (e instanceof VerseError) {
|
|
25
26
|
if (e.status === 401 && !hasAccount)
|
|
26
|
-
return "Uploading needs a free Verse account
|
|
27
|
+
return "Uploading needs a free Verse account: sign up at verse.ctruh.com/signin, create an API key on your Account page and set it as VERSE_API_KEY.";
|
|
27
28
|
if (e.status === 401)
|
|
28
29
|
return "The server rejected the Verse credential; check VERSE_API_KEY.";
|
|
29
30
|
if (e.status === 404 && e.code !== "unknown_job" && !hasAccount)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctruhtech/verse-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server for Verse: let Claude, ChatGPT, Cursor and other AI agents turn 3D files into shareable, embeddable Verse links. stdio and Streamable HTTP.",
|
|
5
5
|
"homepage": "https://verse.ctruh.com/docs/#/mcp",
|
|
6
6
|
"repository": {
|
package/server.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"name": "io.github.dev-vinayagastya/verse-mcp",
|
|
4
4
|
"title": "Verse",
|
|
5
5
|
"description": "Turn 3D files into shareable, embeddable Verse links from any AI assistant.",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.1",
|
|
7
7
|
"repository": { "url": "https://github.com/dev-vinayagastya/verse-mcp", "source": "github" },
|
|
8
8
|
"packages": [
|
|
9
9
|
{
|
|
10
10
|
"registryType": "npm",
|
|
11
11
|
"identifier": "@ctruhtech/verse-mcp",
|
|
12
|
-
"version": "0.1.
|
|
12
|
+
"version": "0.1.1",
|
|
13
13
|
"transport": { "type": "stdio" },
|
|
14
14
|
"environmentVariables": [
|
|
15
15
|
{ "name": "VERSE_API_KEY", "description": "Your Verse API key (Account page, API keys card) or account token. Sent as Authorization: Bearer.", "isRequired": true, "isSecret": true }
|