@igstack/app-catalog-frontend-core 6.15.0 → 6.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/api/infra/trpc.d.ts +36 -0
- package/dist/esm/internal.d.ts +1 -0
- package/dist/esm/internal.js +2 -0
- package/dist/esm/internal.js.map +1 -1
- package/dist/esm/lib/externalLink.d.ts +8 -0
- package/dist/esm/lib/externalLink.js +9 -0
- package/dist/esm/lib/externalLink.js.map +1 -0
- package/dist/esm/modules/appCatalog/context/AppCatalogContext.d.ts +3 -1
- package/dist/esm/modules/appCatalog/context/AppCatalogContext.js +2 -0
- package/dist/esm/modules/appCatalog/context/AppCatalogContext.js.map +1 -1
- package/dist/esm/modules/appCatalog/hooks/useUpdateApp.d.ts +36 -36
- package/dist/esm/modules/appCatalog/ui/components/SectionTabs.d.ts +2 -1
- package/dist/esm/modules/appCatalog/ui/components/SectionTabs.js +11 -1
- package/dist/esm/modules/appCatalog/ui/components/SectionTabs.js.map +1 -1
- package/dist/esm/modules/appCatalog/ui/components/SourcesList.d.ts +10 -0
- package/dist/esm/modules/appCatalog/ui/components/SourcesList.js +51 -0
- package/dist/esm/modules/appCatalog/ui/components/SourcesList.js.map +1 -0
- package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js +9 -52
- package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js.map +1 -1
- package/dist/esm/modules/communityTools/useCommunityTools.d.ts +6 -6
- package/dist/esm/modules/mcpCatalog/McpAccessLine.d.ts +5 -0
- package/dist/esm/modules/mcpCatalog/McpAccessLine.js +48 -0
- package/dist/esm/modules/mcpCatalog/McpAccessLine.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpCatalogPage.d.ts +11 -0
- package/dist/esm/modules/mcpCatalog/McpCatalogPage.js +289 -0
- package/dist/esm/modules/mcpCatalog/McpCatalogPage.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpInfoTiles.d.ts +5 -0
- package/dist/esm/modules/mcpCatalog/McpInfoTiles.js +88 -0
- package/dist/esm/modules/mcpCatalog/McpInfoTiles.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpSafetyLines.d.ts +5 -0
- package/dist/esm/modules/mcpCatalog/McpSafetyLines.js +82 -0
- package/dist/esm/modules/mcpCatalog/McpSafetyLines.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpSearchResult.d.ts +18 -0
- package/dist/esm/modules/mcpCatalog/McpSearchResult.js +150 -0
- package/dist/esm/modules/mcpCatalog/McpSearchResult.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpServerDetail.d.ts +8 -0
- package/dist/esm/modules/mcpCatalog/McpServerDetail.js +116 -0
- package/dist/esm/modules/mcpCatalog/McpServerDetail.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpServerRow.d.ts +10 -0
- package/dist/esm/modules/mcpCatalog/McpServerRow.js +75 -0
- package/dist/esm/modules/mcpCatalog/McpServerRow.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/McpToolsTable.d.ts +5 -0
- package/dist/esm/modules/mcpCatalog/McpToolsTable.js +24 -0
- package/dist/esm/modules/mcpCatalog/McpToolsTable.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/Triad.d.ts +13 -0
- package/dist/esm/modules/mcpCatalog/Triad.js +175 -0
- package/dist/esm/modules/mcpCatalog/Triad.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/cart/McpCart.d.ts +15 -0
- package/dist/esm/modules/mcpCatalog/cart/McpCart.js +156 -0
- package/dist/esm/modules/mcpCatalog/cart/McpCart.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/cart/useMcpCart.d.ts +11 -0
- package/dist/esm/modules/mcpCatalog/cart/useMcpCart.js +48 -0
- package/dist/esm/modules/mcpCatalog/cart/useMcpCart.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/install/InstallButton.d.ts +12 -0
- package/dist/esm/modules/mcpCatalog/install/InstallButton.js +126 -0
- package/dist/esm/modules/mcpCatalog/install/InstallButton.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/install/InstallMenu.d.ts +14 -0
- package/dist/esm/modules/mcpCatalog/install/InstallMenu.js +139 -0
- package/dist/esm/modules/mcpCatalog/install/InstallMenu.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/install/WhatHappensDialog.d.ts +10 -0
- package/dist/esm/modules/mcpCatalog/install/WhatHappensDialog.js +161 -0
- package/dist/esm/modules/mcpCatalog/install/WhatHappensDialog.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/install/installOptions.d.ts +40 -0
- package/dist/esm/modules/mcpCatalog/install/installOptions.js +204 -0
- package/dist/esm/modules/mcpCatalog/install/installOptions.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/install/useMcpPrefs.d.ts +14 -0
- package/dist/esm/modules/mcpCatalog/install/useMcpPrefs.js +39 -0
- package/dist/esm/modules/mcpCatalog/install/useMcpPrefs.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/searchMcpServers.d.ts +25 -0
- package/dist/esm/modules/mcpCatalog/searchMcpServers.js +44 -0
- package/dist/esm/modules/mcpCatalog/searchMcpServers.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/signIn.d.ts +13 -0
- package/dist/esm/modules/mcpCatalog/signIn.js +29 -0
- package/dist/esm/modules/mcpCatalog/signIn.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/useHasMcpServers.d.ts +8 -0
- package/dist/esm/modules/mcpCatalog/useHasMcpServers.js +13 -0
- package/dist/esm/modules/mcpCatalog/useHasMcpServers.js.map +1 -0
- package/dist/esm/modules/mcpCatalog/useMcpCatalogConfig.d.ts +7 -0
- package/dist/esm/modules/mcpCatalog/useMcpCatalogConfig.js +16 -0
- package/dist/esm/modules/mcpCatalog/useMcpCatalogConfig.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/schemas.js +3 -3
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/api.js +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.js +1 -1
- package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js +2 -2
- package/dist/esm/routeTree.gen.d.ts +43 -17
- package/dist/esm/routeTree.gen.js +15 -3
- package/dist/esm/routeTree.gen.js.map +1 -1
- package/dist/esm/routes/_layout/community.$slug.d.ts +3 -3
- package/dist/esm/routes/_layout/community.d.ts +3 -3
- package/dist/esm/routes/_layout/mcp.$slug.d.ts +9 -0
- package/dist/esm/routes/_layout/mcp._slug.js +8 -0
- package/dist/esm/routes/_layout/mcp._slug.js.map +1 -0
- package/dist/esm/routes/_layout/mcp.d.ts +5 -1
- package/dist/esm/routes/_layout/mcp.js +45 -5
- package/dist/esm/routes/_layout/mcp.js.map +1 -1
- package/dist/esm/ui/button.d.ts +1 -1
- package/dist/esm/ui/components/header/Header.js +1 -5
- package/dist/esm/ui/components/header/Header.js.map +1 -1
- package/dist/esm/ui/empty.d.ts +1 -1
- package/dist/esm/ui/item.d.ts +1 -1
- package/dist/esm/userDb/AcDb.d.ts +10 -0
- package/dist/esm/userDb/AcDb.js +6 -0
- package/dist/esm/userDb/AcDb.js.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/modules/communityTools/timeAgo.test.ts +16 -0
- package/src/internal.ts +1 -0
- package/src/lib/externalLink.ts +10 -0
- package/src/modules/appCatalog/context/AppCatalogContext.tsx +5 -0
- package/src/modules/appCatalog/ui/components/SectionTabs.tsx +14 -1
- package/src/modules/appCatalog/ui/components/SourcesList.tsx +62 -0
- package/src/modules/appCatalog/ui/detail/AppDetails.tsx +6 -52
- package/src/modules/mcpCatalog/McpAccessLine.tsx +54 -0
- package/src/modules/mcpCatalog/McpCatalogPage.tsx +324 -0
- package/src/modules/mcpCatalog/McpInfoTiles.tsx +112 -0
- package/src/modules/mcpCatalog/McpSafetyLines.tsx +89 -0
- package/src/modules/mcpCatalog/McpSearchResult.tsx +173 -0
- package/src/modules/mcpCatalog/McpServerDetail.tsx +145 -0
- package/src/modules/mcpCatalog/McpServerRow.tsx +78 -0
- package/src/modules/mcpCatalog/McpToolsTable.tsx +36 -0
- package/src/modules/mcpCatalog/Triad.tsx +213 -0
- package/src/modules/mcpCatalog/cart/McpCart.tsx +171 -0
- package/src/modules/mcpCatalog/cart/useMcpCart.ts +64 -0
- package/src/modules/mcpCatalog/install/InstallButton.tsx +154 -0
- package/src/modules/mcpCatalog/install/InstallMenu.tsx +160 -0
- package/src/modules/mcpCatalog/install/WhatHappensDialog.tsx +199 -0
- package/src/modules/mcpCatalog/install/installOptions.tsx +266 -0
- package/src/modules/mcpCatalog/install/useMcpPrefs.ts +55 -0
- package/src/modules/mcpCatalog/searchMcpServers.ts +84 -0
- package/src/modules/mcpCatalog/signIn.ts +34 -0
- package/src/modules/mcpCatalog/useHasMcpServers.ts +22 -0
- package/src/modules/mcpCatalog/useMcpCatalogConfig.ts +20 -0
- package/src/routeTree.gen.ts +36 -5
- package/src/routes/_layout/mcp.$slug.tsx +10 -0
- package/src/routes/_layout/mcp.tsx +63 -3
- package/src/ui/components/header/Header.tsx +1 -7
- package/src/userDb/AcDb.ts +13 -0
- package/dist/esm/modules/appCatalog/ui/pages/McpPage.d.ts +0 -11
- package/dist/esm/modules/appCatalog/ui/pages/McpPage.js +0 -227
- package/dist/esm/modules/appCatalog/ui/pages/McpPage.js.map +0 -1
- package/dist/esm/modules/appCatalog/utils/fetchMcpTools.d.ts +0 -32
- package/dist/esm/modules/appCatalog/utils/fetchMcpTools.js +0 -79
- package/dist/esm/modules/appCatalog/utils/fetchMcpTools.js.map +0 -1
- package/src/modules/appCatalog/ui/pages/McpPage.tsx +0 -275
- package/src/modules/appCatalog/utils/fetchMcpTools.ts +0 -140
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const MCP_ENDPOINT_PATH = "/api/mcp";
|
|
2
|
-
function describeType(prop) {
|
|
3
|
-
var _a, _b;
|
|
4
|
-
const base = Array.isArray(prop.type) ? prop.type.join(" | ") : prop.type;
|
|
5
|
-
if (base === "array") {
|
|
6
|
-
const itemType = Array.isArray((_a = prop.items) == null ? void 0 : _a.type) ? prop.items.type.join(" | ") : (_b = prop.items) == null ? void 0 : _b.type;
|
|
7
|
-
return itemType ? `${itemType}[]` : "array";
|
|
8
|
-
}
|
|
9
|
-
return base;
|
|
10
|
-
}
|
|
11
|
-
function enumValues(prop) {
|
|
12
|
-
var _a;
|
|
13
|
-
const values = prop.enum ?? ((_a = prop.items) == null ? void 0 : _a.enum);
|
|
14
|
-
return (values == null ? void 0 : values.length) ? values.map(String) : void 0;
|
|
15
|
-
}
|
|
16
|
-
function parseBody(contentType, body) {
|
|
17
|
-
if (!contentType.includes("text/event-stream")) {
|
|
18
|
-
return JSON.parse(body);
|
|
19
|
-
}
|
|
20
|
-
const dataLines = body.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trim());
|
|
21
|
-
if (dataLines.length === 0) {
|
|
22
|
-
throw new Error("The server returned an empty event stream.");
|
|
23
|
-
}
|
|
24
|
-
return JSON.parse(dataLines.join(""));
|
|
25
|
-
}
|
|
26
|
-
async function fetchMcpTools(origin, signal) {
|
|
27
|
-
var _a;
|
|
28
|
-
const response = await fetch(`${origin}${MCP_ENDPOINT_PATH}`, {
|
|
29
|
-
method: "POST",
|
|
30
|
-
signal,
|
|
31
|
-
headers: {
|
|
32
|
-
"content-type": "application/json",
|
|
33
|
-
// The Streamable HTTP transport requires the client to accept both.
|
|
34
|
-
accept: "application/json, text/event-stream"
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify({
|
|
37
|
-
jsonrpc: "2.0",
|
|
38
|
-
id: 1,
|
|
39
|
-
method: "tools/list",
|
|
40
|
-
params: {}
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`The MCP endpoint answered ${response.status} ${response.statusText}.`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const payload = parseBody(
|
|
49
|
-
response.headers.get("content-type") ?? "",
|
|
50
|
-
await response.text()
|
|
51
|
-
);
|
|
52
|
-
if (payload.error) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
payload.error.message ?? "The MCP endpoint returned an error."
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
return (((_a = payload.result) == null ? void 0 : _a.tools) ?? []).map((tool) => {
|
|
58
|
-
var _a2, _b;
|
|
59
|
-
const properties = ((_a2 = tool.inputSchema) == null ? void 0 : _a2.properties) ?? {};
|
|
60
|
-
const required = new Set(((_b = tool.inputSchema) == null ? void 0 : _b.required) ?? []);
|
|
61
|
-
return {
|
|
62
|
-
name: tool.name,
|
|
63
|
-
title: tool.title,
|
|
64
|
-
description: tool.description,
|
|
65
|
-
parameters: Object.entries(properties).map(([name, prop]) => ({
|
|
66
|
-
name,
|
|
67
|
-
type: describeType(prop),
|
|
68
|
-
required: required.has(name),
|
|
69
|
-
description: prop.description,
|
|
70
|
-
enumValues: enumValues(prop)
|
|
71
|
-
}))
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
MCP_ENDPOINT_PATH,
|
|
77
|
-
fetchMcpTools
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=fetchMcpTools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchMcpTools.js","sources":["../../../../../src/modules/appCatalog/utils/fetchMcpTools.ts"],"sourcesContent":["/**\n * Minimal MCP client for the docs page: one `tools/list` call over Streamable\n * HTTP. Deliberately raw `fetch` rather than the MCP SDK — the page needs one\n * unauthenticated read and nothing else.\n *\n * The endpoint is stateless (a fresh server per request), so `tools/list`\n * stands alone with no `initialize` handshake. It may answer with either JSON\n * or a single SSE event, so both are parsed.\n */\n\nexport interface McpToolParameter {\n name: string\n type?: string\n required: boolean\n description?: string\n enumValues?: string[]\n}\n\nexport interface McpTool {\n name: string\n title?: string\n description?: string\n parameters: McpToolParameter[]\n}\n\n/** Path the MCP server is mounted at, relative to the site origin. */\nexport const MCP_ENDPOINT_PATH = '/api/mcp'\n\ninterface JsonSchemaProperty {\n type?: string | string[]\n description?: string\n enum?: unknown[]\n items?: { type?: string | string[]; enum?: unknown[] }\n}\n\nfunction describeType(prop: JsonSchemaProperty): string | undefined {\n const base = Array.isArray(prop.type) ? prop.type.join(' | ') : prop.type\n if (base === 'array') {\n const itemType = Array.isArray(prop.items?.type)\n ? prop.items.type.join(' | ')\n : prop.items?.type\n return itemType ? `${itemType}[]` : 'array'\n }\n return base\n}\n\nfunction enumValues(prop: JsonSchemaProperty): string[] | undefined {\n const values = prop.enum ?? prop.items?.enum\n return values?.length ? values.map(String) : undefined\n}\n\n/** Pull the single JSON-RPC payload out of a JSON or SSE response body. */\nfunction parseBody(contentType: string, body: string): unknown {\n if (!contentType.includes('text/event-stream')) {\n return JSON.parse(body)\n }\n const dataLines = body\n .split(/\\r?\\n/)\n .filter((line) => line.startsWith('data:'))\n .map((line) => line.slice('data:'.length).trim())\n if (dataLines.length === 0) {\n throw new Error('The server returned an empty event stream.')\n }\n return JSON.parse(dataLines.join(''))\n}\n\n/**\n * Fetch the live tool registry so this page cannot go stale when the tools\n * change.\n *\n * @param origin - Site origin, e.g. `window.location.origin`\n * @param signal - Optional abort signal\n */\nexport async function fetchMcpTools(\n origin: string,\n signal?: AbortSignal,\n): Promise<McpTool[]> {\n const response = await fetch(`${origin}${MCP_ENDPOINT_PATH}`, {\n method: 'POST',\n signal,\n headers: {\n 'content-type': 'application/json',\n // The Streamable HTTP transport requires the client to accept both.\n accept: 'application/json, text/event-stream',\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'tools/list',\n params: {},\n }),\n })\n\n if (!response.ok) {\n throw new Error(\n `The MCP endpoint answered ${response.status} ${response.statusText}.`,\n )\n }\n\n const payload = parseBody(\n response.headers.get('content-type') ?? '',\n await response.text(),\n ) as {\n error?: { message?: string }\n result?: {\n tools?: {\n name: string\n title?: string\n description?: string\n inputSchema?: {\n properties?: Record<string, JsonSchemaProperty>\n required?: string[]\n }\n }[]\n }\n }\n\n if (payload.error) {\n throw new Error(\n payload.error.message ?? 'The MCP endpoint returned an error.',\n )\n }\n\n return (payload.result?.tools ?? []).map((tool) => {\n const properties = tool.inputSchema?.properties ?? {}\n const required = new Set(tool.inputSchema?.required ?? [])\n return {\n name: tool.name,\n title: tool.title,\n description: tool.description,\n parameters: Object.entries(properties).map(([name, prop]) => ({\n name,\n type: describeType(prop),\n required: required.has(name),\n description: prop.description,\n enumValues: enumValues(prop),\n })),\n }\n })\n}\n"],"names":["_a"],"mappings":"AA0BO,MAAM,oBAAoB;AASjC,SAAS,aAAa,MAA8C;AAT7D;AAUL,QAAM,OAAO,MAAM,QAAQ,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,KAAK,IAAI,KAAK;AACrE,MAAI,SAAS,SAAS;AACpB,UAAM,WAAW,MAAM,SAAQ,UAAK,UAAL,mBAAY,IAAI,IAC3C,KAAK,MAAM,KAAK,KAAK,KAAK,KAC1B,UAAK,UAAL,mBAAY;AAChB,WAAO,WAAW,GAAG,QAAQ,OAAO;AAAA,EACtC;AACA,SAAO;AACT;AAEA,SAAS,WAAW,MAAgD;AApB7D;AAqBL,QAAM,SAAS,KAAK,UAAQ,UAAK,UAAL,mBAAY;AACxC,UAAO,iCAAQ,UAAS,OAAO,IAAI,MAAM,IAAI;AAC/C;AAGA,SAAS,UAAU,aAAqB,MAAuB;AAC7D,MAAI,CAAC,YAAY,SAAS,mBAAmB,GAAG;AAC9C,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB;AACA,QAAM,YAAY,KACf,MAAM,OAAO,EACb,OAAO,CAAC,SAAS,KAAK,WAAW,OAAO,CAAC,EACzC,IAAI,CAAC,SAAS,KAAK,MAAM,QAAQ,MAAM,EAAE,MAAM;AAClD,MAAI,UAAU,WAAW,GAAG;AAC1B,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC9D;AACA,SAAO,KAAK,MAAM,UAAU,KAAK,EAAE,CAAC;AACtC;AASA,eAAsB,cACpB,QACA,QACoB;AAlDf;AAmDL,QAAM,WAAW,MAAM,MAAM,GAAG,MAAM,GAAG,iBAAiB,IAAI;AAAA,IAC5D,QAAQ;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,gBAAgB;AAAA;AAAA,MAEhB,QAAQ;AAAA,IAAA;AAAA,IAEV,MAAM,KAAK,UAAU;AAAA,MACnB,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ,CAAA;AAAA,IAAC,CACV;AAAA,EAAA,CACF;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI;AAAA,MACR,6BAA6B,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,IAAA;AAAA,EAEvE;AAEA,QAAM,UAAU;AAAA,IACd,SAAS,QAAQ,IAAI,cAAc,KAAK;AAAA,IACxC,MAAM,SAAS,KAAA;AAAA,EAAK;AAgBtB,MAAI,QAAQ,OAAO;AACjB,UAAM,IAAI;AAAA,MACR,QAAQ,MAAM,WAAW;AAAA,IAAA;AAAA,EAE7B;AAEA,YAAQ,aAAQ,WAAR,mBAAgB,UAAS,CAAA,GAAI,IAAI,CAAC,SAAS;AAjG9C,QAAAA,KAAA;AAkGH,UAAM,eAAaA,MAAA,KAAK,gBAAL,gBAAAA,IAAkB,eAAc,CAAA;AACnD,UAAM,WAAW,IAAI,MAAI,UAAK,gBAAL,mBAAkB,aAAY,EAAE;AACzD,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,YAAY,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO;AAAA,QAC5D;AAAA,QACA,MAAM,aAAa,IAAI;AAAA,QACvB,UAAU,SAAS,IAAI,IAAI;AAAA,QAC3B,aAAa,KAAK;AAAA,QAClB,YAAY,WAAW,IAAI;AAAA,MAAA,EAC3B;AAAA,IAAA;AAAA,EAEN,CAAC;AACH;"}
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { Check, Copy, TriangleAlert } from 'lucide-react'
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
3
|
-
import { Button } from '~/ui/button'
|
|
4
|
-
import { Spinner } from '~/ui/spinner'
|
|
5
|
-
import type { McpTool } from '../../utils/fetchMcpTools'
|
|
6
|
-
import { MCP_ENDPOINT_PATH, fetchMcpTools } from '../../utils/fetchMcpTools'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* MCP docs page: how to point an AI agent at this catalog.
|
|
10
|
-
*
|
|
11
|
-
* Every snippet is built from `window.location.origin`, so production, a
|
|
12
|
-
* preview host and localhost each show a config that actually works — nothing
|
|
13
|
-
* is hardcoded.
|
|
14
|
-
*
|
|
15
|
-
* The tool reference is fetched from the live registry (`tools/list`) rather
|
|
16
|
-
* than written out by hand, so it cannot rot when the server's tools change.
|
|
17
|
-
*/
|
|
18
|
-
export function McpPage() {
|
|
19
|
-
const origin = typeof window === 'undefined' ? '' : window.location.origin
|
|
20
|
-
const endpoint = `${origin}${MCP_ENDPOINT_PATH}`
|
|
21
|
-
const serverName = 'app-catalog'
|
|
22
|
-
|
|
23
|
-
const [tools, setTools] = useState<McpTool[] | null>(null)
|
|
24
|
-
const [error, setError] = useState<string | null>(null)
|
|
25
|
-
const [reloadKey, setReloadKey] = useState(0)
|
|
26
|
-
const headingRef = useRef<HTMLHeadingElement>(null)
|
|
27
|
-
|
|
28
|
-
// New view: land keyboard and screen-reader users in the content rather than
|
|
29
|
-
// leaving focus on whatever nav element was clicked.
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
headingRef.current?.focus()
|
|
32
|
-
}, [])
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const controller = new AbortController()
|
|
36
|
-
setTools(null)
|
|
37
|
-
setError(null)
|
|
38
|
-
fetchMcpTools(origin, controller.signal)
|
|
39
|
-
.then(setTools)
|
|
40
|
-
.catch((err: unknown) => {
|
|
41
|
-
if (controller.signal.aborted) return
|
|
42
|
-
setError(
|
|
43
|
-
err instanceof Error
|
|
44
|
-
? err.message
|
|
45
|
-
: 'Could not reach the MCP endpoint.',
|
|
46
|
-
)
|
|
47
|
-
})
|
|
48
|
-
return () => controller.abort()
|
|
49
|
-
}, [origin, reloadKey])
|
|
50
|
-
|
|
51
|
-
const mcpJson = JSON.stringify(
|
|
52
|
-
{
|
|
53
|
-
mcpServers: {
|
|
54
|
-
[serverName]: { type: 'http', url: endpoint },
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
null,
|
|
58
|
-
2,
|
|
59
|
-
)
|
|
60
|
-
const cliCommand = `claude mcp add --transport http ${serverName} ${endpoint}`
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<div className="flex flex-col flex-1 min-h-0 overflow-y-auto">
|
|
64
|
-
<div className="flex flex-col gap-8 w-full max-w-3xl mx-auto pb-8">
|
|
65
|
-
<section className="flex flex-col gap-2">
|
|
66
|
-
<h1
|
|
67
|
-
ref={headingRef}
|
|
68
|
-
tabIndex={-1}
|
|
69
|
-
className="text-xl font-semibold outline-none"
|
|
70
|
-
>
|
|
71
|
-
MCP server
|
|
72
|
-
</h1>
|
|
73
|
-
<p className="text-sm text-muted-foreground">
|
|
74
|
-
This catalog exposes a{' '}
|
|
75
|
-
<a
|
|
76
|
-
href="https://modelcontextprotocol.io"
|
|
77
|
-
target="_blank"
|
|
78
|
-
rel="noopener noreferrer"
|
|
79
|
-
className="text-primary hover:underline"
|
|
80
|
-
>
|
|
81
|
-
Model Context Protocol
|
|
82
|
-
</a>{' '}
|
|
83
|
-
server, so an AI agent can search the catalog and read an entry the
|
|
84
|
-
same way you can — what exists, who owns it, and how to request
|
|
85
|
-
access. Point your agent at the endpoint below and it gains those
|
|
86
|
-
tools; no key or account is needed.
|
|
87
|
-
</p>
|
|
88
|
-
<p className="text-sm text-muted-foreground">
|
|
89
|
-
It speaks MCP over Streamable HTTP (JSON-RPC over{' '}
|
|
90
|
-
<code className="text-xs">POST</code>), and it is read-only.
|
|
91
|
-
</p>
|
|
92
|
-
</section>
|
|
93
|
-
|
|
94
|
-
<Snippet
|
|
95
|
-
title="Endpoint"
|
|
96
|
-
description="The URL an MCP client connects to."
|
|
97
|
-
value={endpoint}
|
|
98
|
-
/>
|
|
99
|
-
|
|
100
|
-
<Snippet
|
|
101
|
-
title="Add it with the CLI"
|
|
102
|
-
description="One command, if your agent ships a CLI that manages MCP servers."
|
|
103
|
-
value={cliCommand}
|
|
104
|
-
/>
|
|
105
|
-
|
|
106
|
-
<Snippet
|
|
107
|
-
title="Or add it to .mcp.json"
|
|
108
|
-
description="Commit this in a project so everyone working on it gets the same tools."
|
|
109
|
-
value={mcpJson}
|
|
110
|
-
language="json"
|
|
111
|
-
/>
|
|
112
|
-
|
|
113
|
-
<section
|
|
114
|
-
className="flex flex-col gap-3"
|
|
115
|
-
aria-busy={tools === null && error === null}
|
|
116
|
-
>
|
|
117
|
-
<div className="flex flex-col gap-1">
|
|
118
|
-
<h2 className="text-base font-semibold">Tools</h2>
|
|
119
|
-
<p className="text-xs text-muted-foreground">
|
|
120
|
-
Read live from the server, so this list is always what your agent
|
|
121
|
-
will actually see.
|
|
122
|
-
</p>
|
|
123
|
-
</div>
|
|
124
|
-
|
|
125
|
-
{error !== null ? (
|
|
126
|
-
<div
|
|
127
|
-
role="alert"
|
|
128
|
-
className="flex flex-col items-start gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-4"
|
|
129
|
-
>
|
|
130
|
-
<p className="flex items-start gap-2 text-sm">
|
|
131
|
-
<TriangleAlert className="size-4 shrink-0 mt-0.5 text-destructive" />
|
|
132
|
-
<span>
|
|
133
|
-
Could not read the tool list. {error} The setup instructions
|
|
134
|
-
above are still correct.
|
|
135
|
-
</span>
|
|
136
|
-
</p>
|
|
137
|
-
<Button
|
|
138
|
-
variant="outline"
|
|
139
|
-
size="sm"
|
|
140
|
-
onClick={() => setReloadKey((k) => k + 1)}
|
|
141
|
-
>
|
|
142
|
-
Try again
|
|
143
|
-
</Button>
|
|
144
|
-
</div>
|
|
145
|
-
) : tools === null ? (
|
|
146
|
-
<p className="flex items-center gap-2 text-sm text-muted-foreground">
|
|
147
|
-
<Spinner className="size-4" />
|
|
148
|
-
Reading the tool list…
|
|
149
|
-
</p>
|
|
150
|
-
) : tools.length === 0 ? (
|
|
151
|
-
<p className="text-sm text-muted-foreground">
|
|
152
|
-
The server reported no tools.
|
|
153
|
-
</p>
|
|
154
|
-
) : (
|
|
155
|
-
<ul className="flex flex-col gap-4 list-none p-0 m-0">
|
|
156
|
-
{tools.map((tool) => (
|
|
157
|
-
<li
|
|
158
|
-
key={tool.name}
|
|
159
|
-
className="rounded-md border p-4 flex flex-col gap-2"
|
|
160
|
-
>
|
|
161
|
-
<code className="text-sm font-semibold">{tool.name}</code>
|
|
162
|
-
{tool.description && (
|
|
163
|
-
<p className="text-sm text-muted-foreground">
|
|
164
|
-
{tool.description}
|
|
165
|
-
</p>
|
|
166
|
-
)}
|
|
167
|
-
{tool.parameters.length === 0 ? (
|
|
168
|
-
<p className="text-xs text-muted-foreground">
|
|
169
|
-
No parameters.
|
|
170
|
-
</p>
|
|
171
|
-
) : (
|
|
172
|
-
<dl className="flex flex-col gap-2 m-0">
|
|
173
|
-
{tool.parameters.map((param) => (
|
|
174
|
-
<div key={param.name} className="flex flex-col gap-0.5">
|
|
175
|
-
<dt className="text-xs">
|
|
176
|
-
<code className="font-medium">{param.name}</code>
|
|
177
|
-
{param.type && (
|
|
178
|
-
<span className="text-muted-foreground">
|
|
179
|
-
{' '}
|
|
180
|
-
{param.type}
|
|
181
|
-
</span>
|
|
182
|
-
)}
|
|
183
|
-
<span className="text-muted-foreground">
|
|
184
|
-
{' '}
|
|
185
|
-
— {param.required ? 'required' : 'optional'}
|
|
186
|
-
</span>
|
|
187
|
-
</dt>
|
|
188
|
-
{param.description && (
|
|
189
|
-
<dd className="text-xs text-muted-foreground m-0">
|
|
190
|
-
{param.description}
|
|
191
|
-
</dd>
|
|
192
|
-
)}
|
|
193
|
-
{param.enumValues && (
|
|
194
|
-
<dd className="text-xs text-muted-foreground m-0">
|
|
195
|
-
One of: {param.enumValues.join(', ')}
|
|
196
|
-
</dd>
|
|
197
|
-
)}
|
|
198
|
-
</div>
|
|
199
|
-
))}
|
|
200
|
-
</dl>
|
|
201
|
-
)}
|
|
202
|
-
</li>
|
|
203
|
-
))}
|
|
204
|
-
</ul>
|
|
205
|
-
)}
|
|
206
|
-
</section>
|
|
207
|
-
</div>
|
|
208
|
-
</div>
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function Snippet({
|
|
213
|
-
title,
|
|
214
|
-
description,
|
|
215
|
-
value,
|
|
216
|
-
language,
|
|
217
|
-
}: {
|
|
218
|
-
title: string
|
|
219
|
-
description: string
|
|
220
|
-
value: string
|
|
221
|
-
language?: string
|
|
222
|
-
}) {
|
|
223
|
-
return (
|
|
224
|
-
<section className="flex flex-col gap-2">
|
|
225
|
-
<h2 className="text-base font-semibold">{title}</h2>
|
|
226
|
-
<p className="text-xs text-muted-foreground">{description}</p>
|
|
227
|
-
<div className="relative">
|
|
228
|
-
<pre
|
|
229
|
-
className="overflow-x-auto rounded-md border bg-muted/40 p-3 pr-12 text-xs"
|
|
230
|
-
data-language={language}
|
|
231
|
-
>
|
|
232
|
-
<code>{value}</code>
|
|
233
|
-
</pre>
|
|
234
|
-
<CopyButton value={value} label={title} />
|
|
235
|
-
</div>
|
|
236
|
-
</section>
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function CopyButton({ value, label }: { value: string; label: string }) {
|
|
241
|
-
const [copied, setCopied] = useState(false)
|
|
242
|
-
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
243
|
-
|
|
244
|
-
useEffect(
|
|
245
|
-
() => () => {
|
|
246
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
247
|
-
},
|
|
248
|
-
[],
|
|
249
|
-
)
|
|
250
|
-
|
|
251
|
-
const copy = useCallback(() => {
|
|
252
|
-
void navigator.clipboard.writeText(value)
|
|
253
|
-
setCopied(true)
|
|
254
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
255
|
-
timeoutRef.current = setTimeout(() => setCopied(false), 2000)
|
|
256
|
-
}, [value])
|
|
257
|
-
|
|
258
|
-
return (
|
|
259
|
-
<Button
|
|
260
|
-
type="button"
|
|
261
|
-
variant="ghost"
|
|
262
|
-
size="icon"
|
|
263
|
-
onClick={copy}
|
|
264
|
-
aria-label={copied ? `${label} copied` : `Copy ${label}`}
|
|
265
|
-
title={copied ? 'Copied' : 'Copy'}
|
|
266
|
-
className="absolute right-1.5 top-1.5"
|
|
267
|
-
>
|
|
268
|
-
{copied ? (
|
|
269
|
-
<Check className="size-4 text-primary" />
|
|
270
|
-
) : (
|
|
271
|
-
<Copy className="size-4" />
|
|
272
|
-
)}
|
|
273
|
-
</Button>
|
|
274
|
-
)
|
|
275
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal MCP client for the docs page: one `tools/list` call over Streamable
|
|
3
|
-
* HTTP. Deliberately raw `fetch` rather than the MCP SDK — the page needs one
|
|
4
|
-
* unauthenticated read and nothing else.
|
|
5
|
-
*
|
|
6
|
-
* The endpoint is stateless (a fresh server per request), so `tools/list`
|
|
7
|
-
* stands alone with no `initialize` handshake. It may answer with either JSON
|
|
8
|
-
* or a single SSE event, so both are parsed.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface McpToolParameter {
|
|
12
|
-
name: string
|
|
13
|
-
type?: string
|
|
14
|
-
required: boolean
|
|
15
|
-
description?: string
|
|
16
|
-
enumValues?: string[]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface McpTool {
|
|
20
|
-
name: string
|
|
21
|
-
title?: string
|
|
22
|
-
description?: string
|
|
23
|
-
parameters: McpToolParameter[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Path the MCP server is mounted at, relative to the site origin. */
|
|
27
|
-
export const MCP_ENDPOINT_PATH = '/api/mcp'
|
|
28
|
-
|
|
29
|
-
interface JsonSchemaProperty {
|
|
30
|
-
type?: string | string[]
|
|
31
|
-
description?: string
|
|
32
|
-
enum?: unknown[]
|
|
33
|
-
items?: { type?: string | string[]; enum?: unknown[] }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function describeType(prop: JsonSchemaProperty): string | undefined {
|
|
37
|
-
const base = Array.isArray(prop.type) ? prop.type.join(' | ') : prop.type
|
|
38
|
-
if (base === 'array') {
|
|
39
|
-
const itemType = Array.isArray(prop.items?.type)
|
|
40
|
-
? prop.items.type.join(' | ')
|
|
41
|
-
: prop.items?.type
|
|
42
|
-
return itemType ? `${itemType}[]` : 'array'
|
|
43
|
-
}
|
|
44
|
-
return base
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function enumValues(prop: JsonSchemaProperty): string[] | undefined {
|
|
48
|
-
const values = prop.enum ?? prop.items?.enum
|
|
49
|
-
return values?.length ? values.map(String) : undefined
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Pull the single JSON-RPC payload out of a JSON or SSE response body. */
|
|
53
|
-
function parseBody(contentType: string, body: string): unknown {
|
|
54
|
-
if (!contentType.includes('text/event-stream')) {
|
|
55
|
-
return JSON.parse(body)
|
|
56
|
-
}
|
|
57
|
-
const dataLines = body
|
|
58
|
-
.split(/\r?\n/)
|
|
59
|
-
.filter((line) => line.startsWith('data:'))
|
|
60
|
-
.map((line) => line.slice('data:'.length).trim())
|
|
61
|
-
if (dataLines.length === 0) {
|
|
62
|
-
throw new Error('The server returned an empty event stream.')
|
|
63
|
-
}
|
|
64
|
-
return JSON.parse(dataLines.join(''))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Fetch the live tool registry so this page cannot go stale when the tools
|
|
69
|
-
* change.
|
|
70
|
-
*
|
|
71
|
-
* @param origin - Site origin, e.g. `window.location.origin`
|
|
72
|
-
* @param signal - Optional abort signal
|
|
73
|
-
*/
|
|
74
|
-
export async function fetchMcpTools(
|
|
75
|
-
origin: string,
|
|
76
|
-
signal?: AbortSignal,
|
|
77
|
-
): Promise<McpTool[]> {
|
|
78
|
-
const response = await fetch(`${origin}${MCP_ENDPOINT_PATH}`, {
|
|
79
|
-
method: 'POST',
|
|
80
|
-
signal,
|
|
81
|
-
headers: {
|
|
82
|
-
'content-type': 'application/json',
|
|
83
|
-
// The Streamable HTTP transport requires the client to accept both.
|
|
84
|
-
accept: 'application/json, text/event-stream',
|
|
85
|
-
},
|
|
86
|
-
body: JSON.stringify({
|
|
87
|
-
jsonrpc: '2.0',
|
|
88
|
-
id: 1,
|
|
89
|
-
method: 'tools/list',
|
|
90
|
-
params: {},
|
|
91
|
-
}),
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
if (!response.ok) {
|
|
95
|
-
throw new Error(
|
|
96
|
-
`The MCP endpoint answered ${response.status} ${response.statusText}.`,
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const payload = parseBody(
|
|
101
|
-
response.headers.get('content-type') ?? '',
|
|
102
|
-
await response.text(),
|
|
103
|
-
) as {
|
|
104
|
-
error?: { message?: string }
|
|
105
|
-
result?: {
|
|
106
|
-
tools?: {
|
|
107
|
-
name: string
|
|
108
|
-
title?: string
|
|
109
|
-
description?: string
|
|
110
|
-
inputSchema?: {
|
|
111
|
-
properties?: Record<string, JsonSchemaProperty>
|
|
112
|
-
required?: string[]
|
|
113
|
-
}
|
|
114
|
-
}[]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (payload.error) {
|
|
119
|
-
throw new Error(
|
|
120
|
-
payload.error.message ?? 'The MCP endpoint returned an error.',
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return (payload.result?.tools ?? []).map((tool) => {
|
|
125
|
-
const properties = tool.inputSchema?.properties ?? {}
|
|
126
|
-
const required = new Set(tool.inputSchema?.required ?? [])
|
|
127
|
-
return {
|
|
128
|
-
name: tool.name,
|
|
129
|
-
title: tool.title,
|
|
130
|
-
description: tool.description,
|
|
131
|
-
parameters: Object.entries(properties).map(([name, prop]) => ({
|
|
132
|
-
name,
|
|
133
|
-
type: describeType(prop),
|
|
134
|
-
required: required.has(name),
|
|
135
|
-
description: prop.description,
|
|
136
|
-
enumValues: enumValues(prop),
|
|
137
|
-
})),
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
}
|