mcp-use 2.0.0-beta.8 → 2.0.0-beta.9
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/.tsbuildinfo +1 -1
- package/dist/branding.d.ts +85 -0
- package/dist/branding.d.ts.map +1 -0
- package/dist/{chunk-FCGJJVL2.js → chunk-GTOOHAI2.js} +2 -1
- package/dist/chunk-GTOOHAI2.js.map +1 -0
- package/dist/{public-route-26FUVRO5.js → chunk-SMN75YED.js} +12 -8
- package/dist/chunk-SMN75YED.js.map +1 -0
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/commands/build.js +8 -4
- package/dist/commands/build.js.map +1 -1
- package/dist/config.d.ts +69 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +338 -19
- package/dist/index.js.map +1 -1
- package/dist/inspector-shell.d.ts +3 -0
- package/dist/inspector-shell.d.ts.map +1 -1
- package/dist/{landing-handler-VQRYCQOV.js → landing-handler-3VN4BMR2.js} +6 -3
- package/dist/landing-handler-3VN4BMR2.js.map +1 -0
- package/dist/landing-handler.d.ts +3 -1
- package/dist/landing-handler.d.ts.map +1 -1
- package/dist/landing.d.ts.map +1 -1
- package/dist/landing.js +1 -1
- package/dist/public-route-5JEGFEIN.js +9 -0
- package/dist/public-route-5JEGFEIN.js.map +1 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/views/public-route.d.ts +3 -1
- package/dist/views/public-route.d.ts.map +1 -1
- package/dist/views/routes.d.ts +3 -1
- package/dist/views/routes.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-FCGJJVL2.js.map +0 -1
- package/dist/landing-handler-VQRYCQOV.js.map +0 -1
- package/dist/public-route-26FUVRO5.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Icon } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { FetchHandler } from "./fetch-app.js";
|
|
3
|
+
/** Normalized server branding shared by browser and MCP identity surfaces. */
|
|
4
|
+
export interface ServerBranding {
|
|
5
|
+
/**
|
|
6
|
+
* Source selected for `/favicon.ico`, after applying explicit-favicon and
|
|
7
|
+
* icon-ranking precedence.
|
|
8
|
+
*/
|
|
9
|
+
readonly favicon?: string;
|
|
10
|
+
/** Icons reported in MCP implementation metadata, in author order. */
|
|
11
|
+
readonly icons?: readonly Icon[];
|
|
12
|
+
/** Server website reported in MCP implementation metadata. */
|
|
13
|
+
readonly websiteUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
interface NormalizedServerBranding extends ServerBranding {
|
|
16
|
+
readonly faviconMimeType?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Select the browser favicon from an ordered set of MCP icons.
|
|
20
|
+
*
|
|
21
|
+
* Ranking is deterministic: ICO, 16x16/32x32 PNG, any PNG, then the first
|
|
22
|
+
* icon. MIME declarations and URL pathnames participate alongside filename
|
|
23
|
+
* suffixes, so absolute URLs with queries and data URLs rank correctly.
|
|
24
|
+
*
|
|
25
|
+
* @param icons - Validated, non-empty icon list.
|
|
26
|
+
* @returns The selected icon.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export declare function selectFaviconFromIcons(icons: readonly Icon[]): Icon | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Validate and freeze the branding fields from server configuration.
|
|
33
|
+
*
|
|
34
|
+
* @param config - Untyped-compatible branding input.
|
|
35
|
+
* @returns Immutable normalized branding and the selected favicon MIME type.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeServerBranding(config: {
|
|
40
|
+
favicon?: unknown;
|
|
41
|
+
icons?: unknown;
|
|
42
|
+
websiteUrl?: unknown;
|
|
43
|
+
}): NormalizedServerBranding;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve configured icons for MCP implementation metadata.
|
|
46
|
+
*
|
|
47
|
+
* Absolute HTTP(S) and data URLs pass through. Public-relative sources become
|
|
48
|
+
* request-scoped absolute URLs under `${basePath}/_mcp-use/public/`.
|
|
49
|
+
*
|
|
50
|
+
* @param icons - Normalized configured icons.
|
|
51
|
+
* @param request - HTTP request used to derive the public asset origin.
|
|
52
|
+
* @param basePath - MCP endpoint base path.
|
|
53
|
+
* @returns Icons suitable for the official SDK `Implementation` object.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveImplementationIcons(icons: readonly Icon[] | undefined, request: Request | undefined, basePath: string): Icon[] | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Whether any configured branding source needs the local public route.
|
|
60
|
+
*
|
|
61
|
+
* @param branding - Normalized branding to inspect.
|
|
62
|
+
* @returns `true` when the favicon or an MCP icon uses a `public/` path.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export declare function hasLocalBrandingAsset(branding: ServerBranding): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Create the root-level `/favicon.ico` handler for normalized branding.
|
|
69
|
+
*
|
|
70
|
+
* Local public files and data URLs are streamed directly. Absolute HTTP(S)
|
|
71
|
+
* sources receive a temporary redirect, avoiding server-side remote fetches.
|
|
72
|
+
*
|
|
73
|
+
* @param branding - Normalized server branding.
|
|
74
|
+
* @param options - Public directory resolution mode.
|
|
75
|
+
* @returns A GET/HEAD handler, or `undefined` when no favicon is configured.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare function createFaviconHandler(branding: NormalizedServerBranding, options: {
|
|
80
|
+
dev: boolean;
|
|
81
|
+
projectRoot: string;
|
|
82
|
+
deferCors?: boolean;
|
|
83
|
+
}): FetchHandler | undefined;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=branding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branding.d.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M,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAClE,YAAY,GAAG,SAAS,CAgE1B"}
|
|
@@ -257,6 +257,7 @@ function generateLandingPage(options) {
|
|
|
257
257
|
<meta name="twitter:card" content="summary">
|
|
258
258
|
<meta name="twitter:title" content="${pageTitle}">
|
|
259
259
|
<meta name="twitter:description" content="${metaDescription}">
|
|
260
|
+
${iconUrl ? `<link rel="icon" href="${escapeHtml(iconUrl)}">` : ""}
|
|
260
261
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
261
262
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
262
263
|
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
@@ -736,4 +737,4 @@ a:hover { text-decoration: underline; }
|
|
|
736
737
|
export {
|
|
737
738
|
generateLandingPage
|
|
738
739
|
};
|
|
739
|
-
//# sourceMappingURL=chunk-
|
|
740
|
+
//# sourceMappingURL=chunk-GTOOHAI2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/landing.ts"],"sourcesContent":["/**\n * Landing page generator for MCP server endpoints\n *\n * Generates SEO-friendly HTML with connection instructions for MCP servers\n * from Claude Code, Cursor, VS Code, ChatGPT, and Manufact Inspector (hosted).\n */\n\n/**\n * Escapes HTML special characters to prevent XSS in user-provided content.\n */\nfunction escapeHtml(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\n/** Serialize data for an inline JSON script without creating an HTML end tag. */\nfunction serializeScriptJson(value: unknown): string {\n return JSON.stringify(value)\n .replace(/</g, \"\\\\u003c\")\n .replace(/>/g, \"\\\\u003e\");\n}\n\n/**\n * Sanitizes a server name for use in filenames and URLs.\n * Replaces non-alphanumeric characters with underscores and converts to lowercase.\n */\nfunction sanitizeServerName(name: string): string {\n return name.replace(/[^a-zA-Z0-9-_]/g, \"_\").toLowerCase();\n}\n\n/**\n * Generates a Cursor deep link for installing an MCP server.\n * The config is base64-encoded JSON containing the server URL.\n */\nfunction generateCursorDeepLink(url: string, name: string): string {\n const config = { url };\n const configJson = JSON.stringify(config);\n\n // Use Buffer in Node.js or btoa in browser-like environments\n const base64Config =\n typeof Buffer !== \"undefined\"\n ? Buffer.from(configJson).toString(\"base64\")\n : btoa(configJson);\n\n const sanitizedName = sanitizeServerName(name);\n return `cursor://anysphere.cursor-deeplink/mcp/install?config=${encodeURIComponent(base64Config)}&name=${encodeURIComponent(sanitizedName)}`;\n}\n\n/**\n * Generates a VS Code deep link for installing an MCP server.\n * The config is URL-encoded JSON containing the server URL.\n */\nfunction generateVSCodeDeepLink(url: string, name: string): string {\n const config = {\n url,\n name: sanitizeServerName(name),\n type: \"http\",\n };\n const configJson = JSON.stringify(config);\n const urlEncodedConfig = encodeURIComponent(configJson);\n return `vscode:mcp/install?${urlEncodedConfig}`;\n}\n\n/**\n * Generates a VS Code Insiders deep link for installing an MCP server.\n * The config is URL-encoded JSON containing the server URL.\n */\nfunction generateVSCodeInsidersDeepLink(url: string, name: string): string {\n const config = {\n url,\n name: sanitizeServerName(name),\n type: \"http\",\n };\n const configJson = JSON.stringify(config);\n const urlEncodedConfig = encodeURIComponent(configJson);\n return `vscode-insiders:mcp/install?${urlEncodedConfig}`;\n}\n\n/**\n * Generates a Claude Code CLI command for adding an MCP server.\n */\nfunction generateClaudeCommand(url: string, name: string): string {\n const sanitizedName = sanitizeServerName(name);\n const quotedUrl = `'${url.replace(/'/g, \"'\\\\''\")}'`;\n return `claude mcp add --transport http \"${sanitizedName}\" ${quotedUrl}`;\n}\n\n/** Hosted Manufact Inspector base (same as cloud deploy “Open in new tab”). */\nconst MANUFACT_INSPECTOR_ORIGIN = \"https://inspector.manufact.com\";\n\n/**\n * Deep link to hosted Manufact Inspector with this MCP server URL pre-filled\n * and the Chat tab selected (`tab=chat`).\n */\nfunction getManufactInspectorUrl(serverUrl: string): string {\n const params = new URLSearchParams({\n autoConnect: serverUrl,\n tab: \"chat\",\n });\n return `${MANUFACT_INSPECTOR_ORIGIN}/inspector?${params.toString()}`;\n}\n\nconst LOGO_SVG_PATHS = {\n path1:\n \"M105.933 0C164.437 0.000115889 211.865 47.607 211.865 106.333C211.865 131.828 210.494 158.401 221.068 181.6L228.976 198.947C243.585 230.997 269.266 256.7 301.304 271.336L316.156 278.121C340.143 289.079 367.695 287.335 394.067 287.335C452.572 287.335 500 334.942 500 393.668C500 452.394 452.572 500.001 394.067 500.001C335.563 500.001 288.135 452.394 288.135 393.668C288.135 368.974 289.241 343.275 278.992 320.807L270.587 302.38C255.949 270.289 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.92992e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z\",\n circle: { cx: 100.426, cy: 399.575, r: 100.426 },\n path2:\n \"M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z\",\n};\n\nconst LINE_INTERSECTION_PATH =\n \"M10.5 4C10.5 7.31371 7.81371 10 4.5 10H0.5V11H4.5C7.81371 11 10.5 13.6863 10.5 17V21H11.5V17C11.5 13.6863 14.1863 11 17.5 11H21.5V10H17.5C14.1863 10 11.5 7.31371 11.5 4V0H10.5V4Z\";\n\n/** Returns the inline WebGL mesh gradient script (no deps). */\nfunction getMeshGradientScript(): string {\n const VERT = `#version 300 es\nin vec4 a_position;\nout vec2 v_objectUV;\nvoid main(){\n gl_Position=a_position;\n v_objectUV=a_position.xy*0.5+0.5;\n}`;\n\n const FRAG = `#version 300 es\nprecision mediump float;\nuniform float u_time;\nuniform vec4 u_colors[4];\nuniform float u_colorsCount;\nuniform float u_distortion;\nuniform float u_swirl;\nuniform float u_grainMixer;\nuniform float u_grainOverlay;\nin vec2 v_objectUV;\nout vec4 fragColor;\n#define PI 3.14159265359\nvec2 rotate(vec2 uv,float th){return mat2(cos(th),sin(th),-sin(th),cos(th))*uv;}\nfloat hash21(vec2 p){\n p=fract(p*vec2(0.3183099,0.3678794))+0.1;\n p+=dot(p,p+19.19);\n return fract(p.x*p.y);\n}\nfloat valueNoise(vec2 st){\n vec2 i=floor(st);vec2 f=fract(st);\n float a=hash21(i),b=hash21(i+vec2(1.,0.)),c=hash21(i+vec2(0.,1.)),d=hash21(i+vec2(1.,1.));\n vec2 u=f*f*(3.-2.*f);\n return mix(mix(a,b,u.x),mix(c,d,u.x),u.y);\n}\nvec2 getPosition(int i,float t){\n float a=float(i)*.37,b=.6+fract(float(i)/3.)*.9,c=.8+fract(float(i+1)/4.);\n float x=sin(t*b+a),y=cos(t*c+a*1.5);\n return .5+.5*vec2(x,y);\n}\nvoid main(){\n vec2 uv=v_objectUV;uv+=.5;\n vec2 grainUV=uv*1000.;\n float grain=valueNoise(grainUV);\n float mixerGrain=.4*u_grainMixer*(grain-.5);\n float t=.5*(u_time+41.5);\n float radius=smoothstep(0.,1.,length(uv-.5));\n float center=1.-radius;\n for(float i=1.;i<=2.;i++){\n uv.x+=u_distortion*center/i*sin(t+i*.4*smoothstep(0.,1.,uv.y))*cos(.2*t+i*2.4*smoothstep(0.,1.,uv.y));\n uv.y+=u_distortion*center/i*cos(t+i*2.*smoothstep(0.,1.,uv.x));\n }\n vec2 uvR=uv-vec2(.5);\n float angle=3.*u_swirl*radius;\n uvR=rotate(uvR,-angle);uvR+=vec2(.5);\n vec3 color=vec3(0.);float opacity=0.,totalWeight=0.;\n for(int i=0;i<4;i++){\n if(i>=int(u_colorsCount))break;\n vec2 pos=getPosition(i,t)+mixerGrain;\n vec3 cf=u_colors[i].rgb*u_colors[i].a;\n float opacityF=u_colors[i].a;\n float dist=length(uvR-pos);\n dist=pow(dist,3.5);\n float w=1./(dist+1e-3);\n color+=cf*w;opacity+=opacityF*w;totalWeight+=w;\n }\n color/=max(1e-4,totalWeight);\n opacity/=max(1e-4,totalWeight);\n float grainO=valueNoise(rotate(grainUV,1.)+vec2(3.));\n grainO=mix(grainO,valueNoise(rotate(grainUV,2.)+vec2(-1.)),.5);\n grainO=pow(grainO,1.3);\n float grainOV=grainO*2.-1.;\n vec3 grainOC=vec3(step(0.,grainOV));\n float grainOS=u_grainOverlay*abs(grainOV);\n grainOS=pow(grainOS,.8);\n color=mix(color,grainOC,.35*grainOS);\n opacity+=.5*grainOS;\n fragColor=vec4(color,clamp(opacity,0.,1.));\n}`;\n\n return `(function(){\nvar c=document.getElementById('mesh-bg');\nif(!c)return;\nvar wrap=c.parentElement;\nif(!wrap)return;\nvar gl=c.getContext('webgl2');\nif(!gl)return;\nfunction compileShader(typ,src){\n var s=gl.createShader(typ);\n gl.shaderSource(s,src);\n gl.compileShader(s);\n if(!gl.getShaderParameter(s,gl.COMPILE_STATUS)){console.error(gl.getShaderInfoLog(s));return null;}\n return s;\n}\nvar vs=compileShader(gl.VERTEX_SHADER,${JSON.stringify(VERT)});\nvar fs=compileShader(gl.FRAGMENT_SHADER,${JSON.stringify(FRAG)});\nif(!vs||!fs)return;\nvar prog=gl.createProgram();\ngl.attachShader(prog,vs);\ngl.attachShader(prog,fs);\ngl.linkProgram(prog);\nif(!gl.getProgramParameter(prog,gl.LINK_STATUS)){console.error(gl.getProgramInfoLog(prog));return;}\ngl.useProgram(prog);\nvar posLoc=gl.getAttribLocation(prog,'a_position');\nvar buf=gl.createBuffer();\ngl.bindBuffer(gl.ARRAY_BUFFER,buf);\ngl.bufferData(gl.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),gl.STATIC_DRAW);\ngl.enableVertexAttribArray(posLoc);\ngl.vertexAttribPointer(posLoc,2,gl.FLOAT,false,0,0);\nfunction hexToRgba(hex){\n var r=(parseInt(hex.slice(1,3),16))/255;\n var g=(parseInt(hex.slice(3,5),16))/255;\n var b=(parseInt(hex.slice(5,7),16))/255;\n return[r,g,b,1];\n}\nvar colors=[hexToRgba('#e0eaff'),hexToRgba('#f9ffbd'),hexToRgba('#dedede'),hexToRgba('#ffffff')];\nvar uTime=gl.getUniformLocation(prog,'u_time');\nvar uColors=[gl.getUniformLocation(prog,'u_colors[0]'),gl.getUniformLocation(prog,'u_colors[1]'),gl.getUniformLocation(prog,'u_colors[2]'),gl.getUniformLocation(prog,'u_colors[3]')];\nvar uColorsCount=gl.getUniformLocation(prog,'u_colorsCount');\nvar uDistortion=gl.getUniformLocation(prog,'u_distortion');\nvar uSwirl=gl.getUniformLocation(prog,'u_swirl');\nvar uGrainMixer=gl.getUniformLocation(prog,'u_grainMixer');\nvar uGrainOverlay=gl.getUniformLocation(prog,'u_grainOverlay');\nvar time=0,speed=1,raf;\nfunction resize(){\n var dpr=Math.min(2,window.devicePixelRatio||1);\n c.width=Math.floor(wrap.clientWidth*dpr);\n c.height=Math.floor(wrap.clientHeight*dpr);\n gl.viewport(0,0,c.width,c.height);\n}\nfunction draw(){\n if(document.hidden){raf=requestAnimationFrame(draw);return;}\n time+=0.016*speed;\n gl.uniform1f(uTime,time);\n for(var i=0;i<4;i++)gl.uniform4fv(uColors[i],colors[i]);\n gl.uniform1f(uColorsCount,4);\n gl.uniform1f(uDistortion,0.8);\n gl.uniform1f(uSwirl,0.1);\n gl.uniform1f(uGrainMixer,0);\n gl.uniform1f(uGrainOverlay,0.3);\n gl.drawArrays(gl.TRIANGLES,0,6);\n raf=requestAnimationFrame(draw);\n}\nresize();\nnew ResizeObserver(resize).observe(wrap);\ndraw();\n})();`;\n}\n\n/** A tool shown in the landing page's primitives list. */\nexport interface LandingPageTool {\n /** Protocol-facing tool name. */\n name: string;\n\n /** Optional human-readable tool title. */\n title?: string;\n\n /** Optional tool description. */\n description?: string;\n}\n\n/** A prompt shown in the landing page's primitives list. */\nexport interface LandingPagePrompt {\n /** Protocol-facing prompt name. */\n name: string;\n\n /** Optional human-readable prompt title. */\n title?: string;\n\n /** Optional prompt description. */\n description?: string;\n}\n\n/** A static resource shown in the landing page's primitives list. */\nexport interface LandingPageResource {\n /** Resource URI. */\n uri: string;\n\n /** Optional protocol-facing resource name. */\n name?: string;\n\n /** Optional human-readable resource title. */\n title?: string;\n\n /** Optional resource description. */\n description?: string;\n}\n\n/** Inputs used to render the v1-compatible MCP server landing page. */\nexport interface LandingPageOptions {\n /** Protocol-facing server name. */\n name: string;\n\n /** Optional human-readable server title used as the page heading. */\n title?: string;\n\n /** Server version shown beside the heading. */\n version: string;\n\n /** Absolute public URL of the MCP endpoint. */\n url: string;\n\n /** Optional server description. */\n description?: string;\n\n /** Optional tools shown in the primitives list. */\n tools?: readonly LandingPageTool[];\n\n /** Optional prompts shown in the primitives list. */\n prompts?: readonly LandingPagePrompt[];\n\n /** Optional static resources shown in the primitives list. */\n resources?: readonly LandingPageResource[];\n\n /** Optional absolute URL for the icon displayed above the server heading. */\n iconUrl?: string;\n}\n\n/**\n * Generates an HTML landing page with connection instructions\n * for Claude Code, Cursor, VS Code, ChatGPT, and Manufact Inspector.\n *\n * @param options - Server identity, endpoint, icon, and primitive metadata.\n * @returns HTML landing page with connection instructions\n */\nexport function generateLandingPage(options: LandingPageOptions): string {\n const {\n name: protocolName,\n title,\n version,\n url,\n description,\n tools,\n prompts,\n resources,\n iconUrl,\n } = options;\n const name = title ?? protocolName;\n const cursorDeepLink = generateCursorDeepLink(url, name);\n const vscodeDeepLink = generateVSCodeDeepLink(url, name);\n const vscodeInsidersDeepLink = generateVSCodeInsidersDeepLink(url, name);\n const claudeCommand = generateClaudeCommand(url, name);\n const manufactInspectorUrl = getManufactInspectorUrl(url);\n\n const safeName = escapeHtml(name);\n const safeDescription = description ? escapeHtml(description) : \"\";\n const rawMetaDescription =\n description ||\n `${name} MCP Server — Connect with Claude Code, Cursor, and VS Code. Model Context Protocol server.`;\n const metaDescription = escapeHtml(rawMetaDescription);\n const pageTitle = `${safeName} MCP Server — Connect with Claude Code, Cursor & VS Code`;\n\n const jsonLd = serializeScriptJson({\n \"@context\": \"https://schema.org\",\n \"@type\": \"SoftwareApplication\",\n name: name,\n softwareVersion: version,\n description: rawMetaDescription,\n applicationCategory: \"DeveloperApplication\",\n });\n\n const normalizedTools: LandingPageTool[] =\n tools && tools.length > 0\n ? tools.map((tool) => ({\n name: tool.title ?? tool.name,\n ...(tool.description !== undefined && {\n description: tool.description,\n }),\n }))\n : [];\n\n const toolsListHtml =\n normalizedTools.length > 0\n ? normalizedTools\n .map(\n (t) =>\n `<div class=\"spec-item\"><code class=\"spec-name\">${escapeHtml(t.name)}</code>${t.description ? `<p class=\"spec-desc\">${escapeHtml(t.description)}</p>` : \"\"}</div>`\n )\n .join(\"\\n\")\n : \"\";\n\n const promptsListHtml =\n prompts && prompts.length > 0\n ? prompts\n .map(\n (p) =>\n `<div class=\"spec-item\"><code class=\"spec-name\">${escapeHtml(p.title ?? p.name)}</code>${p.description ? `<p class=\"spec-desc\">${escapeHtml(p.description)}</p>` : \"\"}</div>`\n )\n .join(\"\\n\")\n : \"\";\n\n const resourcesListHtml =\n resources && resources.length > 0\n ? resources\n .map(\n (r) =>\n `<div class=\"spec-item\"><code class=\"spec-uri\">${escapeHtml(r.uri)}</code>${r.description ? `<p class=\"spec-desc\">${escapeHtml(r.description)}</p>` : \"\"}</div>`\n )\n .join(\"\\n\")\n : \"\";\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>${pageTitle}</title>\n<meta name=\"description\" content=\"${metaDescription}\">\n<meta property=\"og:title\" content=\"${pageTitle}\">\n<meta property=\"og:description\" content=\"${metaDescription}\">\n<meta property=\"og:type\" content=\"website\">\n<meta name=\"twitter:card\" content=\"summary\">\n<meta name=\"twitter:title\" content=\"${pageTitle}\">\n<meta name=\"twitter:description\" content=\"${metaDescription}\">\n${iconUrl ? `<link rel=\"icon\" href=\"${escapeHtml(iconUrl)}\">` : \"\"}\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap\" rel=\"stylesheet\">\n<script type=\"application/ld+json\">${jsonLd}</script>\n<style>\n* { box-sizing: border-box; }\nbody {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n color: #1e293b;\n background-color: #fdfcfc;\n min-height: 100vh;\n}\n.layout {\n max-width: 48rem;\n margin: 0 auto;\n padding: 2rem 1.5rem;\n position: relative;\n}\n.rail-left, .rail-right {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 1px;\n background: rgba(0,0,0,0.08);\n}\n.rail-left { left: 1.5rem; }\n.rail-right { right: 1.5rem; }\n.rail-top, .rail-bottom {\n height: 1px;\n background: rgba(0,0,0,0.08);\n position: absolute;\n left: 1.5rem;\n right: 1.5rem;\n}\n.rail-top { top: 0; }\n.rail-bottom { bottom: 0; }\n.corner {\n position: absolute;\n width: 22px;\n height: 21px;\n color: rgba(0,0,0,0.08);\n}\n.corner-tl { left: 1.5rem; top: 0; transform: translate(-50%, -50%); }\n.corner-tr { right: 1.5rem; top: 0; transform: translate(50%, -50%); left: auto; }\n.corner-bl { left: 1.5rem; bottom: 0; transform: translate(-50%, 50%); top: auto; }\n.corner-br { right: 1.5rem; bottom: 0; transform: translate(50%, 50%); left: auto; top: auto; }\n.card {\n background: #fff;\n border-top: 1px solid rgba(0,0,0,0.08);\n border-bottom: 1px solid rgba(0,0,0,0.08);\n margin-bottom: 1.5rem;\n overflow: hidden;\n}\n.card-header {\n padding: 1.5rem 1.5rem 0.5rem;\n}\n.card-content { padding: 0 1.5rem 1.5rem; }\n.hero-card .card-header {\n text-align: center;\n padding: 0 1.5rem 1.25rem;\n}\n.hero-card .card-header.has-icon {\n padding-top: 1.5rem;\n}\n.hero-icon {\n width: 64px;\n height: 64px;\n border-radius: 14px;\n object-fit: contain;\n margin-bottom: 0.75rem;\n}\n.hero-row {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.75rem;\n margin-bottom: 0.35rem;\n}\n.hero h1 {\n font-size: 1.75rem;\n font-weight: 700;\n color: #172037;\n margin: 0.75rem 0 0;\n}\n.hero-card .card-header.has-icon .hero h1 { margin-top: 0; }\n.hero .version { font-size: 0.95rem; color: #64748b; font-weight: 500; }\n.hero-description {\n color: rgba(23,32,55,0.8);\n font-size: 1rem;\n margin: 0.35rem 0 0;\n max-width: 36rem;\n margin-left: auto;\n margin-right: auto;\n}\n.logo-symbol {\n display: inline-block;\n cursor: default;\n flex-shrink: 0;\n}\n.logo-symbol svg {\n width: 32px;\n height: 32px;\n color: #172037;\n}\n.logo-fill { transition: opacity 0.2s ease; }\n.logo-stroke path,\n.logo-stroke circle {\n fill: none;\n stroke: currentColor;\n stroke-width: 6;\n stroke-linecap: round;\n stroke-linejoin: round;\n stroke-dasharray: 2000;\n stroke-dashoffset: 2000;\n opacity: 0;\n}\n.logo-symbol:hover .logo-fill {\n animation: logo-fill-out 0.2s forwards, logo-fill-in 0.6s 0.9s forwards;\n}\n.logo-symbol:hover .logo-stroke path,\n.logo-symbol:hover .logo-stroke circle {\n opacity: 1;\n animation: logo-draw 0.7s 0.2s ease-in-out forwards;\n}\n@keyframes logo-fill-out { to { opacity: 0; } }\n@keyframes logo-fill-in { to { opacity: 1; } }\n@keyframes logo-draw { to { stroke-dashoffset: 0; } }\n.footer-content { text-align: center; padding: 2.5rem 1.5rem; border-top: 1px solid rgba(0,0,0,0.08); display: flex; justify-content: center; align-items: center; }\n.footer-brand-link { justify-content: center; }\n.footer-brand-link .logo-symbol svg { width: 22px; height: 22px; }\n.hero-powered { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; margin-top: 0.75rem; font-family: \"Outfit\", -apple-system, BlinkMacSystemFont, sans-serif; font-size: 0.875rem; font-weight: 500; color: rgba(23,32,55,0.6); }\n.hero-powered a { color: #000; text-decoration: none; display: inline-flex; align-items: center; }\n.hero-powered a:hover { text-decoration: underline; }\n.footer-brand-link { display: inline-flex; align-items: center; gap: 0.5rem; font-family: \"Outfit\", -apple-system, BlinkMacSystemFont, sans-serif; font-size: 1.5rem; font-weight: 600; color: #172037; text-decoration: none; }\n.footer-brand-link:hover { color: #0f172a; }\n.hero-url-block { display: flex; justify-content: center; margin: 0.75rem 0; }\n.hero-cta-row {\n display: flex;\n justify-content: center;\n margin: 0.35rem 0 0.5rem;\n}\n.hero-primary-btn {\n display: inline-block;\n padding: 0.625rem 1.25rem;\n background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);\n color: #fff;\n border-radius: 9999px;\n text-decoration: none;\n font-weight: 600;\n font-size: 0.9375rem;\n box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 2px 8px rgba(15,23,42,0.15);\n transition: background 0.15s;\n border: 1px solid rgba(0,0,0,0.12);\n}\n.hero-primary-btn:hover {\n background: linear-gradient(180deg, #334155 0%, #1e293b 100%);\n text-decoration: none;\n color: #fff;\n}\n.hero-url-block .url-block { max-width: 100%; }\n.hero-url-block .url-box {\n font-size: 0.938rem;\n background: #fff;\n border: 1px solid rgba(0,0,0,0.12);\n border-radius: 9999px;\n padding: 0.75rem 3rem 0.75rem 1rem;\n margin: 1rem 0;\n}\n.hero-powered .gh-icon { width: 18px; height: 18px; margin-right: 0.25rem; vertical-align: -0.2em; }\n.hero-powered .gh-shield { height: 18px; width: auto; margin-left: 0.4rem; vertical-align: -0.2em; }\n.card-title { font-size: 1.25rem; font-weight: 600; color: #172037; margin: 0 0 0.25rem; }\n.card-desc { font-size: 0.875rem; color: rgba(23,32,55,0.8); margin: 0 0 1rem; }\n.url-block {\n position: relative;\n margin: 1rem 0;\n}\n.url-block .url-box {\n margin: 0;\n padding-right: 2.75rem;\n}\n.url-block .copy-btn { top: 50%; right: 0.5rem; transform: translateY(-50%); }\n.url-box {\n font-family: ui-monospace, monospace;\n font-size: 0.813rem;\n background: #f8fafc;\n padding: 0.5rem 0.75rem;\n border-radius: 6px;\n color: #475569;\n margin: 1rem 0;\n}\n.spec-section { margin-top: 1.5rem; }\n.spec-section h3 { font-size: 1rem; font-weight: 600; color: #172037; margin: 0 0 0.75rem; }\n.spec-item { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #f1f5f9; }\n.spec-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }\n.spec-name, .spec-uri { font-family: ui-monospace, monospace; font-size: 0.813rem; background: #f1f5f9; padding: 0.2rem 0.4rem; border-radius: 4px; }\n.spec-uri { word-break: break-all; }\n.spec-desc { margin: 0.5rem 0 0; font-size: 0.875rem; color: #64748b; line-height: 1.5; }\n.tabs-row {\n display: flex;\n gap: 2px;\n background: rgba(23,32,55,0.05);\n padding: 3px;\n border-radius: 8px;\n margin-bottom: 1.5rem;\n flex-wrap: wrap;\n}\n.tab {\n flex: 1;\n min-width: 80px;\n padding: 0.5rem 0.75rem;\n font-size: 0.813rem;\n font-weight: 500;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: #64748b;\n cursor: pointer;\n transition: background 0.15s, color 0.15s;\n}\n.tab:hover { color: #172037; background: rgba(255,255,255,0.6); }\n.tab.active { background: #fff; color: #172037; border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }\n.tab-panel { display: none; }\n.tab-panel.active { display: block; }\n.tab-panel h3 { font-size: 1.125rem; font-weight: 600; color: #172037; margin: 0 0 1rem; }\n.install-btn {\n display: inline-block;\n padding: 0.375rem 0.875rem;\n background: #0f172a;\n color: #fff;\n border-radius: 9999px;\n text-decoration: none;\n font-weight: 500;\n font-size: 0.813rem;\n margin-bottom: 1rem;\n transition: background 0.15s;\n}\n.install-btn:hover { background: #1e293b; }\n.code-block {\n position: relative;\n margin: 1rem 0;\n}\n.code-block pre {\n margin: 0;\n padding: 0.5rem 0.75rem;\n background: #f8fafc;\n color: #475569;\n border-radius: 8px;\n font-family: ui-monospace, monospace;\n font-size: 0.875rem;\n overflow-x: auto;\n border: 1px solid rgba(0,0,0,0.08);\n}\n.code-block .copy-btn { top: 50%; right: 0.375rem; transform: translateY(-50%); }\n.copy-btn {\n position: absolute;\n top: 0.5rem;\n right: 0.5rem;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border: none;\n border-radius: 6px;\n background: #fff;\n color: #172037;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s;\n}\n.copy-btn:hover { background: #f1f5f9; }\n.copy-btn.copied { background: #fff; color: #172037; }\n.copy-btn svg { width: 14px; height: 14px; }\nol.steps { margin: 0; padding-left: 1.25rem; }\nol.steps li { margin: 0.5rem 0; color: #475569; }\na { color: #0522a5; text-decoration: none; }\na:hover { text-decoration: underline; }\n.hero-gradient-wrap {\n position: relative;\n padding: 1.5rem;\n overflow: hidden;\n}\n.hero-gradient-wrap canvas {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n display: block;\n}\n.hero-inner {\n position: relative;\n z-index: 1;\n background: rgba(253,252,252,0.9);\n -webkit-backdrop-filter: blur(12px);\n backdrop-filter: blur(12px);\n padding: 1.25rem 1.5rem;\n border: 1px solid rgba(0,0,0,0.06);\n}\n.hero-inner .card-header { padding: 0; }\n.hero-inner .card-header.has-icon { padding-top: 0.5rem; }\n</style>\n</head>\n<body>\n<div class=\"layout\">\n <div class=\"rail-left\"></div>\n <div class=\"rail-right\"></div>\n <div class=\"rail-top\"></div>\n <div class=\"rail-bottom\"></div>\n <svg class=\"corner corner-tl\" viewBox=\"0 0 22 21\" fill=\"none\"><path d=\"${LINE_INTERSECTION_PATH}\" fill=\"currentColor\"/></svg>\n <svg class=\"corner corner-tr\" viewBox=\"0 0 22 21\" fill=\"none\"><path d=\"${LINE_INTERSECTION_PATH}\" fill=\"currentColor\"/></svg>\n <svg class=\"corner corner-bl\" viewBox=\"0 0 22 21\" fill=\"none\"><path d=\"${LINE_INTERSECTION_PATH}\" fill=\"currentColor\"/></svg>\n <svg class=\"corner corner-br\" viewBox=\"0 0 22 21\" fill=\"none\"><path d=\"${LINE_INTERSECTION_PATH}\" fill=\"currentColor\"/></svg>\n\n <div class=\"card hero-card\">\n <div class=\"hero-gradient-wrap\" id=\"hero-gradient-wrap\">\n <canvas id=\"mesh-bg\" aria-hidden=\"true\"></canvas>\n <div class=\"hero-inner\">\n <div class=\"card-header ${iconUrl ? \"has-icon\" : \"\"}\">\n ${iconUrl ? `<img src=\"${escapeHtml(iconUrl)}\" alt=\"\" class=\"hero-icon\" width=\"64\" height=\"64\" />` : \"\"}\n <div class=\"hero-row\">\n <h1>${safeName} <span class=\"version\">(v${escapeHtml(version)})</span></h1>\n </div>\n ${safeDescription ? `<p class=\"hero-description\">${safeDescription}</p>` : \"\"}\n <div class=\"hero-url-block\">\n <div class=\"url-block\">\n <div class=\"url-box\" data-copy=\"${escapeHtml(url)}\">${escapeHtml(url)}</div>\n <button type=\"button\" class=\"copy-btn\" data-copy=\"${escapeHtml(url)}\" aria-label=\"Copy URL\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg></button>\n </div>\n </div>\n <div class=\"hero-cta-row\">\n <a href=\"${escapeHtml(manufactInspectorUrl)}\" class=\"hero-primary-btn\" target=\"_blank\" rel=\"noopener noreferrer\">Open in Inspector</a>\n </div>\n <div class=\"hero-powered\">\n <span>Powered by</span>\n <a href=\"https://github.com/mcp-use/mcp-use\" target=\"_blank\" rel=\"noopener noreferrer\">\n <svg class=\"gh-icon\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z\"/></svg>\n github.com/mcp-use/mcp-use\n <img src=\"https://img.shields.io/github/stars/mcp-use/mcp-use\" alt=\"GitHub stars\" class=\"gh-shield\" width=\"90\" height=\"18\" loading=\"lazy\" />\n </a>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"card\">\n <div class=\"card-header\">\n <h2 class=\"card-title\">Installation Guide</h2>\n <p class=\"card-desc\">Choose your preferred MCP client</p>\n </div>\n <div class=\"card-content\">\n <div class=\"tabs-row\" role=\"tablist\">\n <button type=\"button\" class=\"tab active\" role=\"tab\" data-tab=\"claude-code\" aria-selected=\"true\">Claude Code</button>\n <button type=\"button\" class=\"tab\" role=\"tab\" data-tab=\"cursor\" aria-selected=\"false\">Cursor</button>\n <button type=\"button\" class=\"tab\" role=\"tab\" data-tab=\"vscode\" aria-selected=\"false\">VS Code</button>\n <button type=\"button\" class=\"tab\" role=\"tab\" data-tab=\"vscode-insiders\" aria-selected=\"false\">VS Code Insiders</button>\n <button type=\"button\" class=\"tab\" role=\"tab\" data-tab=\"chatgpt\" aria-selected=\"false\">ChatGPT</button>\n </div>\n\n <div id=\"panel-claude-code\" class=\"tab-panel active\">\n <h3>Install in Claude Code</h3>\n <p>Run this command in your terminal:</p>\n <div class=\"code-block\">\n <pre data-copy=\"${escapeHtml(claudeCommand)}\">${escapeHtml(claudeCommand)}</pre>\n <button type=\"button\" class=\"copy-btn\" aria-label=\"Copy\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg></button>\n </div>\n </div>\n\n <div id=\"panel-cursor\" class=\"tab-panel\">\n <h3>Install in Cursor</h3>\n <p>Click the button below to add this MCP server to Cursor:</p>\n <a href=\"${cursorDeepLink}\" class=\"install-btn\">Open in Cursor</a>\n <p>Or add manually: Settings → MCP → Add server</p>\n </div>\n\n <div id=\"panel-vscode\" class=\"tab-panel\">\n <h3>Install in VS Code</h3>\n <p>Click the button below to add this MCP server to VS Code:</p>\n <a href=\"${vscodeDeepLink}\" class=\"install-btn\">Open in VS Code</a>\n <p>Or add manually: Settings → MCP → Add server</p>\n </div>\n\n <div id=\"panel-vscode-insiders\" class=\"tab-panel\">\n <h3>Install in VS Code Insiders</h3>\n <p>Click the button below to add this MCP server to VS Code Insiders:</p>\n <a href=\"${vscodeInsidersDeepLink}\" class=\"install-btn\">Open in VS Code Insiders</a>\n <p>Or add manually: Settings → MCP → Add server</p>\n </div>\n\n <div id=\"panel-chatgpt\" class=\"tab-panel\">\n <h3>Connect with ChatGPT</h3>\n <ol class=\"steps\">\n <li><strong>Enable Developer Mode:</strong> Settings → Connectors → Advanced → Developer mode</li>\n <li><strong>Import this MCP server:</strong> Go to Connectors tab and add: ${escapeHtml(url)}</li>\n <li><strong>Use in conversations:</strong> Choose the MCP server from the Plus menu</li>\n </ol>\n </div>\n </div>\n </div>\n\n ${\n toolsListHtml || promptsListHtml || resourcesListHtml\n ? `\n <div class=\"card\">\n <div class=\"card-header\">\n <h2 class=\"card-title\">Primitives</h2>\n ${toolsListHtml ? `<div class=\"spec-section\"><h3>Tools (${normalizedTools.length})</h3>${toolsListHtml}</div>` : \"\"}\n ${promptsListHtml ? `<div class=\"spec-section\"><h3>Prompts (${prompts!.length})</h3>${promptsListHtml}</div>` : \"\"}\n ${resourcesListHtml ? `<div class=\"spec-section\"><h3>Resources (${resources!.length})</h3>${resourcesListHtml}</div>` : \"\"}\n </div>\n </div>\n `\n : \"\"\n }\n\n <footer class=\"footer-content\">\n <a href=\"https://manufact.com\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"footer-brand-link\" aria-label=\"Manufact\">\n <span class=\"logo-symbol\">\n <svg viewBox=\"0 0 500 500\" xmlns=\"http://www.w3.org/2000/svg\">\n <g class=\"logo-fill\" fill=\"currentColor\" fill-rule=\"nonzero\">\n <path d=\"${LOGO_SVG_PATHS.path1}\"/>\n <circle cx=\"${LOGO_SVG_PATHS.circle.cx}\" cy=\"${LOGO_SVG_PATHS.circle.cy}\" r=\"${LOGO_SVG_PATHS.circle.r}\"/>\n <path d=\"${LOGO_SVG_PATHS.path2}\"/>\n </g>\n <g class=\"logo-stroke\">\n <path d=\"${LOGO_SVG_PATHS.path1}\"/>\n <circle cx=\"${LOGO_SVG_PATHS.circle.cx}\" cy=\"${LOGO_SVG_PATHS.circle.cy}\" r=\"${LOGO_SVG_PATHS.circle.r}\"/>\n <path d=\"${LOGO_SVG_PATHS.path2}\"/>\n </g>\n </svg>\n </span>\n <span>Manufact</span>\n </a>\n </footer>\n</div>\n\n<script>${getMeshGradientScript()}</script>\n<script>\n(function(){\n var tabs = document.querySelectorAll('.tab');\n var panels = document.querySelectorAll('.tab-panel');\n tabs.forEach(function(tab){\n tab.addEventListener('click', function(){\n var target = tab.getAttribute('data-tab');\n tabs.forEach(function(t){ t.classList.remove('active'); t.setAttribute('aria-selected','false'); });\n panels.forEach(function(p){\n var match = p.id === 'panel-' + target;\n p.classList.toggle('active', match);\n p.hidden = !match;\n });\n tab.classList.add('active');\n tab.setAttribute('aria-selected','true');\n });\n });\n var copySvg = '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg>';\n var checkSvg = '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M20 6L9 17l-5-5\"/></svg>';\n document.querySelectorAll('.copy-btn').forEach(function(btn){\n btn.addEventListener('click', function(){\n var text = btn.getAttribute('data-copy');\n if (!text) {\n var pre = btn.parentElement.querySelector('pre');\n text = pre ? (pre.getAttribute('data-copy') || pre.textContent) : '';\n }\n if (text) navigator.clipboard.writeText(text).then(function(){\n btn.classList.add('copied');\n btn.innerHTML = checkSvg;\n setTimeout(function(){ btn.classList.remove('copied'); btn.innerHTML = copySvg; }, 2000);\n });\n });\n });\n panels.forEach(function(p){ if(!p.classList.contains('active')) p.hidden = true; });\n})();\n</script>\n</body>\n</html>`;\n}\n"],"mappings":";AAUA,SAAS,WAAW,MAAsB;AACxC,SAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,OAAO;AAC1B;AAGA,SAAS,oBAAoB,OAAwB;AACnD,SAAO,KAAK,UAAU,KAAK,EACxB,QAAQ,MAAM,SAAS,EACvB,QAAQ,MAAM,SAAS;AAC5B;AAMA,SAAS,mBAAmB,MAAsB;AAChD,SAAO,KAAK,QAAQ,mBAAmB,GAAG,EAAE,YAAY;AAC1D;AAMA,SAAS,uBAAuB,KAAa,MAAsB;AACjE,QAAM,SAAS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AO,CAAC;AAAA,uBAC3F,eAAe,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UASjC,sBAAsB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCjC;","names":[]}
|
|
@@ -17,9 +17,9 @@ var PUBLIC_CONTENT_TYPES = {
|
|
|
17
17
|
".woff2": "font/woff2"
|
|
18
18
|
};
|
|
19
19
|
async function resolvePublicFilePath(publicRoot, subpath) {
|
|
20
|
-
const {
|
|
20
|
+
const { stat } = await import("fs/promises");
|
|
21
21
|
const { resolve, sep } = await import("path");
|
|
22
|
-
if (subpath === "" || subpath.includes("
|
|
22
|
+
if (subpath === "" || subpath.includes("\\") || subpath.split("/").some((segment) => segment === "..")) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
const clean = subpath.replace(/^\/+/, "");
|
|
@@ -31,7 +31,11 @@ async function resolvePublicFilePath(publicRoot, subpath) {
|
|
|
31
31
|
if (abs !== root && !abs.startsWith(root + sep)) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
try {
|
|
35
|
+
if (!(await stat(abs)).isFile()) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
35
39
|
return null;
|
|
36
40
|
}
|
|
37
41
|
return abs;
|
|
@@ -40,11 +44,10 @@ async function servePublicFile(diskPath, options = {}) {
|
|
|
40
44
|
const { createReadStream } = await import("fs");
|
|
41
45
|
const { extname } = await import("path");
|
|
42
46
|
const { Readable } = await import("stream");
|
|
43
|
-
const ext = extname(diskPath);
|
|
47
|
+
const ext = extname(diskPath).toLowerCase();
|
|
44
48
|
const contentType = PUBLIC_CONTENT_TYPES[ext] ?? "application/octet-stream";
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
return new Response(webStream, {
|
|
49
|
+
const body = options.head === true ? null : Readable.toWeb(createReadStream(diskPath));
|
|
50
|
+
return new Response(body, {
|
|
48
51
|
status: 200,
|
|
49
52
|
headers: {
|
|
50
53
|
"Content-Type": contentType,
|
|
@@ -55,8 +58,9 @@ async function servePublicFile(diskPath, options = {}) {
|
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
}
|
|
61
|
+
|
|
58
62
|
export {
|
|
59
63
|
resolvePublicFilePath,
|
|
60
64
|
servePublicFile
|
|
61
65
|
};
|
|
62
|
-
//# sourceMappingURL=
|
|
66
|
+
//# sourceMappingURL=chunk-SMN75YED.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/views/public-route.ts"],"sourcesContent":["const PUBLIC_CONTENT_TYPES: Record<string, string> = {\n \".css\": \"text/css\",\n \".gif\": \"image/gif\",\n \".html\": \"text/html\",\n \".ico\": \"image/x-icon\",\n \".jpeg\": \"image/jpeg\",\n \".jpg\": \"image/jpeg\",\n \".js\": \"application/javascript\",\n \".json\": \"application/json\",\n \".map\": \"application/json\",\n \".png\": \"image/png\",\n \".svg\": \"image/svg+xml\",\n \".txt\": \"text/plain\",\n \".webp\": \"image/webp\",\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n};\n\n/**\n * Resolve a request subpath to an on-disk file under `publicRoot`, rejecting\n * path traversal.\n *\n * @param publicRoot - Absolute path to the `public/` directory on disk.\n * @param subpath - Request path after the `/public/` route prefix.\n * @returns Absolute file path when safe and present, otherwise `null`.\n *\n * @internal\n */\nexport async function resolvePublicFilePath(\n publicRoot: string,\n subpath: string\n): Promise<string | null> {\n const { stat } = await import(\"node:fs/promises\");\n const { resolve, sep } = await import(\"node:path\");\n\n if (\n subpath === \"\" ||\n subpath.includes(\"\\\\\") ||\n subpath.split(\"/\").some((segment) => segment === \"..\")\n ) {\n return null;\n }\n const clean = subpath.replace(/^\\/+/, \"\");\n if (clean === \"\" || clean.endsWith(\"/\")) {\n return null;\n }\n const root = resolve(publicRoot);\n const abs = resolve(root, clean);\n if (abs !== root && !abs.startsWith(root + sep)) {\n return null;\n }\n try {\n if (!(await stat(abs)).isFile()) {\n return null;\n }\n } catch {\n return null;\n }\n return abs;\n}\n\n/**\n * Serve one file from the project's `public/` directory.\n *\n * @param diskPath - Absolute path resolved by {@link resolvePublicFilePath}.\n * @param options - `head` returns headers without opening a file stream.\n * When `deferCors` is true, omit hardcoded `ACAO: *` so global\n * {@link ServerConfig.cors} middleware owns CORS headers.\n * @returns A `Response` with `Cache-Control: public, max-age=0, must-revalidate`\n * and optionally `Access-Control-Allow-Origin: *` so cross-origin sandboxed\n * view iframes can load public files (module scripts and fetches use CORS mode).\n *\n * @internal\n */\nexport async function servePublicFile(\n diskPath: string,\n options: { deferCors?: boolean; head?: boolean } = {}\n): Promise<Response> {\n const { createReadStream } = await import(\"node:fs\");\n const { extname } = await import(\"node:path\");\n const { Readable } = await import(\"node:stream\");\n\n const ext = extname(diskPath).toLowerCase();\n const contentType = PUBLIC_CONTENT_TYPES[ext] ?? \"application/octet-stream\";\n const body =\n options.head === true\n ? null\n : (Readable.toWeb(createReadStream(diskPath)) as ReadableStream);\n return new Response(body, {\n status: 200,\n headers: {\n \"Content-Type\": contentType,\n \"Cache-Control\": \"public, max-age=0, must-revalidate\",\n ...(options.deferCors !== true && {\n \"Access-Control-Allow-Origin\": \"*\",\n }),\n },\n });\n}\n"],"mappings":";AAAA,IAAM,uBAA+C;AAAA,EACnD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AA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Q;AAAA,QAChC,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/cli/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA4CH;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAsKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkLnE"}
|
package/dist/commands/build.js
CHANGED
|
@@ -86,6 +86,12 @@ async function validateViewBindingsAtBuild(environment, entry, viewsManifest) {
|
|
|
86
86
|
var BUILD_ENTRY_NAME = "index.js";
|
|
87
87
|
var WRAPPER_BASENAME = "entry-wrapper.ts";
|
|
88
88
|
var ASSETS_INLINE_LIMIT = 100 * 1024 * 1024;
|
|
89
|
+
async function copyPublicAssets(cwd, outputDir) {
|
|
90
|
+
const publicSrc = join(cwd, "public");
|
|
91
|
+
if (existsSync(publicSrc)) {
|
|
92
|
+
await cp(publicSrc, outputDir, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
89
95
|
async function writeWrapperEntry(cacheDir, userEntry, viewsManifest) {
|
|
90
96
|
const wrapperPath = join(cacheDir, WRAPPER_BASENAME);
|
|
91
97
|
await mkdir(cacheDir, { recursive: true });
|
|
@@ -238,6 +244,7 @@ async function runBuild(options) {
|
|
|
238
244
|
target: "node"
|
|
239
245
|
}
|
|
240
246
|
});
|
|
247
|
+
await copyPublicAssets(options.cwd, join(paths.build, "views/public"));
|
|
241
248
|
const manifest2 = {
|
|
242
249
|
buildId: randomBytes(8).toString("hex"),
|
|
243
250
|
entryPoint: BUILD_ENTRY_NAME,
|
|
@@ -303,10 +310,7 @@ async function runBuild(options) {
|
|
|
303
310
|
);
|
|
304
311
|
}
|
|
305
312
|
}
|
|
306
|
-
|
|
307
|
-
if (existsSync(publicSrc)) {
|
|
308
|
-
await cp(publicSrc, join(viewsOutDir, "public"), { recursive: true });
|
|
309
|
-
}
|
|
313
|
+
await copyPublicAssets(options.cwd, join(viewsOutDir, "public"));
|
|
310
314
|
try {
|
|
311
315
|
await validateViewBindingsAtBuild(
|
|
312
316
|
bindingServer.environments.ssr,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/build.ts","../../src/cli/views-bindings.ts"],"sourcesContent":["/**\n * `mcp-use build` — Vite SSR/node build of the user's server entry into the\n * `.mcp-use/build/` workspace directory (CLI_SPEC.md § Commands → build).\n *\n * When views exist (under `resources/<name>/view.tsx`), also runs a client-environment\n * build per view (hashed assets on disk), validates bindings, and emits a\n * wrapper entry that primes views before re-exporting the server (VIEWS_SPEC.md §\n * Build system).\n *\n * `vite` is an optional peer dependency of `mcp-use` (never a regular\n * dependency): this module is only ever reached through the bin's dynamic\n * `import(\"./cli/index.js\")`, so a missing install surfaces as a rejected\n * promise there (classified by `bin/main.ts`'s `isViteMissing`), not at\n * package load time.\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport { cp, mkdir, rm, writeFile } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\nimport tailwindcss from \"@tailwindcss/vite\";\nimport react from \"@vitejs/plugin-react\";\nimport { build } from \"vite\";\n\nimport { discoverEntry } from \"./entry.js\";\nimport { mcpUseViewsPlugin } from \"./views-plugin.js\";\nimport { ensureToolsDeclaration } from \"./tools-declaration.js\";\nimport {\n resolveBuildBasePath,\n validateViewBindingsAtBuild,\n} from \"./views-bindings.js\";\nimport {\n createBindingValidationServer,\n discoverViews,\n virtualViewId,\n type DiscoveredView,\n} from \"./views.js\";\nimport { resolveTailwindCss, resolveUserViteConfig } from \"./vite-config.js\";\nimport { resolveWorkspacePaths, type BuildManifest } from \"./workspace.js\";\nimport { normalizeAssetsBaseUrl } from \"../views/origin.js\";\nimport { viewAssetsBasePath } from \"../views/document.js\";\nimport type { ViewsManifest } from \"../views/types.js\";\n\n/** Fixed filename of the emitted server entry inside `.mcp-use/build/`. */\nconst BUILD_ENTRY_NAME = \"index.js\";\n\nconst WRAPPER_BASENAME = \"entry-wrapper.ts\";\n\n/** Inline imported assets as data URLs up to this byte size (effectively all). */\nconst ASSETS_INLINE_LIMIT = 100 * 1024 * 1024;\n\n/**\n * Options for {@link runBuild}.\n *\n * @internal\n */\nexport interface BuildOptions {\n /** Absolute path to the project root (the directory containing the entry). */\n cwd: string;\n /**\n * Explicit entry path (the `--entry` flag), absolute or relative to `cwd`.\n *\n * @defaultValue Conventional discovery: `src/index.ts`, `src/server.ts`,\n * `index.ts`, `server.ts` — first hit wins.\n */\n entry?: string;\n /**\n * When true (`mcp-use build --with-inspector`), record `inspector: true`\n * in the build manifest.\n */\n withInspector?: boolean;\n}\n\n/**\n * Emit a short-lived wrapper module under `.mcp-use/cache/` that primes views\n * before re-exporting the user's entry (VIEWS_SPEC.md § Registration mechanism).\n */\nasync function writeWrapperEntry(\n cacheDir: string,\n userEntry: string,\n viewsManifest: ViewsManifest\n): Promise<string> {\n const wrapperPath = join(cacheDir, WRAPPER_BASENAME);\n await mkdir(cacheDir, { recursive: true });\n const manifestJson = JSON.stringify(viewsManifest);\n await writeFile(\n wrapperPath,\n [\n `import server from ${JSON.stringify(userEntry)};`,\n `import { registerViews } from \"mcp-use\";`,\n `server[registerViews](${manifestJson});`,\n `export default server;`,\n \"\",\n ].join(\"\\n\")\n );\n return wrapperPath;\n}\n\nfunction readBuildAssetsBase(): string | undefined {\n const raw = process.env[\"MCP_ASSETS_URL\"];\n if (raw === undefined || raw.trim() === \"\") {\n return undefined;\n }\n try {\n return normalizeAssetsBaseUrl(new URL(raw).href.replace(/\\/$/, \"\"));\n } catch {\n return undefined;\n }\n}\n\n/** Rewrite a view-relative manifest path to a full CDN URL at build time. */\nfunction toCdnAssetUrl(\n relativePath: string,\n viewName: string,\n assetsBase: string,\n basePath: string\n): string {\n const clean = relativePath.replace(/^\\/+/, \"\");\n return `${assetsBase}${viewAssetsBasePath(basePath, viewName)}${clean}`;\n}\n\nfunction applyBuildAssetsPrefix(\n entry: ViewsManifest[string],\n viewName: string,\n assetsBase: string,\n basePath: string\n): ViewsManifest[string] {\n if (entry.kind !== \"external\") {\n return entry;\n }\n return {\n ...entry,\n entry: toCdnAssetUrl(entry.entry, viewName, assetsBase, basePath),\n css: entry.css.map((path) =>\n toCdnAssetUrl(path, viewName, assetsBase, basePath)\n ),\n ...(entry.scripts !== undefined && {\n scripts: entry.scripts.map((path) =>\n toCdnAssetUrl(path, viewName, assetsBase, basePath)\n ),\n }),\n };\n}\n\n/**\n * Build one view into hashed assets on disk, then record view-relative paths\n * in the manifest (served over HTTP at runtime).\n */\nasync function buildExternalView(\n view: DiscoveredView,\n options: {\n cwd: string;\n cacheDir: string;\n viewsOutDir: string;\n userViteConfig: string | false;\n }\n): Promise<ViewsManifest[string]> {\n const viewOutDir = join(options.viewsOutDir, view.name);\n const clientResult = await build({\n root: options.cwd,\n configFile: options.userViteConfig,\n envFile: false,\n logLevel: \"warn\",\n cacheDir: options.cacheDir,\n resolve: { alias: { tailwindcss: resolveTailwindCss() } },\n plugins: [\n tailwindcss(),\n react(),\n mcpUseViewsPlugin({ getViews: () => [view] }),\n ],\n build: {\n outDir: viewOutDir,\n emptyOutDir: true,\n target: \"es2022\",\n sourcemap: false,\n minify: true,\n cssCodeSplit: false,\n assetsInlineLimit: ASSETS_INLINE_LIMIT,\n rollupOptions: {\n input: { [view.name]: virtualViewId(view.name) },\n output: {\n format: \"es\",\n codeSplitting: false,\n entryFileNames: \"assets/[name]-[hash].js\",\n assetFileNames: \"assets/[name]-[hash][extname]\",\n },\n },\n },\n base: \"./\",\n });\n\n const clientOutput = Array.isArray(clientResult)\n ? clientResult[0]\n : clientResult;\n if (clientOutput === undefined || !(\"output\" in clientOutput)) {\n throw new Error(`Client build for view \"${view.name}\" produced no output.`);\n }\n\n const rawOutput = clientOutput.output;\n const items = Array.isArray(rawOutput) ? rawOutput : Object.values(rawOutput);\n\n let jsFileName: string | undefined;\n let cssFileName: string | undefined;\n\n for (const item of items) {\n if (typeof item !== \"object\" || item === null || !(\"fileName\" in item)) {\n continue;\n }\n const fileName = (item as { fileName: unknown }).fileName;\n if (typeof fileName !== \"string\") {\n continue;\n }\n const typed = item as {\n type?: string;\n isEntry?: boolean;\n fileName: string;\n };\n if (typed.type === \"chunk\" && typed.isEntry === true) {\n jsFileName = typed.fileName;\n } else if (typed.type === \"asset\" && typed.fileName.endsWith(\".css\")) {\n cssFileName = typed.fileName;\n }\n }\n\n if (jsFileName === undefined) {\n throw new Error(\n `Client build produced no entry chunk for view \"${view.name}\".`\n );\n }\n\n return {\n kind: \"external\",\n entry: jsFileName.replace(/^\\/+/, \"\"),\n css: cssFileName !== undefined ? [cssFileName.replace(/^\\/+/, \"\")] : [],\n };\n}\n\n/**\n * Build the project's server for production: a Vite build of the SSR/node\n * environment only (the client environment for views arrives with\n * VIEWS_SPEC.md), emitted as ESM to `.mcp-use/build/` with a `manifest.json`\n * alongside it.\n *\n * Dependencies stay external (`ssr: { external: true }`): only the\n * user's own source is bundled; every bare import resolves from\n * `node_modules` at runtime. The built entry preserves the default export\n * (the `MCPServer` instance) so `mcp-use start` can import and serve it.\n *\n * There is deliberately no typecheck step — the build is transpile-only;\n * users run `tsc --noEmit` via their own script.\n *\n * @param options - Project root and optional entry override.\n * @throws If no entry is found (see {@link discoverEntry}), or if `vite` is\n * not installed (`mcp-use build` requires it as a devDependency) — the\n * `import(\"vite\")` rejection propagates to the bin's dispatch boundary,\n * which classifies it and prints the install hint.\n *\n * @internal Reached only via the bin's `import(\"./cli/index.js\")`\n * dispatch (`bin/main.ts`) — not re-exported from the package's \".\" entry.\n */\nexport async function runBuild(options: BuildOptions): Promise<void> {\n const startedAt = performance.now();\n const entry = discoverEntry(options.cwd, options.entry);\n if (await ensureToolsDeclaration(options.cwd, entry)) {\n console.log(\"[mcp-use] created tools.d.ts\");\n }\n const paths = resolveWorkspacePaths(options.cwd);\n const views = discoverViews(options.cwd);\n const userViteConfig = resolveUserViteConfig(options.cwd);\n const inspector = options.withInspector === true;\n\n if (views.length === 0) {\n await build({\n root: options.cwd,\n configFile: false,\n envFile: false,\n logLevel: \"warn\",\n cacheDir: paths.cache,\n build: {\n ssr: entry,\n outDir: paths.build,\n emptyOutDir: true,\n target: \"node24\",\n sourcemap: true,\n minify: false,\n rollupOptions: {\n output: {\n format: \"es\",\n entryFileNames: BUILD_ENTRY_NAME,\n },\n },\n },\n ssr: {\n external: true,\n target: \"node\",\n },\n });\n\n const manifest: BuildManifest = {\n buildId: randomBytes(8).toString(\"hex\"),\n entryPoint: BUILD_ENTRY_NAME,\n createdAt: new Date().toISOString(),\n inspector,\n };\n await mkdir(paths.build, { recursive: true });\n await writeFile(\n paths.buildManifest,\n `${JSON.stringify(manifest, null, 2)}\\n`\n );\n\n const duration = Math.round(performance.now() - startedAt);\n console.log(\n `[mcp-use] built ${relative(options.cwd, entry)} → ` +\n `${relative(options.cwd, paths.build)}/${BUILD_ENTRY_NAME} (${duration}ms)`\n );\n return;\n }\n\n await rm(paths.build, { recursive: true, force: true });\n\n const viewsOutDir = join(paths.build, \"views\");\n await mkdir(viewsOutDir, { recursive: true });\n\n const bindingServer = await createBindingValidationServer(\n options.cwd,\n paths.cache,\n false\n );\n let buildBasePath: string;\n try {\n buildBasePath = await resolveBuildBasePath(\n bindingServer.environments.ssr,\n entry\n );\n } catch (error) {\n await bindingServer.close();\n throw error;\n }\n\n const viewsManifest: ViewsManifest = {};\n const buildAssetsBase = readBuildAssetsBase();\n for (const view of views) {\n let manifestEntry = await buildExternalView(view, {\n cwd: options.cwd,\n cacheDir: paths.cache,\n viewsOutDir,\n userViteConfig,\n });\n if (buildAssetsBase !== undefined) {\n manifestEntry = applyBuildAssetsPrefix(\n manifestEntry,\n view.name,\n buildAssetsBase,\n buildBasePath\n );\n }\n viewsManifest[view.name] = manifestEntry;\n }\n\n if (buildAssetsBase !== undefined) {\n console.log(\n `[mcp-use] MCP_ASSETS_URL set — manifest uses CDN URLs; upload ` +\n `${relative(options.cwd, viewsOutDir)}/ to your asset host.`\n );\n if (buildBasePath !== \"/mcp\") {\n console.log(\n `[mcp-use] CDN manifest uses basePath ${buildBasePath} from server entry`\n );\n }\n }\n\n const publicSrc = join(options.cwd, \"public\");\n if (existsSync(publicSrc)) {\n await cp(publicSrc, join(viewsOutDir, \"public\"), { recursive: true });\n }\n\n try {\n await validateViewBindingsAtBuild(\n bindingServer.environments.ssr,\n entry,\n viewsManifest\n );\n } finally {\n await bindingServer.close();\n }\n\n const wrapperEntry = await writeWrapperEntry(\n paths.cache,\n entry,\n viewsManifest\n );\n\n await build({\n root: options.cwd,\n configFile: false,\n envFile: false,\n logLevel: \"warn\",\n cacheDir: paths.cache,\n build: {\n ssr: wrapperEntry,\n outDir: paths.build,\n emptyOutDir: false,\n target: \"node24\",\n sourcemap: true,\n minify: false,\n rollupOptions: {\n output: {\n format: \"es\",\n entryFileNames: BUILD_ENTRY_NAME,\n },\n },\n },\n ssr: {\n external: true,\n target: \"node\",\n },\n });\n\n const manifest: BuildManifest = {\n buildId: randomBytes(8).toString(\"hex\"),\n entryPoint: BUILD_ENTRY_NAME,\n createdAt: new Date().toISOString(),\n inspector,\n };\n await mkdir(paths.build, { recursive: true });\n await writeFile(\n paths.buildManifest,\n `${JSON.stringify(manifest, null, 2)}\\n`\n );\n\n const duration = Math.round(performance.now() - startedAt);\n const viewNames = views.map((v) => v.name).join(\", \");\n console.log(\n `[mcp-use] built ${relative(options.cwd, entry)} + views (${viewNames}) → ` +\n `${relative(options.cwd, paths.build)}/${BUILD_ENTRY_NAME} (${duration}ms)`\n );\n}\n","/**\n * Build-time view binding validation via mount-time checks.\n */\n\nimport { createServerModuleRunner, type DevEnvironment } from \"vite\";\n\nimport type { ViewsManifest } from \"../views/types.js\";\n\nconst DEFAULT_BASE_PATH = \"/mcp\";\n\n/** Synthetic origin for entry evaluation when OAuth needs MCP_URL at import. */\nconst BUILD_ENTRY_MCP_URL = \"http://localhost:3000\";\n\n/**\n * Duck-typed server shape needed for binding validation.\n *\n * @internal\n */\ninterface ServerLike {\n getHandler(): unknown;\n __primeViews(views: ViewsManifest, options?: { dev?: boolean }): void;\n basePath?: string;\n}\n\n/**\n * Import the server entry and read `basePath` from the default export.\n *\n * Does not prime views or call `getHandler()`. Sets a synthetic `MCP_URL` only\n * when unset so OAuth entries can construct during build introspection.\n *\n * @internal\n */\nexport async function resolveBuildBasePath(\n environment: DevEnvironment,\n entry: string\n): Promise<string> {\n const runner = createServerModuleRunner(environment, {\n hmr: false,\n sourcemapInterceptor: \"node\",\n });\n\n const previousMcpUrl = process.env[\"MCP_URL\"];\n try {\n if (previousMcpUrl === undefined) {\n process.env[\"MCP_URL\"] = BUILD_ENTRY_MCP_URL;\n }\n\n const serverModule = (await runner.import(entry)) as {\n default?: ServerLike;\n };\n const server = serverModule.default;\n if (server === null || typeof server !== \"object\") {\n throw new Error(\n \"The server entry must default-export the MCPServer instance.\"\n );\n }\n\n return server.basePath ?? DEFAULT_BASE_PATH;\n } finally {\n if (previousMcpUrl === undefined) {\n delete process.env[\"MCP_URL\"];\n } else {\n process.env[\"MCP_URL\"] = previousMcpUrl;\n }\n await runner.close();\n }\n}\n\n/**\n * Prime the server with the manifest and run mount-time binding validation\n * by calling `getHandler()`.\n *\n * Surfaces the same errors as runtime mount: missing primed view, missing\n * `outputSchema`, double binding. Unbound views emit a warning to stderr.\n *\n * @param environment - Vite SSR environment for module evaluation.\n * @param entry - Absolute path to the user's server entry.\n * @param viewsManifest - Built or dev-shaped manifest to prime.\n * @throws On binding hard errors (naming the view/tool).\n *\n * @internal\n */\nexport async function validateViewBindingsAtBuild(\n environment: DevEnvironment,\n entry: string,\n viewsManifest: ViewsManifest\n): Promise<void> {\n const runner = createServerModuleRunner(environment, {\n hmr: false,\n sourcemapInterceptor: \"node\",\n });\n\n try {\n const serverModule = (await runner.import(entry)) as {\n default?: ServerLike;\n };\n const server = serverModule.default;\n if (server === null || typeof server !== \"object\") {\n throw new Error(\n \"The server entry must default-export the MCPServer instance.\"\n );\n }\n\n if (typeof server.__primeViews !== \"function\") {\n throw new Error(\n \"The entry's default export does not support __primeViews.\"\n );\n }\n server.__primeViews(viewsManifest);\n server.getHandler();\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,IAAI,OAAO,IAAI,iBAAiB;AACzC,SAAS,MAAM,gBAAgB;AAC/B,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,SAAS,aAAa;;;AClBtB,SAAS,gCAAqD;AAI9D,IAAM,oBAAoB;AAG1B,IAAM,sBAAsB;AAqB5B,eAAsB,qBACpB,aACA,OACiB;AACjB,QAAM,SAAS,yBAAyB,aAAa;AAAA,IACnD,KAAK;AAAA,IACL,sBAAsB;AAAA,EACxB,CAAC;AAED,QAAM,iBAAiB,QAAQ,IAAI,SAAS;AAC5C,MAAI;AACF,QAAI,mBAAmB,QAAW;AAChC,cAAQ,IAAI,SAAS,IAAI;AAAA,IAC3B;AAEA,UAAM,eAAgB,MAAM,OAAO,OAAO,KAAK;AAG/C,UAAM,SAAS,aAAa;AAC5B,QAAI,WAAW,QAAQ,OAAO,WAAW,UAAU;AACjD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,OAAO,YAAY;AAAA,EAC5B,UAAE;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est","duration"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/build.ts","../../src/cli/views-bindings.ts"],"sourcesContent":["/**\n * `mcp-use build` — Vite SSR/node build of the user's server entry into the\n * `.mcp-use/build/` workspace directory (CLI_SPEC.md § Commands → build).\n *\n * When views exist (under `resources/<name>/view.tsx`), also runs a client-environment\n * build per view (hashed assets on disk), validates bindings, and emits a\n * wrapper entry that primes views before re-exporting the server (VIEWS_SPEC.md §\n * Build system).\n *\n * `vite` is an optional peer dependency of `mcp-use` (never a regular\n * dependency): this module is only ever reached through the bin's dynamic\n * `import(\"./cli/index.js\")`, so a missing install surfaces as a rejected\n * promise there (classified by `bin/main.ts`'s `isViteMissing`), not at\n * package load time.\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport { cp, mkdir, rm, writeFile } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\nimport tailwindcss from \"@tailwindcss/vite\";\nimport react from \"@vitejs/plugin-react\";\nimport { build } from \"vite\";\n\nimport { discoverEntry } from \"./entry.js\";\nimport { mcpUseViewsPlugin } from \"./views-plugin.js\";\nimport { ensureToolsDeclaration } from \"./tools-declaration.js\";\nimport {\n resolveBuildBasePath,\n validateViewBindingsAtBuild,\n} from \"./views-bindings.js\";\nimport {\n createBindingValidationServer,\n discoverViews,\n virtualViewId,\n type DiscoveredView,\n} from \"./views.js\";\nimport { resolveTailwindCss, resolveUserViteConfig } from \"./vite-config.js\";\nimport { resolveWorkspacePaths, type BuildManifest } from \"./workspace.js\";\nimport { normalizeAssetsBaseUrl } from \"../views/origin.js\";\nimport { viewAssetsBasePath } from \"../views/document.js\";\nimport type { ViewsManifest } from \"../views/types.js\";\n\n/** Fixed filename of the emitted server entry inside `.mcp-use/build/`. */\nconst BUILD_ENTRY_NAME = \"index.js\";\n\nconst WRAPPER_BASENAME = \"entry-wrapper.ts\";\n\n/** Inline imported assets as data URLs up to this byte size (effectively all). */\nconst ASSETS_INLINE_LIMIT = 100 * 1024 * 1024;\n\nasync function copyPublicAssets(cwd: string, outputDir: string): Promise<void> {\n const publicSrc = join(cwd, \"public\");\n if (existsSync(publicSrc)) {\n await cp(publicSrc, outputDir, { recursive: true });\n }\n}\n\n/**\n * Options for {@link runBuild}.\n *\n * @internal\n */\nexport interface BuildOptions {\n /** Absolute path to the project root (the directory containing the entry). */\n cwd: string;\n /**\n * Explicit entry path (the `--entry` flag), absolute or relative to `cwd`.\n *\n * @defaultValue Conventional discovery: `src/index.ts`, `src/server.ts`,\n * `index.ts`, `server.ts` — first hit wins.\n */\n entry?: string;\n /**\n * When true (`mcp-use build --with-inspector`), record `inspector: true`\n * in the build manifest.\n */\n withInspector?: boolean;\n}\n\n/**\n * Emit a short-lived wrapper module under `.mcp-use/cache/` that primes views\n * before re-exporting the user's entry (VIEWS_SPEC.md § Registration mechanism).\n */\nasync function writeWrapperEntry(\n cacheDir: string,\n userEntry: string,\n viewsManifest: ViewsManifest\n): Promise<string> {\n const wrapperPath = join(cacheDir, WRAPPER_BASENAME);\n await mkdir(cacheDir, { recursive: true });\n const manifestJson = JSON.stringify(viewsManifest);\n await writeFile(\n wrapperPath,\n [\n `import server from ${JSON.stringify(userEntry)};`,\n `import { registerViews } from \"mcp-use\";`,\n `server[registerViews](${manifestJson});`,\n `export default server;`,\n \"\",\n ].join(\"\\n\")\n );\n return wrapperPath;\n}\n\nfunction readBuildAssetsBase(): string | undefined {\n const raw = process.env[\"MCP_ASSETS_URL\"];\n if (raw === undefined || raw.trim() === \"\") {\n return undefined;\n }\n try {\n return normalizeAssetsBaseUrl(new URL(raw).href.replace(/\\/$/, \"\"));\n } catch {\n return undefined;\n }\n}\n\n/** Rewrite a view-relative manifest path to a full CDN URL at build time. */\nfunction toCdnAssetUrl(\n relativePath: string,\n viewName: string,\n assetsBase: string,\n basePath: string\n): string {\n const clean = relativePath.replace(/^\\/+/, \"\");\n return `${assetsBase}${viewAssetsBasePath(basePath, viewName)}${clean}`;\n}\n\nfunction applyBuildAssetsPrefix(\n entry: ViewsManifest[string],\n viewName: string,\n assetsBase: string,\n basePath: string\n): ViewsManifest[string] {\n if (entry.kind !== \"external\") {\n return entry;\n }\n return {\n ...entry,\n entry: toCdnAssetUrl(entry.entry, viewName, assetsBase, basePath),\n css: entry.css.map((path) =>\n toCdnAssetUrl(path, viewName, assetsBase, basePath)\n ),\n ...(entry.scripts !== undefined && {\n scripts: entry.scripts.map((path) =>\n toCdnAssetUrl(path, viewName, assetsBase, basePath)\n ),\n }),\n };\n}\n\n/**\n * Build one view into hashed assets on disk, then record view-relative paths\n * in the manifest (served over HTTP at runtime).\n */\nasync function buildExternalView(\n view: DiscoveredView,\n options: {\n cwd: string;\n cacheDir: string;\n viewsOutDir: string;\n userViteConfig: string | false;\n }\n): Promise<ViewsManifest[string]> {\n const viewOutDir = join(options.viewsOutDir, view.name);\n const clientResult = await build({\n root: options.cwd,\n configFile: options.userViteConfig,\n envFile: false,\n logLevel: \"warn\",\n cacheDir: options.cacheDir,\n resolve: { alias: { tailwindcss: resolveTailwindCss() } },\n plugins: [\n tailwindcss(),\n react(),\n mcpUseViewsPlugin({ getViews: () => [view] }),\n ],\n build: {\n outDir: viewOutDir,\n emptyOutDir: true,\n target: \"es2022\",\n sourcemap: false,\n minify: true,\n cssCodeSplit: false,\n assetsInlineLimit: ASSETS_INLINE_LIMIT,\n rollupOptions: {\n input: { [view.name]: virtualViewId(view.name) },\n output: {\n format: \"es\",\n codeSplitting: false,\n entryFileNames: \"assets/[name]-[hash].js\",\n assetFileNames: \"assets/[name]-[hash][extname]\",\n },\n },\n },\n base: \"./\",\n });\n\n const clientOutput = Array.isArray(clientResult)\n ? clientResult[0]\n : clientResult;\n if (clientOutput === undefined || !(\"output\" in clientOutput)) {\n throw new Error(`Client build for view \"${view.name}\" produced no output.`);\n }\n\n const rawOutput = clientOutput.output;\n const items = Array.isArray(rawOutput) ? rawOutput : Object.values(rawOutput);\n\n let jsFileName: string | undefined;\n let cssFileName: string | undefined;\n\n for (const item of items) {\n if (typeof item !== \"object\" || item === null || !(\"fileName\" in item)) {\n continue;\n }\n const fileName = (item as { fileName: unknown }).fileName;\n if (typeof fileName !== \"string\") {\n continue;\n }\n const typed = item as {\n type?: string;\n isEntry?: boolean;\n fileName: string;\n };\n if (typed.type === \"chunk\" && typed.isEntry === true) {\n jsFileName = typed.fileName;\n } else if (typed.type === \"asset\" && typed.fileName.endsWith(\".css\")) {\n cssFileName = typed.fileName;\n }\n }\n\n if (jsFileName === undefined) {\n throw new Error(\n `Client build produced no entry chunk for view \"${view.name}\".`\n );\n }\n\n return {\n kind: \"external\",\n entry: jsFileName.replace(/^\\/+/, \"\"),\n css: cssFileName !== undefined ? [cssFileName.replace(/^\\/+/, \"\")] : [],\n };\n}\n\n/**\n * Build the project's server for production: a Vite build of the SSR/node\n * environment only (the client environment for views arrives with\n * VIEWS_SPEC.md), emitted as ESM to `.mcp-use/build/` with a `manifest.json`\n * alongside it.\n *\n * Dependencies stay external (`ssr: { external: true }`): only the\n * user's own source is bundled; every bare import resolves from\n * `node_modules` at runtime. The built entry preserves the default export\n * (the `MCPServer` instance) so `mcp-use start` can import and serve it.\n *\n * There is deliberately no typecheck step — the build is transpile-only;\n * users run `tsc --noEmit` via their own script.\n *\n * @param options - Project root and optional entry override.\n * @throws If no entry is found (see {@link discoverEntry}), or if `vite` is\n * not installed (`mcp-use build` requires it as a devDependency) — the\n * `import(\"vite\")` rejection propagates to the bin's dispatch boundary,\n * which classifies it and prints the install hint.\n *\n * @internal Reached only via the bin's `import(\"./cli/index.js\")`\n * dispatch (`bin/main.ts`) — not re-exported from the package's \".\" entry.\n */\nexport async function runBuild(options: BuildOptions): Promise<void> {\n const startedAt = performance.now();\n const entry = discoverEntry(options.cwd, options.entry);\n if (await ensureToolsDeclaration(options.cwd, entry)) {\n console.log(\"[mcp-use] created tools.d.ts\");\n }\n const paths = resolveWorkspacePaths(options.cwd);\n const views = discoverViews(options.cwd);\n const userViteConfig = resolveUserViteConfig(options.cwd);\n const inspector = options.withInspector === true;\n\n if (views.length === 0) {\n await build({\n root: options.cwd,\n configFile: false,\n envFile: false,\n logLevel: \"warn\",\n cacheDir: paths.cache,\n build: {\n ssr: entry,\n outDir: paths.build,\n emptyOutDir: true,\n target: \"node24\",\n sourcemap: true,\n minify: false,\n rollupOptions: {\n output: {\n format: \"es\",\n entryFileNames: BUILD_ENTRY_NAME,\n },\n },\n },\n ssr: {\n external: true,\n target: \"node\",\n },\n });\n\n // Branding may reference project-public icon files even when the server\n // has no views. Keep the runtime public-asset location identical in both\n // shapes so `mcp-use start` and serverless built entries behave alike.\n await copyPublicAssets(options.cwd, join(paths.build, \"views/public\"));\n\n const manifest: BuildManifest = {\n buildId: randomBytes(8).toString(\"hex\"),\n entryPoint: BUILD_ENTRY_NAME,\n createdAt: new Date().toISOString(),\n inspector,\n };\n await mkdir(paths.build, { recursive: true });\n await writeFile(\n paths.buildManifest,\n `${JSON.stringify(manifest, null, 2)}\\n`\n );\n\n const duration = Math.round(performance.now() - startedAt);\n console.log(\n `[mcp-use] built ${relative(options.cwd, entry)} → ` +\n `${relative(options.cwd, paths.build)}/${BUILD_ENTRY_NAME} (${duration}ms)`\n );\n return;\n }\n\n await rm(paths.build, { recursive: true, force: true });\n\n const viewsOutDir = join(paths.build, \"views\");\n await mkdir(viewsOutDir, { recursive: true });\n\n const bindingServer = await createBindingValidationServer(\n options.cwd,\n paths.cache,\n false\n );\n let buildBasePath: string;\n try {\n buildBasePath = await resolveBuildBasePath(\n bindingServer.environments.ssr,\n entry\n );\n } catch (error) {\n await bindingServer.close();\n throw error;\n }\n\n const viewsManifest: ViewsManifest = {};\n const buildAssetsBase = readBuildAssetsBase();\n for (const view of views) {\n let manifestEntry = await buildExternalView(view, {\n cwd: options.cwd,\n cacheDir: paths.cache,\n viewsOutDir,\n userViteConfig,\n });\n if (buildAssetsBase !== undefined) {\n manifestEntry = applyBuildAssetsPrefix(\n manifestEntry,\n view.name,\n buildAssetsBase,\n buildBasePath\n );\n }\n viewsManifest[view.name] = manifestEntry;\n }\n\n if (buildAssetsBase !== undefined) {\n console.log(\n `[mcp-use] MCP_ASSETS_URL set — manifest uses CDN URLs; upload ` +\n `${relative(options.cwd, viewsOutDir)}/ to your asset host.`\n );\n if (buildBasePath !== \"/mcp\") {\n console.log(\n `[mcp-use] CDN manifest uses basePath ${buildBasePath} from server entry`\n );\n }\n }\n\n await copyPublicAssets(options.cwd, join(viewsOutDir, \"public\"));\n\n try {\n await validateViewBindingsAtBuild(\n bindingServer.environments.ssr,\n entry,\n viewsManifest\n );\n } finally {\n await bindingServer.close();\n }\n\n const wrapperEntry = await writeWrapperEntry(\n paths.cache,\n entry,\n viewsManifest\n );\n\n await build({\n root: options.cwd,\n configFile: false,\n envFile: false,\n logLevel: \"warn\",\n cacheDir: paths.cache,\n build: {\n ssr: wrapperEntry,\n outDir: paths.build,\n emptyOutDir: false,\n target: \"node24\",\n sourcemap: true,\n minify: false,\n rollupOptions: {\n output: {\n format: \"es\",\n entryFileNames: BUILD_ENTRY_NAME,\n },\n },\n },\n ssr: {\n external: true,\n target: \"node\",\n },\n });\n\n const manifest: BuildManifest = {\n buildId: randomBytes(8).toString(\"hex\"),\n entryPoint: BUILD_ENTRY_NAME,\n createdAt: new Date().toISOString(),\n inspector,\n };\n await mkdir(paths.build, { recursive: true });\n await writeFile(\n paths.buildManifest,\n `${JSON.stringify(manifest, null, 2)}\\n`\n );\n\n const duration = Math.round(performance.now() - startedAt);\n const viewNames = views.map((v) => v.name).join(\", \");\n console.log(\n `[mcp-use] built ${relative(options.cwd, entry)} + views (${viewNames}) → ` +\n `${relative(options.cwd, paths.build)}/${BUILD_ENTRY_NAME} (${duration}ms)`\n );\n}\n","/**\n * Build-time view binding validation via mount-time checks.\n */\n\nimport { createServerModuleRunner, type DevEnvironment } from \"vite\";\n\nimport type { ViewsManifest } from \"../views/types.js\";\n\nconst DEFAULT_BASE_PATH = \"/mcp\";\n\n/** Synthetic origin for entry evaluation when OAuth needs MCP_URL at import. */\nconst BUILD_ENTRY_MCP_URL = \"http://localhost:3000\";\n\n/**\n * Duck-typed server shape needed for binding validation.\n *\n * @internal\n */\ninterface ServerLike {\n getHandler(): unknown;\n __primeViews(views: ViewsManifest, options?: { dev?: boolean }): void;\n basePath?: string;\n}\n\n/**\n * Import the server entry and read `basePath` from the default export.\n *\n * Does not prime views or call `getHandler()`. Sets a synthetic `MCP_URL` only\n * when unset so OAuth entries can construct during build introspection.\n *\n * @internal\n */\nexport async function resolveBuildBasePath(\n environment: DevEnvironment,\n entry: string\n): Promise<string> {\n const runner = createServerModuleRunner(environment, {\n hmr: false,\n sourcemapInterceptor: \"node\",\n });\n\n const previousMcpUrl = process.env[\"MCP_URL\"];\n try {\n if (previousMcpUrl === undefined) {\n process.env[\"MCP_URL\"] = BUILD_ENTRY_MCP_URL;\n }\n\n const serverModule = (await runner.import(entry)) as {\n default?: ServerLike;\n };\n const server = serverModule.default;\n if (server === null || typeof server !== \"object\") {\n throw new Error(\n \"The server entry must default-export the MCPServer instance.\"\n );\n }\n\n return server.basePath ?? DEFAULT_BASE_PATH;\n } finally {\n if (previousMcpUrl === undefined) {\n delete process.env[\"MCP_URL\"];\n } else {\n process.env[\"MCP_URL\"] = previousMcpUrl;\n }\n await runner.close();\n }\n}\n\n/**\n * Prime the server with the manifest and run mount-time binding validation\n * by calling `getHandler()`.\n *\n * Surfaces the same errors as runtime mount: missing primed view, missing\n * `outputSchema`, double binding. Unbound views emit a warning to stderr.\n *\n * @param environment - Vite SSR environment for module evaluation.\n * @param entry - Absolute path to the user's server entry.\n * @param viewsManifest - Built or dev-shaped manifest to prime.\n * @throws On binding hard errors (naming the view/tool).\n *\n * @internal\n */\nexport async function validateViewBindingsAtBuild(\n environment: DevEnvironment,\n entry: string,\n viewsManifest: ViewsManifest\n): Promise<void> {\n const runner = createServerModuleRunner(environment, {\n hmr: false,\n sourcemapInterceptor: \"node\",\n });\n\n try {\n const serverModule = (await runner.import(entry)) as {\n default?: ServerLike;\n };\n const server = serverModule.default;\n if (server === null || typeof server !== \"object\") {\n throw new Error(\n \"The server entry must default-export the MCPServer instance.\"\n );\n }\n\n if (typeof server.__primeViews !== \"function\") {\n throw new Error(\n \"The entry's default export does not support __primeViews.\"\n );\n }\n server.__primeViews(viewsManifest);\n server.getHandler();\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,IAAI,OAAO,IAAI,iBAAiB;AACzC,SAAS,MAAM,gBAAgB;AAC/B,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,SAAS,aAAa;;;AClBtB,SAAS,gCAAqD;AAI9D,IAAM,oBAAoB;AAG1B,IAAM,sBAAsB;AAqB5B,eAAsB,qBACpB,aACA,OACiB;AACjB,QAAM,SAAS,yBAAyB,aAAa;AAAA,IACnD,KAAK;AAAA,IACL,sBAAsB;AAAA,EACxB,CAAC;AAED,QAAM,iBAAiB,QAAQ,IAAI,SAAS;AAC5C,MAAI;AACF,QAAI,mBAAmB,QAAW;AAChC,cAAQ,IAAI,SAAS,IAAI;AAAA,IAC3B;AAEA,UAAM,eAAgB,MAAM,OAAO,OAAO,KAAK;AAG/C,UAAM,SAAS,aAAa;AAC5B,QAAI,WAAW,QAAQ,OAAO,WAAW,UAAU;AACjD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,OAAO,YAAY;AAAA,EAC5B,UAAE;AACA,QAAI,mBAAmB,QAAW;AAChC,aAAO,QAAQ,IAAI,SAAS;AAAA,IAC9B,OAAO;AACL,cAAQ,IAAI,SAAS,IAAI;AAAA,IAC3B;AACA,UAAM,OAAO,MAAM;AAAA,EACrB;AACF;AAgBA,eAAsB,4BACpB,aACA,OACA,eACe;AACf,QAAM,SAAS,yBAAyB,aAAa;AAAA,IACnD,KAAK;AAAA,IACL,sBAAsB;AAAA,EACxB,CAAC;AAED,MAAI;AACF,UAAM,eAAgB,M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AAAA,IACA;AAAA,EACF;AAEA,QAAM,MAAM;AAAA,IACV,MAAM,QAAQ;AAAA,IACd,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,UAAU,MAAM;AAAA,IAChB,OAAO;AAAA,MACL,KAAK;AAAA,MACL,QAAQ,MAAM;AAAA,MACd,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,eAAe;AAAA,QACb,QAAQ;AAAA,UACN,QAAQ;AAAA,UACR,gBAAgB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,EACF,CAAC;AAED,QAAM,WAA0B;AAAA,IAC9B,SAAS,YAAY,CAAC,EAAE,SAAS,KAAK;AAAA,IACtC,YAAY;AAAA,IACZ,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,IAClC;AAAA,EACF;AACA,QAAM,MAAM,MAAM,OAAO,EAAE,WAAW,KAAK,CAAC;AAC5C,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA;AAAA,EACtC;AAEA,QAAM,WAAW,KAAK,MAAM,YAAY,IAAI,IAAI,SAAS;AACzD,QAAM,YAAY,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI;AACpD,UAAQ;AAAA,IACN,mBAAmB,SAAS,QAAQ,KAAK,KAAK,CAAC,aAAa,SAAS,YAChE,SAAS,QAAQ,KAAK,MAAM,KAAK,CAAC,IAAI,gBAAgB,KAAK,QAAQ;AAAA,EAC1E;AACF;","names":["manifest","duration"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServerOptions } from "@modelcontextprotocol/server";
|
|
1
|
+
import type { Icon, ServerOptions } from "@modelcontextprotocol/server";
|
|
2
2
|
import type { LoggingOptions } from "./logging.js";
|
|
3
3
|
import type { OAuthProvider } from "./oauth/index.js";
|
|
4
4
|
/**
|
|
@@ -47,6 +47,74 @@ interface BaseServerConfig {
|
|
|
47
47
|
* implementation metadata during negotiation.
|
|
48
48
|
*/
|
|
49
49
|
description?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Browser favicon source.
|
|
52
|
+
*
|
|
53
|
+
* Accepts a safe path relative to the project `public/` directory, an
|
|
54
|
+
* absolute HTTP(S) URL, or an image data URL. The selected image is served
|
|
55
|
+
* at the root-level `/favicon.ico` route. When omitted, the `icons` field
|
|
56
|
+
* selects the favicon using ICO, small PNG, any PNG, then first-icon order.
|
|
57
|
+
* An explicit value always wins; an empty string is invalid.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue Inferred from `icons`, or no favicon when `icons` is absent
|
|
60
|
+
* or empty.
|
|
61
|
+
* @throws TypeError When the value is empty, uses an unsupported URL scheme,
|
|
62
|
+
* or is an unsafe local path.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* new MCPServer({
|
|
67
|
+
* name: "my-server",
|
|
68
|
+
* version: "1.0.0",
|
|
69
|
+
* favicon: "brand/favicon.svg",
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
favicon?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Server icons reported to clients in MCP implementation metadata.
|
|
76
|
+
*
|
|
77
|
+
* Uses the official SDK {@link Icon} shape. Each `src` accepts a safe path
|
|
78
|
+
* relative to `public/`, an absolute HTTP(S) URL, or an image data URL.
|
|
79
|
+
* Local paths become request-scoped absolute URLs under
|
|
80
|
+
* `${basePath}/_mcp-use/public/`; author order is preserved on the wire.
|
|
81
|
+
* When `favicon` is omitted, these icons also select `/favicon.ico`.
|
|
82
|
+
* An empty array is valid and selects no favicon.
|
|
83
|
+
*
|
|
84
|
+
* @defaultValue `undefined`
|
|
85
|
+
* @throws TypeError When an icon has an invalid source, MIME type, sizes,
|
|
86
|
+
* or theme.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* new MCPServer({
|
|
91
|
+
* name: "my-server",
|
|
92
|
+
* version: "1.0.0",
|
|
93
|
+
* icons: [
|
|
94
|
+
* { src: "brand/icon.svg", mimeType: "image/svg+xml" },
|
|
95
|
+
* { src: "brand/icon-32.png", mimeType: "image/png", sizes: ["32x32"] },
|
|
96
|
+
* ],
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
icons?: Icon[];
|
|
101
|
+
/**
|
|
102
|
+
* Absolute HTTP(S) URL for the server's website or documentation, reported
|
|
103
|
+
* to clients in MCP implementation metadata.
|
|
104
|
+
*
|
|
105
|
+
* @defaultValue `undefined`
|
|
106
|
+
* @throws TypeError When the value is empty, relative, or not HTTP(S).
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* new MCPServer({
|
|
111
|
+
* name: "my-server",
|
|
112
|
+
* version: "1.0.0",
|
|
113
|
+
* websiteUrl: "https://example.com/my-server",
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
websiteUrl?: string;
|
|
50
118
|
/** Usage instructions surfaced to the model by clients. */
|
|
51
119
|
instructions?: string;
|
|
52
120
|
/**
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAExE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,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ACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC;IACxE,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,4BAA4B;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAqBvE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,CAAC,KAAK,GAAG,KAAK,IAAI,gBAAgB,GACxD,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GACpB;IACE,wEAAwE;IACxE,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GACD;IACE;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC7B,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,9 @@ export type { CompletionCallback, CompletionContext } from "./completable.js";
|
|
|
42
42
|
*/
|
|
43
43
|
export type { StandardSchemaV1, StandardSchemaWithJSON, } from "@modelcontextprotocol/server";
|
|
44
44
|
export type { InspectorOptions, ServerConfig, CorsOptions } from "./config.js";
|
|
45
|
+
export type { ServerBranding } from "./branding.js";
|
|
46
|
+
/** Official MCP icon shape used by {@link ServerConfig.icons}. */
|
|
47
|
+
export type { Icon } from "@modelcontextprotocol/server";
|
|
45
48
|
export type { MiddlewareContext, McpCompleteEventListenerFn, McpEventListenerFn, McpMiddlewareFn, McpMiddlewareFnFor, McpMiddlewarePatternMap, PromptsGetMiddlewareContext, ResourcesReadMiddlewareContext, ToolsCallMiddlewareContext, } from "./middleware/mcp-middleware.js";
|
|
46
49
|
export { composeMiddleware, matchesPattern, } from "./middleware/mcp-middleware.js";
|
|
47
50
|
export type { NodeRequestHandler } from "./node-bridge.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,wBAAwB,EACxB,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,UAAU,EACV,UAAU,EACV,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7D,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,YAAY,EACV,c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