@sentientui/mcp 0.3.4 → 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/dist/index.cjs CHANGED
@@ -61,7 +61,61 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
61
61
  // src/tools/projects.ts
62
62
  var import_zod = require("zod");
63
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
+ }
64
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
+ );
65
119
  server.tool(
66
120
  "list_projects",
67
121
  "List all SentientUI projects for the authenticated account.",