@sentientui/mcp 0.3.3 → 0.4.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/AGENTS.md +1 -0
- package/README.md +7 -0
- package/dist/chunk-ZXI3OZKA.js +725 -0
- package/dist/index.cjs +61 -1
- package/dist/index.js +4 -662
- package/dist/lib.cjs +758 -0
- package/dist/lib.d.cts +20 -0
- package/dist/lib.d.ts +20 -0
- package/dist/lib.js +11 -0
- package/package.json +22 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.14_tsx@4.22.1_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
|
|
5
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
6
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
7
|
+
|
|
4
8
|
// src/index.ts
|
|
5
9
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
10
|
|
|
@@ -51,12 +55,67 @@ var ApiClient = class {
|
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
// src/server.ts
|
|
58
|
+
var import_node_module = require("module");
|
|
54
59
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
55
60
|
|
|
56
61
|
// src/tools/projects.ts
|
|
57
62
|
var import_zod = require("zod");
|
|
58
63
|
var projectIdSchema = import_zod.z.string().uuid().describe("The project UUID");
|
|
64
|
+
function createProjectGuidance(err) {
|
|
65
|
+
switch (err.message) {
|
|
66
|
+
case "insufficient_scope":
|
|
67
|
+
return "Creating a project needs an account login. Connect via the hosted MCP URL (https://api.sentient-ui.com/mcp) and sign in \u2014 a project-scoped server key (sk_\u2026) cannot create projects.";
|
|
68
|
+
case "demo_read_only":
|
|
69
|
+
return "Demo mode is read-only. Create a SentientUI account and sign in to make projects.";
|
|
70
|
+
case "insufficient_role":
|
|
71
|
+
return "Your account role cannot create projects \u2014 this needs the account owner or an admin.";
|
|
72
|
+
case "project_limit_reached":
|
|
73
|
+
return "You've reached your plan's project limit. Upgrade your plan or remove an existing project, then try again.";
|
|
74
|
+
case "name_required":
|
|
75
|
+
return "A project name is required to create a project.";
|
|
76
|
+
default:
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
59
80
|
function registerProjectTools(server, client) {
|
|
81
|
+
server.tool(
|
|
82
|
+
"create_project",
|
|
83
|
+
"Create a NEW SentientUI project (onboarding). Returns the project id and its pk_ public key for the SDK. Requires an account login: this works when connected via OAuth (the hosted MCP URL) but NOT with a project-scoped sk_ server key or an anonymous demo token. After it succeeds, call get_integration_guide and help the user install @sentientui/react with the returned key.",
|
|
84
|
+
{
|
|
85
|
+
name: import_zod.z.string().min(1).describe("Human-readable project name"),
|
|
86
|
+
contextType: import_zod.z.enum(["saas", "ecommerce", "marketing", "internal"]).optional().describe("What kind of product this is; defaults to saas"),
|
|
87
|
+
framework: import_zod.z.enum(["next-app", "next-pages", "react", "core"]).optional().describe("Frontend framework, used to tailor setup; defaults to next-app"),
|
|
88
|
+
websiteUrl: import_zod.z.string().optional().describe("Production site origin to allow-list so the SDK's events aren't origin-blocked on day one")
|
|
89
|
+
},
|
|
90
|
+
async ({ name, contextType, framework, websiteUrl }) => {
|
|
91
|
+
try {
|
|
92
|
+
const created = await client.post("/projects", {
|
|
93
|
+
name,
|
|
94
|
+
contextType,
|
|
95
|
+
framework,
|
|
96
|
+
origin: websiteUrl
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
content: [{
|
|
100
|
+
type: "text",
|
|
101
|
+
text: [
|
|
102
|
+
`Created project "${name}" (id: ${created.id}, type: ${contextType ?? "saas"}).`,
|
|
103
|
+
`Public key: ${created.apiKey}`,
|
|
104
|
+
`Next: install @sentientui/react with this key. Ask me to pull the setup guide (get_integration_guide) and I'll wrap your first component.`
|
|
105
|
+
].join("\n")
|
|
106
|
+
}]
|
|
107
|
+
};
|
|
108
|
+
} catch (err) {
|
|
109
|
+
if (err instanceof ApiError) {
|
|
110
|
+
const guidance = createProjectGuidance(err);
|
|
111
|
+
if (guidance) {
|
|
112
|
+
return { content: [{ type: "text", text: guidance }], isError: true };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
);
|
|
60
119
|
server.tool(
|
|
61
120
|
"list_projects",
|
|
62
121
|
"List all SentientUI projects for the authenticated account.",
|
|
@@ -647,10 +706,11 @@ function registerIntegrationGuideTools(server) {
|
|
|
647
706
|
}
|
|
648
707
|
|
|
649
708
|
// src/server.ts
|
|
709
|
+
var { version: PKG_VERSION } = (0, import_node_module.createRequire)(importMetaUrl)("../package.json");
|
|
650
710
|
function createMcpServer(client) {
|
|
651
711
|
const server = new import_mcp.McpServer({
|
|
652
712
|
name: "@sentientui/mcp",
|
|
653
|
-
version:
|
|
713
|
+
version: PKG_VERSION
|
|
654
714
|
});
|
|
655
715
|
registerProjectTools(server, client);
|
|
656
716
|
registerComponentTools(server, client);
|