@keystoneui/mcp 0.2.0-beta.4 → 0.2.0-beta.5
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/README.md
CHANGED
|
@@ -12,11 +12,13 @@ The single binary runs in two modes:
|
|
|
12
12
|
### As an MCP server
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npx -y @keystoneui/mcp init --client claude
|
|
15
|
+
npx -y @keystoneui/mcp@latest init --client claude
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Supported clients: `claude`, `cursor`, `vscode`, `opencode`, `codex`. The `init` command writes the appropriate config file for the chosen client and points it at `npx @keystoneui/mcp@latest`.
|
|
19
19
|
|
|
20
|
+
The server runs with the settings of the project it starts in. Before using it in a project you have not reviewed, read [Projects you do not trust](https://keystoneui.io/docs/agents/mcp-server#projects-you-do-not-trust).
|
|
21
|
+
|
|
20
22
|
Once configured, ask your agent things like:
|
|
21
23
|
|
|
22
24
|
- *"List Keystone UI components."*
|
|
@@ -27,23 +29,23 @@ Once configured, ask your agent things like:
|
|
|
27
29
|
|
|
28
30
|
```bash
|
|
29
31
|
# Discover
|
|
30
|
-
npx keystoneui search "table pagination"
|
|
31
|
-
npx keystoneui list --type example
|
|
32
|
-
npx keystoneui blocks signin
|
|
32
|
+
npx @keystoneui/mcp search "table pagination"
|
|
33
|
+
npx @keystoneui/mcp list --type example
|
|
34
|
+
npx @keystoneui/mcp blocks signin
|
|
33
35
|
|
|
34
36
|
# Inspect
|
|
35
|
-
npx keystoneui view button
|
|
36
|
-
npx keystoneui docs button # /llms.mdx/docs/components/button
|
|
37
|
-
npx keystoneui examples table # all demo files for the table component
|
|
37
|
+
npx @keystoneui/mcp view button
|
|
38
|
+
npx @keystoneui/mcp docs button # /llms.mdx/docs/components/button
|
|
39
|
+
npx @keystoneui/mcp examples table # all demo files for the table component
|
|
38
40
|
|
|
39
41
|
# Install (delegates to shadcn CLI)
|
|
40
42
|
npx shadcn@latest add https://keystoneui.io/r/table-with-pagination.json
|
|
41
43
|
|
|
42
44
|
# Verify
|
|
43
|
-
npx keystoneui audit
|
|
45
|
+
npx @keystoneui/mcp audit
|
|
44
46
|
|
|
45
47
|
# Theme (a code from https://keystoneui.io/theme-builder)
|
|
46
|
-
npx keystoneui theme k1_slate_0.55_0.2_262.5_large_inter
|
|
48
|
+
npx @keystoneui/mcp theme k1_slate_0.55_0.2_262.5_large_inter
|
|
47
49
|
```
|
|
48
50
|
|
|
49
51
|
## Verbs
|
|
@@ -44,6 +44,51 @@ function readPackageVersion() {
|
|
|
44
44
|
// src/tools.ts
|
|
45
45
|
import { z } from "zod";
|
|
46
46
|
|
|
47
|
+
// src/display-url.ts
|
|
48
|
+
import { inspect } from "util";
|
|
49
|
+
var DISPLAYED_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "file:"]);
|
|
50
|
+
var PATH_AFTER_AUTHORITY = /^[\0- ]*[a-z][a-z\d+.-]*:[/\\]{2}[^/\\?#]*[/\\]/i;
|
|
51
|
+
function displayUrl(raw) {
|
|
52
|
+
let url;
|
|
53
|
+
try {
|
|
54
|
+
url = new URL(raw);
|
|
55
|
+
} catch {
|
|
56
|
+
return "<unparseable URL>";
|
|
57
|
+
}
|
|
58
|
+
if (!DISPLAYED_PROTOCOLS.has(url.protocol)) {
|
|
59
|
+
return "<unsupported URL>";
|
|
60
|
+
}
|
|
61
|
+
if (!(url.username || url.password || url.search || url.hash)) {
|
|
62
|
+
return raw;
|
|
63
|
+
}
|
|
64
|
+
url.username = "";
|
|
65
|
+
url.password = "";
|
|
66
|
+
url.hash = "";
|
|
67
|
+
const keys = [...url.searchParams.keys()];
|
|
68
|
+
url.search = keys.map((key) => `${encodeURIComponent(key)}=REDACTED`).join("&");
|
|
69
|
+
if (url.host && url.pathname === "/" && !PATH_AFTER_AUTHORITY.test(raw)) {
|
|
70
|
+
return `${url.protocol}//${url.host}${url.search}`;
|
|
71
|
+
}
|
|
72
|
+
return url.href;
|
|
73
|
+
}
|
|
74
|
+
var LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
75
|
+
function wellFormed(text) {
|
|
76
|
+
return text.replace(LONE_SURROGATE, "\uFFFD");
|
|
77
|
+
}
|
|
78
|
+
function redactUrlInError(error, url) {
|
|
79
|
+
const forms = [.../* @__PURE__ */ new Set([url, wellFormed(url)])];
|
|
80
|
+
const full = inspect(error, { depth: 10 });
|
|
81
|
+
if (!forms.some((form) => full.includes(form))) {
|
|
82
|
+
return error;
|
|
83
|
+
}
|
|
84
|
+
const shown = displayUrl(url);
|
|
85
|
+
let message = error instanceof Error ? error.message : String(error ?? "Unknown error");
|
|
86
|
+
for (const form of forms) {
|
|
87
|
+
message = message.replaceAll(form, () => shown);
|
|
88
|
+
}
|
|
89
|
+
return error instanceof TypeError ? new TypeError(message) : new Error(message);
|
|
90
|
+
}
|
|
91
|
+
|
|
47
92
|
// src/fetcher.ts
|
|
48
93
|
var cache = /* @__PURE__ */ new Map();
|
|
49
94
|
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -52,9 +97,14 @@ async function fetchJson(url) {
|
|
|
52
97
|
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
53
98
|
return cached.data;
|
|
54
99
|
}
|
|
55
|
-
|
|
100
|
+
let response;
|
|
101
|
+
try {
|
|
102
|
+
response = await fetch(url);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw redactUrlInError(error, url);
|
|
105
|
+
}
|
|
56
106
|
if (!response.ok) {
|
|
57
|
-
throw new Error(`Failed to fetch ${url}: ${response.status}`);
|
|
107
|
+
throw new Error(`Failed to fetch ${displayUrl(url)}: ${response.status}`);
|
|
58
108
|
}
|
|
59
109
|
const data = await response.json();
|
|
60
110
|
cache.set(url, { data, timestamp: Date.now() });
|
|
@@ -497,7 +547,7 @@ async function getDocsTool(config, input) {
|
|
|
497
547
|
}
|
|
498
548
|
return await response.text();
|
|
499
549
|
} catch {
|
|
500
|
-
return `**${input.name}**: could not reach ${url}.`;
|
|
550
|
+
return `**${input.name}**: could not reach ${displayUrl(url)}.`;
|
|
501
551
|
}
|
|
502
552
|
}
|
|
503
553
|
var emptySchema = z.object({});
|
|
@@ -545,6 +595,8 @@ function getProjectContextTool() {
|
|
|
545
595
|
|
|
546
596
|
export {
|
|
547
597
|
loadProjectConfig,
|
|
598
|
+
displayUrl,
|
|
599
|
+
redactUrlInError,
|
|
548
600
|
readPackageVersion,
|
|
549
601
|
detectProjectContext,
|
|
550
602
|
listComponentsTool,
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
auditChecklistTool,
|
|
4
4
|
detectProjectContext,
|
|
5
|
+
displayUrl,
|
|
5
6
|
getExamplesTool,
|
|
6
7
|
listComponentsTool,
|
|
7
8
|
loadProjectConfig,
|
|
8
9
|
readPackageVersion,
|
|
10
|
+
redactUrlInError,
|
|
9
11
|
searchComponentsTool,
|
|
10
12
|
viewComponentTool
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TAXPGE7O.js";
|
|
12
14
|
|
|
13
15
|
// src/cli.ts
|
|
14
16
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
@@ -84,15 +86,15 @@ function collect() {
|
|
|
84
86
|
node: process.version,
|
|
85
87
|
platform: process.platform,
|
|
86
88
|
cwd,
|
|
87
|
-
registryUrl: config.registry.url,
|
|
88
|
-
docsUrl
|
|
89
|
+
registryUrl: displayUrl(config.registry.url),
|
|
90
|
+
docsUrl: displayUrl(docsUrl)
|
|
89
91
|
},
|
|
90
92
|
mcpClients: detectMcpClients(cwd),
|
|
91
93
|
installedPackages: detectInstalledPackages(cwd),
|
|
92
94
|
links: {
|
|
93
|
-
docs: docsUrl,
|
|
94
|
-
registry: `${config.registry.url}/registry.json
|
|
95
|
-
llms: `${docsUrl}/llms.txt`
|
|
95
|
+
docs: displayUrl(docsUrl),
|
|
96
|
+
registry: displayUrl(`${config.registry.url}/registry.json`),
|
|
97
|
+
llms: displayUrl(`${docsUrl}/llms.txt`)
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
100
|
}
|
|
@@ -162,6 +164,7 @@ function runInfo(args) {
|
|
|
162
164
|
// src/init.ts
|
|
163
165
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
164
166
|
import { dirname, resolve as resolve2 } from "path";
|
|
167
|
+
var TRUST_POINTER = "The server runs with this project's settings. Before using it in a project you have not reviewed, read https://keystoneui.io/docs/agents/mcp-server#projects-you-do-not-trust";
|
|
165
168
|
var SERVER_ENTRY = {
|
|
166
169
|
command: "npx",
|
|
167
170
|
args: ["@keystoneui/mcp@latest"]
|
|
@@ -243,6 +246,7 @@ function writeJsonClient(client) {
|
|
|
243
246
|
`);
|
|
244
247
|
console.log(`Created ${client.configPath}`);
|
|
245
248
|
console.log(`Keystone UI MCP server configured for ${client.name}.`);
|
|
249
|
+
console.log(TRUST_POINTER);
|
|
246
250
|
}
|
|
247
251
|
function printCodexInstructions() {
|
|
248
252
|
console.log("Codex uses a global TOML config that cannot be auto-written.");
|
|
@@ -254,17 +258,18 @@ function printCodexInstructions() {
|
|
|
254
258
|
console.log(' args = ["@keystoneui/mcp@latest"]');
|
|
255
259
|
console.log("");
|
|
256
260
|
console.log("Then restart Codex.");
|
|
261
|
+
console.log(TRUST_POINTER);
|
|
257
262
|
}
|
|
258
263
|
function printUsage() {
|
|
259
264
|
const names = CLIENTS.map((c) => c.name).join(", ");
|
|
260
|
-
console.log("Usage: npx @keystoneui/mcp init --client <name>");
|
|
265
|
+
console.log("Usage: npx @keystoneui/mcp@latest init --client <name>");
|
|
261
266
|
console.log("");
|
|
262
267
|
console.log(`Supported clients: ${names}`);
|
|
263
268
|
console.log("");
|
|
264
269
|
console.log("Examples:");
|
|
265
|
-
console.log(" npx @keystoneui/mcp init --client cursor");
|
|
266
|
-
console.log(" npx @keystoneui/mcp init --client claude");
|
|
267
|
-
console.log(" npx @keystoneui/mcp init --client vscode");
|
|
270
|
+
console.log(" npx @keystoneui/mcp@latest init --client cursor");
|
|
271
|
+
console.log(" npx @keystoneui/mcp@latest init --client claude");
|
|
272
|
+
console.log(" npx @keystoneui/mcp@latest init --client vscode");
|
|
268
273
|
}
|
|
269
274
|
function init() {
|
|
270
275
|
const clientName = parseArgs();
|
|
@@ -649,12 +654,17 @@ async function runDocs(args) {
|
|
|
649
654
|
const name = positional[0];
|
|
650
655
|
const siteUrl = process.env.KEYSTONEUI_URL ?? "https://keystoneui.io";
|
|
651
656
|
const url = `${siteUrl}/llms.mdx/docs/components/${name}`;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
657
|
+
let response;
|
|
658
|
+
try {
|
|
659
|
+
response = await fetch(url, {
|
|
660
|
+
headers: { "User-Agent": "keystoneui-cli/0.1" }
|
|
661
|
+
});
|
|
662
|
+
} catch (error) {
|
|
663
|
+
throw redactUrlInError(error, url);
|
|
664
|
+
}
|
|
655
665
|
if (!response.ok) {
|
|
656
666
|
console.error(
|
|
657
|
-
`Failed to fetch ${url}: ${response.status} ${response.statusText}`
|
|
667
|
+
`Failed to fetch ${displayUrl(url)}: ${response.status} ${response.statusText}`
|
|
658
668
|
);
|
|
659
669
|
process.exitCode = 1;
|
|
660
670
|
return;
|
|
@@ -795,6 +805,6 @@ if (isCliVerb(verbCandidate)) {
|
|
|
795
805
|
process.exit();
|
|
796
806
|
}
|
|
797
807
|
var { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
798
|
-
var { server } = await import("./server-
|
|
808
|
+
var { server } = await import("./server-7ZU3YJ7K.js");
|
|
799
809
|
var transport = new StdioServerTransport();
|
|
800
810
|
await server.connect(transport);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keystoneui/mcp",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "MCP server and CLI for Keystone UI — lets AI agents and shell users discover, search, view, and install components, blocks, and named examples.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|