@prysmid/mcp 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of tracking or improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Prysmid
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # `@prysmid/mcp` — Official Prysmid MCP server
2
+
3
+ Manage your Prysmid auth workspace from any MCP-compatible agent: Claude Code, Cursor, Continue, your own runtime — anything that speaks the Model Context Protocol.
4
+
5
+ ## What it does
6
+
7
+ Exposes the full Prysmid platform API as MCP tools so an agent can:
8
+
9
+ - create workspaces
10
+ - configure login policies (passwords, MFA, passkey-first, lockout)
11
+ - add identity providers (Google, GitHub, Microsoft, generic OIDC)
12
+ - create OIDC apps (with redirect URIs, PKCE, dev mode)
13
+ - manage users (invite, list, remove)
14
+ - update branding (logos, colors, label policy)
15
+ - manage SMTP overrides
16
+ - query subscription / billing state
17
+
18
+ ## Install
19
+
20
+ > Pre-1.0 — distribution is via GitHub for now; `@prysmid/mcp` on npm is on the way.
21
+
22
+ Pin to a specific version (recommended):
23
+
24
+ ```bash
25
+ claude mcp add prysmid -- npx -y github:PrysmID/mcp-server#v0.1.0
26
+ ```
27
+
28
+ Or float to the tip of `main`:
29
+
30
+ ```bash
31
+ claude mcp add prysmid -- npx -y github:PrysmID/mcp-server
32
+ ```
33
+
34
+ (or the equivalent for your agent)
35
+
36
+ For now, auth is bearer-token-only via env var:
37
+
38
+ ```bash
39
+ PRYSMID_API_TOKEN=ptkn_… npx -y github:PrysmID/mcp-server
40
+ ```
41
+
42
+ OAuth device flow with token caching at `~/.config/prysmid-mcp/token.json` (Unix) or `%APPDATA%/prysmid-mcp/token.json` (Windows) is queued for a follow-up release.
43
+
44
+ ## Configuration
45
+
46
+ | Env var | Default | Notes |
47
+ |---|---|---|
48
+ | `PRYSMID_API_BASE` | `https://api.prysmid.com` | Override for self-hosted Prysmid |
49
+ | `PRYSMID_API_TOKEN` | — | Static bearer (skip device flow) |
50
+ | `PRYSMID_MCP_LOG_LEVEL` | `info` | `debug` for verbose tool tracing |
51
+
52
+ ## Status
53
+
54
+ 🚧 Pre-1.0. APIs are stable but the tool surface evolves with the platform. Track the [changelog](CHANGELOG.md).
55
+
56
+ ## License
57
+
58
+ Apache-2.0
package/dist/index.js ADDED
@@ -0,0 +1,631 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+
7
+ // src/client.ts
8
+ var PrysmidApiError = class extends Error {
9
+ constructor(message, status, body, code) {
10
+ super(message);
11
+ this.status = status;
12
+ this.body = body;
13
+ this.code = code;
14
+ this.name = "PrysmidApiError";
15
+ }
16
+ status;
17
+ body;
18
+ code;
19
+ };
20
+ var PrysmidClient = class {
21
+ constructor(cfg, log) {
22
+ this.cfg = cfg;
23
+ this.log = log;
24
+ }
25
+ cfg;
26
+ log;
27
+ async request(path, opts = {}) {
28
+ if (!this.cfg.apiToken) {
29
+ throw new PrysmidApiError(
30
+ "No PRYSMID_API_TOKEN configured. Set the env var or run device-flow login.",
31
+ 401,
32
+ "",
33
+ "auth.no_token"
34
+ );
35
+ }
36
+ const url = new URL(this.cfg.apiBase + path);
37
+ if (opts.query) {
38
+ for (const [k, v] of Object.entries(opts.query)) {
39
+ if (v !== void 0) url.searchParams.set(k, String(v));
40
+ }
41
+ }
42
+ const method = opts.method ?? "GET";
43
+ const headers = {
44
+ Authorization: `Bearer ${this.cfg.apiToken}`,
45
+ Accept: "application/json"
46
+ };
47
+ if (opts.body !== void 0) headers["Content-Type"] = "application/json";
48
+ this.log.debug(`HTTP ${method} ${url.pathname}`);
49
+ const res = await fetch(url, {
50
+ method,
51
+ headers,
52
+ body: opts.body !== void 0 ? JSON.stringify(opts.body) : void 0
53
+ });
54
+ const text = await res.text();
55
+ if (!res.ok) {
56
+ let code;
57
+ try {
58
+ const parsed = JSON.parse(text);
59
+ code = typeof parsed?.error === "string" ? parsed.error : parsed?.code;
60
+ } catch {
61
+ }
62
+ throw new PrysmidApiError(
63
+ `Prysmid API ${res.status} on ${method} ${path}`,
64
+ res.status,
65
+ text,
66
+ code
67
+ );
68
+ }
69
+ if (text === "") return void 0;
70
+ try {
71
+ return JSON.parse(text);
72
+ } catch {
73
+ return text;
74
+ }
75
+ }
76
+ };
77
+
78
+ // src/config.ts
79
+ var DEFAULT_API_BASE = "https://api.prysmid.com";
80
+ function loadConfig(env = process.env) {
81
+ const apiBase = (env.PRYSMID_API_BASE ?? DEFAULT_API_BASE).replace(/\/+$/, "");
82
+ const apiToken = env.PRYSMID_API_TOKEN?.trim() || null;
83
+ const rawLevel = (env.PRYSMID_MCP_LOG_LEVEL ?? "info").toLowerCase();
84
+ const logLevel = rawLevel === "debug" || rawLevel === "warn" || rawLevel === "error" ? rawLevel : "info";
85
+ return { apiBase, apiToken, logLevel };
86
+ }
87
+
88
+ // src/logger.ts
89
+ var ORDER = { debug: 10, info: 20, warn: 30, error: 40 };
90
+ function makeLogger(cfg) {
91
+ const threshold = ORDER[cfg.logLevel];
92
+ function emit(level, msg, extra) {
93
+ if (ORDER[level] < threshold) return;
94
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
95
+ const payload = extra === void 0 ? "" : ` ${safeJSON(extra)}`;
96
+ process.stderr.write(`${ts} ${level.toUpperCase()} ${msg}${payload}
97
+ `);
98
+ }
99
+ return {
100
+ debug: (m, e) => emit("debug", m, e),
101
+ info: (m, e) => emit("info", m, e),
102
+ warn: (m, e) => emit("warn", m, e),
103
+ error: (m, e) => emit("error", m, e)
104
+ };
105
+ }
106
+ function safeJSON(x) {
107
+ try {
108
+ return JSON.stringify(x);
109
+ } catch {
110
+ return String(x);
111
+ }
112
+ }
113
+
114
+ // src/tools/registry.ts
115
+ function defineTool(t) {
116
+ return t;
117
+ }
118
+ function registerAll(server, ctx, tools9) {
119
+ for (const tool of tools9) {
120
+ server.registerTool(
121
+ tool.name,
122
+ {
123
+ description: tool.description,
124
+ inputSchema: tool.inputShape
125
+ },
126
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
+ async (input) => {
128
+ try {
129
+ const result = await tool.handler(input, ctx);
130
+ return {
131
+ content: [
132
+ {
133
+ type: "text",
134
+ text: typeof result === "string" ? result : JSON.stringify(result, null, 2)
135
+ }
136
+ ]
137
+ };
138
+ } catch (err) {
139
+ const message = err instanceof Error ? err.message : String(err);
140
+ ctx.log.error(`tool ${tool.name} failed`, { message });
141
+ return {
142
+ isError: true,
143
+ content: [
144
+ { type: "text", text: `error: ${message}` }
145
+ ]
146
+ };
147
+ }
148
+ }
149
+ );
150
+ }
151
+ }
152
+
153
+ // src/tools/apps.ts
154
+ import { z } from "zod";
155
+ var listApps = defineTool({
156
+ name: "list_apps",
157
+ description: "List all OIDC apps in a workspace.",
158
+ inputShape: {
159
+ workspace: z.string().min(1).describe("Workspace slug or UUID")
160
+ },
161
+ handler: async ({ workspace }, { client }) => client.request(`/v1/workspaces/${encodeURIComponent(workspace)}/apps`)
162
+ });
163
+ var createOidcApp = defineTool({
164
+ name: "create_oidc_app",
165
+ description: "Create an OIDC application in a workspace. Returns client_id (and client_secret if confidential). Use auth_method=NONE for SPA/PKCE; use BASIC for confidential web apps.",
166
+ inputShape: {
167
+ workspace: z.string().min(1),
168
+ name: z.string().min(1).max(255),
169
+ redirect_uris: z.array(z.string().url()).min(1),
170
+ post_logout_redirect_uris: z.array(z.string().url()).optional(),
171
+ app_type: z.enum([
172
+ "OIDC_APP_TYPE_WEB",
173
+ "OIDC_APP_TYPE_USER_AGENT",
174
+ "OIDC_APP_TYPE_NATIVE"
175
+ ]).default("OIDC_APP_TYPE_WEB"),
176
+ auth_method: z.enum([
177
+ "OIDC_AUTH_METHOD_TYPE_NONE",
178
+ "OIDC_AUTH_METHOD_TYPE_BASIC",
179
+ "OIDC_AUTH_METHOD_TYPE_POST"
180
+ ]).default("OIDC_AUTH_METHOD_TYPE_NONE"),
181
+ dev_mode: z.boolean().default(false).describe(
182
+ "Skip redirect URI HTTPS check \u2014 only for local dev, NEVER prod."
183
+ )
184
+ },
185
+ handler: async ({ workspace, ...body }, { client }) => client.request(
186
+ `/v1/workspaces/${encodeURIComponent(workspace)}/apps`,
187
+ { method: "POST", body }
188
+ )
189
+ });
190
+ var deleteOidcApp = defineTool({
191
+ name: "delete_oidc_app",
192
+ description: "Delete an OIDC app. Idempotent \u2014 404 returns success.",
193
+ inputShape: {
194
+ workspace: z.string().min(1),
195
+ app_id: z.string().min(1)
196
+ },
197
+ handler: async ({ workspace, app_id }, { client }) => client.request(
198
+ `/v1/workspaces/${encodeURIComponent(workspace)}/apps/${encodeURIComponent(app_id)}`,
199
+ { method: "DELETE" }
200
+ )
201
+ });
202
+ var tools = [listApps, createOidcApp, deleteOidcApp];
203
+
204
+ // src/tools/billing.ts
205
+ import { z as z2 } from "zod";
206
+ var getBilling = defineTool({
207
+ name: "get_billing",
208
+ description: "Get current billing state: plan, subscription status, current period, spending_cap_cents, signups_blocked.",
209
+ inputShape: {
210
+ workspace: z2.string().min(1)
211
+ },
212
+ handler: async ({ workspace }, { client }) => client.request(
213
+ `/v1/workspaces/${encodeURIComponent(workspace)}/billing`
214
+ )
215
+ });
216
+ var setSpendingCap = defineTool({
217
+ name: "set_spending_cap",
218
+ description: "Cap monthly Pro overage spend (cents). Pass null to remove cap (unlimited). When projected overage exceeds cap, signups_blocked flips on.",
219
+ inputShape: {
220
+ workspace: z2.string().min(1),
221
+ spending_cap_cents: z2.number().int().min(0).max(1e7).nullable().describe("Max overage cents per period; null = unlimited")
222
+ },
223
+ handler: async ({ workspace, spending_cap_cents }, { client }) => client.request(
224
+ `/v1/workspaces/${encodeURIComponent(workspace)}/billing/spending-cap`,
225
+ { method: "PATCH", body: { spending_cap_cents } }
226
+ )
227
+ });
228
+ var startCheckout = defineTool({
229
+ name: "start_billing_checkout",
230
+ description: "Create a Stripe Checkout session for upgrading. Returns the URL the user must visit. Plan must be `pro` (Free has no checkout; Enterprise is sales-only).",
231
+ inputShape: {
232
+ workspace: z2.string().min(1),
233
+ plan: z2.enum(["pro"])
234
+ },
235
+ handler: async ({ workspace, plan }, { client }) => client.request(
236
+ `/v1/workspaces/${encodeURIComponent(workspace)}/billing/checkout`,
237
+ { method: "POST", body: { plan } }
238
+ )
239
+ });
240
+ var startBillingPortal = defineTool({
241
+ name: "start_billing_portal",
242
+ description: "Create a Stripe customer-portal session URL where the user manages payment methods, downloads invoices, cancels subscription.",
243
+ inputShape: {
244
+ workspace: z2.string().min(1)
245
+ },
246
+ handler: async ({ workspace }, { client }) => client.request(
247
+ `/v1/workspaces/${encodeURIComponent(workspace)}/billing/portal`,
248
+ { method: "POST" }
249
+ )
250
+ });
251
+ var tools2 = [
252
+ getBilling,
253
+ setSpendingCap,
254
+ startCheckout,
255
+ startBillingPortal
256
+ ];
257
+
258
+ // src/tools/branding.ts
259
+ import { z as z3 } from "zod";
260
+ var getBranding = defineTool({
261
+ name: "get_branding",
262
+ description: "Return the workspace's active branding policy (colors, fonts, hide-prysmid-watermark flag, logo URLs).",
263
+ inputShape: {
264
+ workspace: z3.string().min(1)
265
+ },
266
+ handler: async ({ workspace }, { client }) => client.request(
267
+ `/v1/workspaces/${encodeURIComponent(workspace)}/branding`
268
+ )
269
+ });
270
+ var updateBranding = defineTool({
271
+ name: "update_branding",
272
+ description: "Update branding colors and watermark. Hex colors as `#RRGGBB`. Activates the policy after update \u2014 change shows on next login screen render.",
273
+ inputShape: {
274
+ workspace: z3.string().min(1),
275
+ primary_color: z3.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
276
+ background_color: z3.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
277
+ warn_color: z3.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
278
+ font_color: z3.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
279
+ disable_watermark: z3.boolean().optional().describe(
280
+ "Hide 'Powered by Prysmid' on the login screen (Pro+ only \u2014 Free silently ignored)."
281
+ )
282
+ },
283
+ handler: async ({ workspace, ...body }, { client }) => client.request(
284
+ `/v1/workspaces/${encodeURIComponent(workspace)}/branding`,
285
+ { method: "PATCH", body }
286
+ )
287
+ });
288
+ var tools3 = [getBranding, updateBranding];
289
+
290
+ // src/tools/curated.ts
291
+ import { z as z4 } from "zod";
292
+ var SetupWorkspaceOutput = z4.object({
293
+ workspace_id: z4.string(),
294
+ slug: z4.string(),
295
+ auth_domain: z4.string(),
296
+ state: z4.string()
297
+ });
298
+ var setupPrysmidWorkspace = defineTool({
299
+ name: "setup_prysmid_workspace",
300
+ description: "Create a new workspace and wait until it's fully provisioned (Zitadel instance, SMTP, DNS). Returns the live auth_domain ready to integrate.",
301
+ inputShape: {
302
+ slug: z4.string().min(2).max(63).regex(/^[a-z0-9-]+$/),
303
+ display_name: z4.string().min(1),
304
+ timeout_seconds: z4.number().int().min(10).max(300).default(120).describe("Max time to wait for provisioning before returning.")
305
+ },
306
+ handler: async ({ slug, display_name, timeout_seconds }, { client, log }) => {
307
+ const created = await client.request("/v1/workspaces", {
308
+ method: "POST",
309
+ body: { slug, display_name }
310
+ });
311
+ const deadline = Date.now() + timeout_seconds * 1e3;
312
+ while (Date.now() < deadline) {
313
+ const ws = await client.request(
314
+ `/v1/workspaces/${encodeURIComponent(created.id)}`
315
+ );
316
+ if (ws.state === "active") {
317
+ return SetupWorkspaceOutput.parse({
318
+ workspace_id: ws.id,
319
+ slug: ws.slug,
320
+ auth_domain: ws.auth_domain ?? `auth.${ws.slug}.prysmid.com`,
321
+ state: ws.state
322
+ });
323
+ }
324
+ if (ws.state === "provisioning_failed") {
325
+ throw new Error(
326
+ `Workspace provisioning failed: ${ws.provisioning_error ?? "unknown reason"}`
327
+ );
328
+ }
329
+ log.debug(`workspace ${created.id} state=${ws.state}, polling\u2026`);
330
+ await sleep(3e3);
331
+ }
332
+ throw new Error(
333
+ `Workspace did not reach state=active within ${timeout_seconds}s`
334
+ );
335
+ }
336
+ });
337
+ function sleep(ms) {
338
+ return new Promise((r) => setTimeout(r, ms));
339
+ }
340
+ var enableGoogleLogin = defineTool({
341
+ name: "enable_google_login",
342
+ description: "Add Google as an identity provider on a workspace and enable external IdPs in the login policy. Hands you a checklist if external IdPs were already disabled \u2014 agent should confirm before flipping that flag.",
343
+ inputShape: {
344
+ workspace: z4.string().min(1),
345
+ google_client_id: z4.string().min(1),
346
+ google_client_secret: z4.string().min(1),
347
+ name: z4.string().default("Google")
348
+ },
349
+ handler: async ({ workspace, google_client_id, google_client_secret, name }, { client }) => {
350
+ const idp = await client.request(
351
+ `/v1/workspaces/${encodeURIComponent(workspace)}/idps`,
352
+ {
353
+ method: "POST",
354
+ body: {
355
+ provider: "google",
356
+ name,
357
+ config: {
358
+ client_id: google_client_id,
359
+ client_secret: google_client_secret
360
+ }
361
+ }
362
+ }
363
+ );
364
+ await client.request(
365
+ `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`,
366
+ { method: "PATCH", body: { allow_external_idp: true } }
367
+ );
368
+ return { idp, login_policy: "allow_external_idp=true" };
369
+ }
370
+ });
371
+ var prysmidSetupCheck = defineTool({
372
+ name: "prysmid_setup_check",
373
+ description: "Run a readiness checklist on a workspace: state=active, \u22651 OIDC app, \u22651 IdP OR password+register enabled, branding has a primary_color set, login_policy reasonable. Returns pass/fail per item plus a summary verdict.",
374
+ inputShape: {
375
+ workspace: z4.string().min(1)
376
+ },
377
+ handler: async ({ workspace }, { client }) => {
378
+ const ws = await client.request(
379
+ `/v1/workspaces/${encodeURIComponent(workspace)}`
380
+ );
381
+ const apps = await client.request(
382
+ `/v1/workspaces/${encodeURIComponent(workspace)}/apps`
383
+ );
384
+ const idps = await client.request(
385
+ `/v1/workspaces/${encodeURIComponent(workspace)}/idps`
386
+ );
387
+ const policy = await client.request(
388
+ `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`
389
+ );
390
+ const branding = await client.request(
391
+ `/v1/workspaces/${encodeURIComponent(workspace)}/branding`
392
+ );
393
+ const checks = [
394
+ {
395
+ ok: ws.state === "active",
396
+ name: "workspace_active",
397
+ details: `state=${ws.state}`
398
+ },
399
+ {
400
+ ok: apps.length > 0,
401
+ name: "has_at_least_one_app",
402
+ details: `${apps.length} apps`
403
+ },
404
+ {
405
+ ok: idps.length > 0 || policy.allow_username_password === true && policy.allow_register === true,
406
+ name: "users_can_sign_in",
407
+ details: idps.length > 0 ? `${idps.length} idps` : "no idps; must allow username+password+register"
408
+ },
409
+ {
410
+ ok: !!branding.primary_color,
411
+ name: "branding_primary_color_set"
412
+ },
413
+ {
414
+ ok: policy.force_mfa === true || idps.length > 0,
415
+ name: "auth_strength_reasonable",
416
+ details: policy.force_mfa ? "force_mfa=true" : "MFA off but external IdP present"
417
+ }
418
+ ];
419
+ const verdict = checks.every((c) => c.ok) ? "ready" : "incomplete";
420
+ return { verdict, checks };
421
+ }
422
+ });
423
+ var tools4 = [
424
+ setupPrysmidWorkspace,
425
+ enableGoogleLogin,
426
+ prysmidSetupCheck
427
+ ];
428
+
429
+ // src/tools/idps.ts
430
+ import { z as z5 } from "zod";
431
+ var listIdps = defineTool({
432
+ name: "list_idps",
433
+ description: "List identity providers (Google/GitHub/Microsoft/OIDC) configured on a workspace.",
434
+ inputShape: {
435
+ workspace: z5.string().min(1)
436
+ },
437
+ handler: async ({ workspace }, { client }) => client.request(`/v1/workspaces/${encodeURIComponent(workspace)}/idps`)
438
+ });
439
+ var addIdp = defineTool({
440
+ name: "add_idp",
441
+ description: "Add an identity provider to the workspace and attach it to the login policy in one atomic call. Provider-specific fields go in `config`.",
442
+ inputShape: {
443
+ workspace: z5.string().min(1),
444
+ provider: z5.enum(["google", "github", "azure_ad", "oidc"]),
445
+ name: z5.string().min(1).describe("Display name shown on login screen"),
446
+ config: z5.object({
447
+ client_id: z5.string().min(1),
448
+ client_secret: z5.string().min(1),
449
+ scopes: z5.array(z5.string()).optional(),
450
+ issuer: z5.string().url().optional().describe("Required for `oidc`; ignored otherwise"),
451
+ tenant_id: z5.string().optional().describe(
452
+ "Required for `azure_ad` to lock to a specific Microsoft tenant"
453
+ )
454
+ }).describe("Provider-specific OAuth config")
455
+ },
456
+ handler: async ({ workspace, ...body }, { client }) => client.request(
457
+ `/v1/workspaces/${encodeURIComponent(workspace)}/idps`,
458
+ { method: "POST", body }
459
+ )
460
+ });
461
+ var deleteIdp = defineTool({
462
+ name: "delete_idp",
463
+ description: "Remove an identity provider. Strips it from the login policy then deletes the config. Idempotent.",
464
+ inputShape: {
465
+ workspace: z5.string().min(1),
466
+ idp_id: z5.string().min(1)
467
+ },
468
+ handler: async ({ workspace, idp_id }, { client }) => client.request(
469
+ `/v1/workspaces/${encodeURIComponent(workspace)}/idps/${encodeURIComponent(idp_id)}`,
470
+ { method: "DELETE" }
471
+ )
472
+ });
473
+ var tools5 = [listIdps, addIdp, deleteIdp];
474
+
475
+ // src/tools/login_policy.ts
476
+ import { z as z6 } from "zod";
477
+ var getLoginPolicy = defineTool({
478
+ name: "get_login_policy",
479
+ description: "Return the workspace's current login policy (password rules, MFA, IdPs allowed, lockout, etc.).",
480
+ inputShape: {
481
+ workspace: z6.string().min(1)
482
+ },
483
+ handler: async ({ workspace }, { client }) => client.request(
484
+ `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`
485
+ )
486
+ });
487
+ var updateLoginPolicy = defineTool({
488
+ name: "update_login_policy",
489
+ description: "Update the login policy. PATCH semantics \u2014 only fields you pass are changed; other policy fields stay as they were.",
490
+ inputShape: {
491
+ workspace: z6.string().min(1),
492
+ allow_username_password: z6.boolean().optional(),
493
+ allow_register: z6.boolean().optional(),
494
+ allow_external_idp: z6.boolean().optional(),
495
+ force_mfa: z6.boolean().optional().describe("Require any second factor at login"),
496
+ passwordless_type: z6.enum([
497
+ "PASSWORDLESS_TYPE_NOT_ALLOWED",
498
+ "PASSWORDLESS_TYPE_ALLOWED"
499
+ ]).optional().describe("Enables passkey-first when set to ALLOWED"),
500
+ max_password_attempts: z6.number().int().min(0).max(20).optional(),
501
+ lockout_password_attempts: z6.number().int().min(0).max(20).optional()
502
+ },
503
+ handler: async ({ workspace, ...body }, { client }) => client.request(
504
+ `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`,
505
+ { method: "PATCH", body }
506
+ )
507
+ });
508
+ var tools6 = [getLoginPolicy, updateLoginPolicy];
509
+
510
+ // src/tools/users.ts
511
+ import { z as z7 } from "zod";
512
+ var listUsers = defineTool({
513
+ name: "list_users",
514
+ description: "List human users in a workspace.",
515
+ inputShape: {
516
+ workspace: z7.string().min(1),
517
+ limit: z7.number().int().min(1).max(500).default(100)
518
+ },
519
+ handler: async ({ workspace, limit }, { client }) => client.request(
520
+ `/v1/workspaces/${encodeURIComponent(workspace)}/users`,
521
+ { query: { limit } }
522
+ )
523
+ });
524
+ var inviteUser = defineTool({
525
+ name: "invite_user",
526
+ description: "Invite a user by email. Idempotent by email \u2014 re-inviting an existing user is a no-op. Triggers a Zitadel init email with a 'set your password' link.",
527
+ inputShape: {
528
+ workspace: z7.string().min(1),
529
+ email: z7.string().regex(/^[^\s@]+@[^\s@]+\.[^\s@]+$/, "must be a valid email"),
530
+ first_name: z7.string().min(1),
531
+ last_name: z7.string().min(1),
532
+ preferred_language: z7.string().length(2).default("en").describe("ISO 639-1, e.g. en/es/pt")
533
+ },
534
+ handler: async ({ workspace, ...body }, { client }) => client.request(
535
+ `/v1/workspaces/${encodeURIComponent(workspace)}/users/invite`,
536
+ { method: "POST", body }
537
+ )
538
+ });
539
+ var deleteUser = defineTool({
540
+ name: "delete_user",
541
+ description: "Delete a user by id. Idempotent.",
542
+ inputShape: {
543
+ workspace: z7.string().min(1),
544
+ user_id: z7.string().min(1)
545
+ },
546
+ handler: async ({ workspace, user_id }, { client }) => client.request(
547
+ `/v1/workspaces/${encodeURIComponent(workspace)}/users/${encodeURIComponent(user_id)}`,
548
+ { method: "DELETE" }
549
+ )
550
+ });
551
+ var tools7 = [listUsers, inviteUser, deleteUser];
552
+
553
+ // src/tools/workspaces.ts
554
+ import { z as z8 } from "zod";
555
+ var listWorkspaces = defineTool({
556
+ name: "list_workspaces",
557
+ description: "List Prysmid workspaces accessible to the current API token. Returns an array of {id, slug, display_name, plan, state}.",
558
+ inputShape: {},
559
+ handler: async (_input, { client }) => client.request("/v1/workspaces", { method: "GET" })
560
+ });
561
+ var getWorkspace = defineTool({
562
+ name: "get_workspace",
563
+ description: "Get a single workspace by slug or id.",
564
+ inputShape: {
565
+ workspace: z8.string().min(1).describe("Workspace slug or UUID")
566
+ },
567
+ handler: async ({ workspace }, { client }) => client.request(`/v1/workspaces/${encodeURIComponent(workspace)}`)
568
+ });
569
+ var createWorkspace = defineTool({
570
+ name: "create_workspace",
571
+ description: "Create a new Prysmid workspace. Provisioning runs in the background; the response returns immediately with state=provisioning. Poll `get_workspace` until state=active (~30s).",
572
+ inputShape: {
573
+ slug: z8.string().min(2).max(63).regex(/^[a-z0-9-]+$/, "lowercase alphanumeric and hyphens only").describe("Subdomain-safe slug \u2014 becomes auth.<slug>.prysmid.com"),
574
+ display_name: z8.string().min(1).max(255)
575
+ },
576
+ handler: async (input, { client }) => client.request("/v1/workspaces", { method: "POST", body: input })
577
+ });
578
+ var tools8 = [listWorkspaces, getWorkspace, createWorkspace];
579
+
580
+ // src/index.ts
581
+ import { readFileSync } from "fs";
582
+ import { fileURLToPath } from "url";
583
+ import { dirname, resolve } from "path";
584
+ var SERVER_NAME = "prysmid";
585
+ function readVersion() {
586
+ try {
587
+ const here = dirname(fileURLToPath(import.meta.url));
588
+ const pkg = JSON.parse(
589
+ readFileSync(resolve(here, "..", "package.json"), "utf8")
590
+ );
591
+ return typeof pkg.version === "string" ? pkg.version : "0.0.0";
592
+ } catch {
593
+ return "0.0.0";
594
+ }
595
+ }
596
+ async function main() {
597
+ const cfg = loadConfig();
598
+ const log = makeLogger(cfg);
599
+ const client = new PrysmidClient(cfg, log);
600
+ const server = new McpServer({
601
+ name: SERVER_NAME,
602
+ version: readVersion()
603
+ });
604
+ const allTools = [
605
+ ...tools8,
606
+ ...tools,
607
+ ...tools5,
608
+ ...tools6,
609
+ ...tools7,
610
+ ...tools3,
611
+ ...tools2,
612
+ ...tools4
613
+ ];
614
+ registerAll(server, { client, log }, allTools);
615
+ log.info(`prysmid-mcp starting`, {
616
+ apiBase: cfg.apiBase,
617
+ tools: allTools.length,
618
+ authMode: cfg.apiToken ? "bearer" : "none"
619
+ });
620
+ const transport = new StdioServerTransport();
621
+ await server.connect(transport);
622
+ }
623
+ main().catch((err) => {
624
+ process.stderr.write(`fatal: ${err instanceof Error ? err.stack : err}
625
+ `);
626
+ process.exit(1);
627
+ });
628
+ export {
629
+ main
630
+ };
631
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/config.ts","../src/logger.ts","../src/tools/registry.ts","../src/tools/apps.ts","../src/tools/billing.ts","../src/tools/branding.ts","../src/tools/curated.ts","../src/tools/idps.ts","../src/tools/login_policy.ts","../src/tools/users.ts","../src/tools/workspaces.ts"],"sourcesContent":["/**\n * Entrypoint — boots an MCP server over stdio with the full Prysmid tool set.\n *\n * MCP transport contract:\n * - JSON-RPC over stdin/stdout\n * - stdout is RESERVED for protocol bytes; logs go to stderr (see logger.ts)\n * - one process == one client; the agent spawns a fresh server per session\n */\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport { PrysmidClient } from \"./client.js\";\nimport { loadConfig } from \"./config.js\";\nimport { makeLogger } from \"./logger.js\";\nimport { registerAll } from \"./tools/registry.js\";\nimport { tools as appsTools } from \"./tools/apps.js\";\nimport { tools as billingTools } from \"./tools/billing.js\";\nimport { tools as brandingTools } from \"./tools/branding.js\";\nimport { tools as curatedTools } from \"./tools/curated.js\";\nimport { tools as idpsTools } from \"./tools/idps.js\";\nimport { tools as loginPolicyTools } from \"./tools/login_policy.js\";\nimport { tools as usersTools } from \"./tools/users.js\";\nimport { tools as workspaceTools } from \"./tools/workspaces.js\";\n\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { dirname, resolve } from \"node:path\";\n\nconst SERVER_NAME = \"prysmid\";\n\nfunction readVersion(): string {\n try {\n const here = dirname(fileURLToPath(import.meta.url));\n const pkg = JSON.parse(\n readFileSync(resolve(here, \"..\", \"package.json\"), \"utf8\"),\n );\n return typeof pkg.version === \"string\" ? pkg.version : \"0.0.0\";\n } catch {\n return \"0.0.0\";\n }\n}\n\nexport async function main(): Promise<void> {\n const cfg = loadConfig();\n const log = makeLogger(cfg);\n const client = new PrysmidClient(cfg, log);\n\n const server = new McpServer({\n name: SERVER_NAME,\n version: readVersion(),\n });\n\n const allTools = [\n ...workspaceTools,\n ...appsTools,\n ...idpsTools,\n ...loginPolicyTools,\n ...usersTools,\n ...brandingTools,\n ...billingTools,\n ...curatedTools,\n ];\n\n registerAll(server, { client, log }, allTools);\n\n log.info(`prysmid-mcp starting`, {\n apiBase: cfg.apiBase,\n tools: allTools.length,\n authMode: cfg.apiToken ? \"bearer\" : \"none\",\n });\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\n// This module is only ever invoked as the package bin (MCP servers run as a\n// process per session). Cross-platform `import.meta.url === file://<argv[1]>`\n// is fragile (Windows backslash vs forward slash; symlinked paths) so we\n// just always boot.\nmain().catch((err) => {\n process.stderr.write(`fatal: ${err instanceof Error ? err.stack : err}\\n`);\n process.exit(1);\n});\n","/**\n * Prysmid API client — thin fetch wrapper that adds auth + maps errors.\n *\n * Auth model (MVP): static bearer via `PRYSMID_API_TOKEN`. Device-flow OAuth\n * lives in `auth.ts` and produces a token compatible with this client.\n */\nimport type { Config } from \"./config.js\";\nimport type { Logger } from \"./logger.js\";\n\nexport class PrysmidApiError extends Error {\n constructor(\n message: string,\n public readonly status: number,\n public readonly body: string,\n public readonly code?: string,\n ) {\n super(message);\n this.name = \"PrysmidApiError\";\n }\n}\n\nexport interface RequestOptions {\n method?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined>;\n}\n\nexport class PrysmidClient {\n constructor(\n private readonly cfg: Config,\n private readonly log: Logger,\n ) {}\n\n async request<T = unknown>(path: string, opts: RequestOptions = {}): Promise<T> {\n if (!this.cfg.apiToken) {\n throw new PrysmidApiError(\n \"No PRYSMID_API_TOKEN configured. Set the env var or run device-flow login.\",\n 401,\n \"\",\n \"auth.no_token\",\n );\n }\n\n const url = new URL(this.cfg.apiBase + path);\n if (opts.query) {\n for (const [k, v] of Object.entries(opts.query)) {\n if (v !== undefined) url.searchParams.set(k, String(v));\n }\n }\n\n const method = opts.method ?? \"GET\";\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.cfg.apiToken}`,\n Accept: \"application/json\",\n };\n if (opts.body !== undefined) headers[\"Content-Type\"] = \"application/json\";\n\n this.log.debug(`HTTP ${method} ${url.pathname}`);\n const res = await fetch(url, {\n method,\n headers,\n body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,\n });\n\n const text = await res.text();\n if (!res.ok) {\n let code: string | undefined;\n try {\n const parsed = JSON.parse(text);\n code = typeof parsed?.error === \"string\" ? parsed.error : parsed?.code;\n } catch {\n // body wasn't JSON\n }\n throw new PrysmidApiError(\n `Prysmid API ${res.status} on ${method} ${path}`,\n res.status,\n text,\n code,\n );\n }\n\n if (text === \"\") return undefined as T;\n try {\n return JSON.parse(text) as T;\n } catch {\n return text as unknown as T;\n }\n }\n}\n","/**\n * Runtime configuration. Pulled from env at startup; immutable thereafter.\n *\n * The MCP runs as a long-lived stdio process — env reads happen once.\n */\n\nexport interface Config {\n apiBase: string;\n apiToken: string | null;\n logLevel: \"debug\" | \"info\" | \"warn\" | \"error\";\n}\n\nconst DEFAULT_API_BASE = \"https://api.prysmid.com\";\n\nexport function loadConfig(env: NodeJS.ProcessEnv = process.env): Config {\n const apiBase = (env.PRYSMID_API_BASE ?? DEFAULT_API_BASE).replace(/\\/+$/, \"\");\n const apiToken = env.PRYSMID_API_TOKEN?.trim() || null;\n const rawLevel = (env.PRYSMID_MCP_LOG_LEVEL ?? \"info\").toLowerCase();\n const logLevel: Config[\"logLevel\"] =\n rawLevel === \"debug\" || rawLevel === \"warn\" || rawLevel === \"error\"\n ? rawLevel\n : \"info\";\n return { apiBase, apiToken, logLevel };\n}\n","/**\n * stderr-only logger. MCP servers MUST NOT write to stdout — that channel\n * is reserved for the JSON-RPC protocol; any stray byte breaks the agent.\n */\nimport type { Config } from \"./config.js\";\n\nconst ORDER = { debug: 10, info: 20, warn: 30, error: 40 } as const;\n\nexport interface Logger {\n debug: (msg: string, extra?: unknown) => void;\n info: (msg: string, extra?: unknown) => void;\n warn: (msg: string, extra?: unknown) => void;\n error: (msg: string, extra?: unknown) => void;\n}\n\nexport function makeLogger(cfg: Pick<Config, \"logLevel\">): Logger {\n const threshold = ORDER[cfg.logLevel];\n\n function emit(level: keyof typeof ORDER, msg: string, extra?: unknown) {\n if (ORDER[level] < threshold) return;\n const ts = new Date().toISOString();\n const payload = extra === undefined ? \"\" : ` ${safeJSON(extra)}`;\n process.stderr.write(`${ts} ${level.toUpperCase()} ${msg}${payload}\\n`);\n }\n\n return {\n debug: (m, e) => emit(\"debug\", m, e),\n info: (m, e) => emit(\"info\", m, e),\n warn: (m, e) => emit(\"warn\", m, e),\n error: (m, e) => emit(\"error\", m, e),\n };\n}\n\nfunction safeJSON(x: unknown): string {\n try {\n return JSON.stringify(x);\n } catch {\n return String(x);\n }\n}\n","/**\n * Tool registry — single place where every MCP tool lives. Each tool exports\n * its input schema (Zod) + handler; `registerAll` wires them into the SDK.\n *\n * Two flavors of tools coexist:\n * - generated: 1:1 with REST endpoints, produced by `scripts/generate-tools.ts`\n * (lives under `tools/generated/*` once the script runs)\n * - curated: high-level orchestrators a human/agent actually wants to call,\n * e.g. `setup_prysmid_workspace(company_name)` that combines several\n * endpoints. These live under `tools/curated/*`.\n *\n * Both share the same `Tool` shape so the registry is uniform.\n */\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n\nimport type { PrysmidClient } from \"../client.js\";\nimport type { Logger } from \"../logger.js\";\n\nexport interface ToolContext {\n client: PrysmidClient;\n log: Logger;\n}\n\nexport interface ToolDef<I extends z.ZodRawShape> {\n name: string;\n description: string;\n inputShape: I;\n /**\n * Handler returns plain JSON-able output. The SDK serializes it into\n * MCP `content` blocks; we wrap to text by default (most MCP UIs render it\n * better than structured content).\n */\n handler: (\n input: z.infer<z.ZodObject<I>>,\n ctx: ToolContext,\n ) => Promise<unknown>;\n}\n\nexport function defineTool<I extends z.ZodRawShape>(t: ToolDef<I>): ToolDef<I> {\n return t;\n}\n\n// `ToolDef<any>` here intentionally — the array is heterogeneous (each tool\n// has its own input shape) and the SDK's registerTool only cares about the\n// runtime Zod object, not compile-time type inference. Without `any` there's\n// no single ZodRawShape that satisfies every entry simultaneously.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function registerAll(\n server: McpServer,\n ctx: ToolContext,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tools: ReadonlyArray<ToolDef<any>>,\n): void {\n for (const tool of tools) {\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n inputSchema: tool.inputShape,\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async (input: any) => {\n try {\n const result = await tool.handler(input, ctx);\n return {\n content: [\n {\n type: \"text\" as const,\n text:\n typeof result === \"string\"\n ? result\n : JSON.stringify(result, null, 2),\n },\n ],\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n ctx.log.error(`tool ${tool.name} failed`, { message });\n return {\n isError: true,\n content: [\n { type: \"text\" as const, text: `error: ${message}` },\n ],\n };\n }\n },\n );\n }\n}\n","/**\n * OIDC application tools — list, create, delete on a workspace's apps.\n * Apps are the integration unit: each one represents one downstream service\n * (web app, mobile app, CLI) that authenticates via Prysmid.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const listApps = defineTool({\n name: \"list_apps\",\n description: \"List all OIDC apps in a workspace.\",\n inputShape: {\n workspace: z.string().min(1).describe(\"Workspace slug or UUID\"),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(`/v1/workspaces/${encodeURIComponent(workspace)}/apps`),\n});\n\nexport const createOidcApp = defineTool({\n name: \"create_oidc_app\",\n description:\n \"Create an OIDC application in a workspace. Returns client_id (and client_secret if confidential). Use auth_method=NONE for SPA/PKCE; use BASIC for confidential web apps.\",\n inputShape: {\n workspace: z.string().min(1),\n name: z.string().min(1).max(255),\n redirect_uris: z.array(z.string().url()).min(1),\n post_logout_redirect_uris: z.array(z.string().url()).optional(),\n app_type: z\n .enum([\n \"OIDC_APP_TYPE_WEB\",\n \"OIDC_APP_TYPE_USER_AGENT\",\n \"OIDC_APP_TYPE_NATIVE\",\n ])\n .default(\"OIDC_APP_TYPE_WEB\"),\n auth_method: z\n .enum([\n \"OIDC_AUTH_METHOD_TYPE_NONE\",\n \"OIDC_AUTH_METHOD_TYPE_BASIC\",\n \"OIDC_AUTH_METHOD_TYPE_POST\",\n ])\n .default(\"OIDC_AUTH_METHOD_TYPE_NONE\"),\n dev_mode: z\n .boolean()\n .default(false)\n .describe(\n \"Skip redirect URI HTTPS check — only for local dev, NEVER prod.\",\n ),\n },\n handler: async ({ workspace, ...body }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/apps`,\n { method: \"POST\", body },\n ),\n});\n\nexport const deleteOidcApp = defineTool({\n name: \"delete_oidc_app\",\n description: \"Delete an OIDC app. Idempotent — 404 returns success.\",\n inputShape: {\n workspace: z.string().min(1),\n app_id: z.string().min(1),\n },\n handler: async ({ workspace, app_id }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/apps/${encodeURIComponent(app_id)}`,\n { method: \"DELETE\" },\n ),\n});\n\nexport const tools = [listApps, createOidcApp, deleteOidcApp] as const;\n","/**\n * Billing tools — read state, manage spending cap, generate Stripe portal URL.\n * Checkout/upgrade flow returns a Stripe-hosted URL; the agent surfaces it to\n * the user for them to navigate (we don't process payment data here).\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const getBilling = defineTool({\n name: \"get_billing\",\n description:\n \"Get current billing state: plan, subscription status, current period, spending_cap_cents, signups_blocked.\",\n inputShape: {\n workspace: z.string().min(1),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/billing`,\n ),\n});\n\nexport const setSpendingCap = defineTool({\n name: \"set_spending_cap\",\n description:\n \"Cap monthly Pro overage spend (cents). Pass null to remove cap (unlimited). When projected overage exceeds cap, signups_blocked flips on.\",\n inputShape: {\n workspace: z.string().min(1),\n spending_cap_cents: z\n .number()\n .int()\n .min(0)\n .max(10_000_000)\n .nullable()\n .describe(\"Max overage cents per period; null = unlimited\"),\n },\n handler: async ({ workspace, spending_cap_cents }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/billing/spending-cap`,\n { method: \"PATCH\", body: { spending_cap_cents } },\n ),\n});\n\nexport const startCheckout = defineTool({\n name: \"start_billing_checkout\",\n description:\n \"Create a Stripe Checkout session for upgrading. Returns the URL the user must visit. Plan must be `pro` (Free has no checkout; Enterprise is sales-only).\",\n inputShape: {\n workspace: z.string().min(1),\n plan: z.enum([\"pro\"]),\n },\n handler: async ({ workspace, plan }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/billing/checkout`,\n { method: \"POST\", body: { plan } },\n ),\n});\n\nexport const startBillingPortal = defineTool({\n name: \"start_billing_portal\",\n description:\n \"Create a Stripe customer-portal session URL where the user manages payment methods, downloads invoices, cancels subscription.\",\n inputShape: {\n workspace: z.string().min(1),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/billing/portal`,\n { method: \"POST\" },\n ),\n});\n\nexport const tools = [\n getBilling,\n setSpendingCap,\n startCheckout,\n startBillingPortal,\n] as const;\n","/**\n * Branding tools — colors, fonts, logo for the login page. Logo upload is\n * out of MCP scope (multipart binary uploads don't fit MCP tool semantics\n * cleanly); use the dashboard or API directly for that.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const getBranding = defineTool({\n name: \"get_branding\",\n description:\n \"Return the workspace's active branding policy (colors, fonts, hide-prysmid-watermark flag, logo URLs).\",\n inputShape: {\n workspace: z.string().min(1),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/branding`,\n ),\n});\n\nexport const updateBranding = defineTool({\n name: \"update_branding\",\n description:\n \"Update branding colors and watermark. Hex colors as `#RRGGBB`. Activates the policy after update — change shows on next login screen render.\",\n inputShape: {\n workspace: z.string().min(1),\n primary_color: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .optional(),\n background_color: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .optional(),\n warn_color: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .optional(),\n font_color: z\n .string()\n .regex(/^#[0-9a-fA-F]{6}$/)\n .optional(),\n disable_watermark: z\n .boolean()\n .optional()\n .describe(\n \"Hide 'Powered by Prysmid' on the login screen (Pro+ only — Free silently ignored).\",\n ),\n },\n handler: async ({ workspace, ...body }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/branding`,\n { method: \"PATCH\", body },\n ),\n});\n\nexport const tools = [getBranding, updateBranding] as const;\n","/**\n * Curated high-level tools — the ones agents would naturally reach for to\n * accomplish a goal in one call, instead of orchestrating 4 raw endpoints.\n *\n * Keep these small: each represents one end-user intent (\"set up a workspace\n * with Google login\"). Branch logic and prompts stay on the agent side; this\n * file only owns the API choreography.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nconst SetupWorkspaceOutput = z.object({\n workspace_id: z.string(),\n slug: z.string(),\n auth_domain: z.string(),\n state: z.string(),\n});\n\nexport const setupPrysmidWorkspace = defineTool({\n name: \"setup_prysmid_workspace\",\n description:\n \"Create a new workspace and wait until it's fully provisioned (Zitadel instance, SMTP, DNS). Returns the live auth_domain ready to integrate.\",\n inputShape: {\n slug: z\n .string()\n .min(2)\n .max(63)\n .regex(/^[a-z0-9-]+$/),\n display_name: z.string().min(1),\n timeout_seconds: z\n .number()\n .int()\n .min(10)\n .max(300)\n .default(120)\n .describe(\"Max time to wait for provisioning before returning.\"),\n },\n handler: async (\n { slug, display_name, timeout_seconds },\n { client, log },\n ) => {\n const created = (await client.request(\"/v1/workspaces\", {\n method: \"POST\",\n body: { slug, display_name },\n })) as { id: string; slug: string; state: string; auth_domain?: string };\n\n const deadline = Date.now() + timeout_seconds * 1000;\n while (Date.now() < deadline) {\n const ws = (await client.request(\n `/v1/workspaces/${encodeURIComponent(created.id)}`,\n )) as {\n id: string;\n slug: string;\n state: string;\n auth_domain?: string;\n provisioning_error?: string;\n };\n if (ws.state === \"active\") {\n return SetupWorkspaceOutput.parse({\n workspace_id: ws.id,\n slug: ws.slug,\n auth_domain: ws.auth_domain ?? `auth.${ws.slug}.prysmid.com`,\n state: ws.state,\n });\n }\n if (ws.state === \"provisioning_failed\") {\n throw new Error(\n `Workspace provisioning failed: ${ws.provisioning_error ?? \"unknown reason\"}`,\n );\n }\n log.debug(`workspace ${created.id} state=${ws.state}, polling…`);\n await sleep(3000);\n }\n throw new Error(\n `Workspace did not reach state=active within ${timeout_seconds}s`,\n );\n },\n});\n\nfunction sleep(ms: number) {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nexport const enableGoogleLogin = defineTool({\n name: \"enable_google_login\",\n description:\n \"Add Google as an identity provider on a workspace and enable external IdPs in the login policy. Hands you a checklist if external IdPs were already disabled — agent should confirm before flipping that flag.\",\n inputShape: {\n workspace: z.string().min(1),\n google_client_id: z.string().min(1),\n google_client_secret: z.string().min(1),\n name: z.string().default(\"Google\"),\n },\n handler: async (\n { workspace, google_client_id, google_client_secret, name },\n { client },\n ) => {\n const idp = await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/idps`,\n {\n method: \"POST\",\n body: {\n provider: \"google\",\n name,\n config: {\n client_id: google_client_id,\n client_secret: google_client_secret,\n },\n },\n },\n );\n\n // Force-enable external IdP toggle in case the workspace had it off.\n await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`,\n { method: \"PATCH\", body: { allow_external_idp: true } },\n );\n\n return { idp, login_policy: \"allow_external_idp=true\" };\n },\n});\n\ninterface SetupCheckItem {\n ok: boolean;\n name: string;\n details?: string;\n}\n\nexport const prysmidSetupCheck = defineTool({\n name: \"prysmid_setup_check\",\n description:\n \"Run a readiness checklist on a workspace: state=active, ≥1 OIDC app, ≥1 IdP OR password+register enabled, branding has a primary_color set, login_policy reasonable. Returns pass/fail per item plus a summary verdict.\",\n inputShape: {\n workspace: z.string().min(1),\n },\n handler: async ({ workspace }, { client }) => {\n const ws = (await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}`,\n )) as { state: string; auth_domain?: string };\n const apps = (await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/apps`,\n )) as unknown[];\n const idps = (await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/idps`,\n )) as unknown[];\n const policy = (await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`,\n )) as {\n allow_username_password?: boolean;\n allow_register?: boolean;\n allow_external_idp?: boolean;\n force_mfa?: boolean;\n };\n const branding = (await client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/branding`,\n )) as { primary_color?: string };\n\n const checks: SetupCheckItem[] = [\n {\n ok: ws.state === \"active\",\n name: \"workspace_active\",\n details: `state=${ws.state}`,\n },\n {\n ok: apps.length > 0,\n name: \"has_at_least_one_app\",\n details: `${apps.length} apps`,\n },\n {\n ok:\n idps.length > 0 ||\n (policy.allow_username_password === true &&\n policy.allow_register === true),\n name: \"users_can_sign_in\",\n details:\n idps.length > 0\n ? `${idps.length} idps`\n : \"no idps; must allow username+password+register\",\n },\n {\n ok: !!branding.primary_color,\n name: \"branding_primary_color_set\",\n },\n {\n ok: policy.force_mfa === true || idps.length > 0,\n name: \"auth_strength_reasonable\",\n details: policy.force_mfa\n ? \"force_mfa=true\"\n : \"MFA off but external IdP present\",\n },\n ];\n const verdict = checks.every((c) => c.ok) ? \"ready\" : \"incomplete\";\n return { verdict, checks };\n },\n});\n\nexport const tools = [\n setupPrysmidWorkspace,\n enableGoogleLogin,\n prysmidSetupCheck,\n] as const;\n","/**\n * Identity provider tools — Google, GitHub, Microsoft, generic OIDC.\n * Each create_* operation atomically: creates the IdP config AND adds it to\n * the login policy so it appears on the login screen. The Prysmid API\n * encapsulates that two-step lifecycle behind a single endpoint.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const listIdps = defineTool({\n name: \"list_idps\",\n description:\n \"List identity providers (Google/GitHub/Microsoft/OIDC) configured on a workspace.\",\n inputShape: {\n workspace: z.string().min(1),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(`/v1/workspaces/${encodeURIComponent(workspace)}/idps`),\n});\n\nexport const addIdp = defineTool({\n name: \"add_idp\",\n description:\n \"Add an identity provider to the workspace and attach it to the login policy in one atomic call. Provider-specific fields go in `config`.\",\n inputShape: {\n workspace: z.string().min(1),\n provider: z.enum([\"google\", \"github\", \"azure_ad\", \"oidc\"]),\n name: z.string().min(1).describe(\"Display name shown on login screen\"),\n config: z\n .object({\n client_id: z.string().min(1),\n client_secret: z.string().min(1),\n scopes: z.array(z.string()).optional(),\n issuer: z\n .string()\n .url()\n .optional()\n .describe(\"Required for `oidc`; ignored otherwise\"),\n tenant_id: z\n .string()\n .optional()\n .describe(\n \"Required for `azure_ad` to lock to a specific Microsoft tenant\",\n ),\n })\n .describe(\"Provider-specific OAuth config\"),\n },\n handler: async ({ workspace, ...body }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/idps`,\n { method: \"POST\", body },\n ),\n});\n\nexport const deleteIdp = defineTool({\n name: \"delete_idp\",\n description:\n \"Remove an identity provider. Strips it from the login policy then deletes the config. Idempotent.\",\n inputShape: {\n workspace: z.string().min(1),\n idp_id: z.string().min(1),\n },\n handler: async ({ workspace, idp_id }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/idps/${encodeURIComponent(idp_id)}`,\n { method: \"DELETE\" },\n ),\n});\n\nexport const tools = [listIdps, addIdp, deleteIdp] as const;\n","/**\n * Login policy tools — control which authentication methods are allowed,\n * MFA enforcement, lockout thresholds. Patches are merge semantics on the\n * server side; only fields you set are changed.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const getLoginPolicy = defineTool({\n name: \"get_login_policy\",\n description:\n \"Return the workspace's current login policy (password rules, MFA, IdPs allowed, lockout, etc.).\",\n inputShape: {\n workspace: z.string().min(1),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`,\n ),\n});\n\nexport const updateLoginPolicy = defineTool({\n name: \"update_login_policy\",\n description:\n \"Update the login policy. PATCH semantics — only fields you pass are changed; other policy fields stay as they were.\",\n inputShape: {\n workspace: z.string().min(1),\n allow_username_password: z.boolean().optional(),\n allow_register: z.boolean().optional(),\n allow_external_idp: z.boolean().optional(),\n force_mfa: z\n .boolean()\n .optional()\n .describe(\"Require any second factor at login\"),\n passwordless_type: z\n .enum([\n \"PASSWORDLESS_TYPE_NOT_ALLOWED\",\n \"PASSWORDLESS_TYPE_ALLOWED\",\n ])\n .optional()\n .describe(\"Enables passkey-first when set to ALLOWED\"),\n max_password_attempts: z.number().int().min(0).max(20).optional(),\n lockout_password_attempts: z.number().int().min(0).max(20).optional(),\n },\n handler: async ({ workspace, ...body }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/login-policy`,\n { method: \"PATCH\", body },\n ),\n});\n\nexport const tools = [getLoginPolicy, updateLoginPolicy] as const;\n","/**\n * User tools — list, invite (sends Zitadel init email), delete.\n * Invite is the primary creation path; users set their own password via the\n * email link. Direct user creation with pre-set credentials is intentionally\n * not exposed here.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const listUsers = defineTool({\n name: \"list_users\",\n description: \"List human users in a workspace.\",\n inputShape: {\n workspace: z.string().min(1),\n limit: z.number().int().min(1).max(500).default(100),\n },\n handler: async ({ workspace, limit }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/users`,\n { query: { limit } },\n ),\n});\n\nexport const inviteUser = defineTool({\n name: \"invite_user\",\n description:\n \"Invite a user by email. Idempotent by email — re-inviting an existing user is a no-op. Triggers a Zitadel init email with a 'set your password' link.\",\n inputShape: {\n workspace: z.string().min(1),\n email: z\n .string()\n .regex(/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/, \"must be a valid email\"),\n first_name: z.string().min(1),\n last_name: z.string().min(1),\n preferred_language: z\n .string()\n .length(2)\n .default(\"en\")\n .describe(\"ISO 639-1, e.g. en/es/pt\"),\n },\n handler: async ({ workspace, ...body }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/users/invite`,\n { method: \"POST\", body },\n ),\n});\n\nexport const deleteUser = defineTool({\n name: \"delete_user\",\n description: \"Delete a user by id. Idempotent.\",\n inputShape: {\n workspace: z.string().min(1),\n user_id: z.string().min(1),\n },\n handler: async ({ workspace, user_id }, { client }) =>\n client.request(\n `/v1/workspaces/${encodeURIComponent(workspace)}/users/${encodeURIComponent(user_id)}`,\n { method: \"DELETE\" },\n ),\n});\n\nexport const tools = [listUsers, inviteUser, deleteUser] as const;\n","/**\n * Hand-written workspace tools. These are the ones agents reach for first;\n * the rest of the surface is auto-generated from OpenAPI in a later pass.\n */\nimport { z } from \"zod\";\n\nimport { defineTool } from \"./registry.js\";\n\nexport const listWorkspaces = defineTool({\n name: \"list_workspaces\",\n description:\n \"List Prysmid workspaces accessible to the current API token. Returns an array of {id, slug, display_name, plan, state}.\",\n inputShape: {},\n handler: async (_input, { client }) =>\n client.request(\"/v1/workspaces\", { method: \"GET\" }),\n});\n\nexport const getWorkspace = defineTool({\n name: \"get_workspace\",\n description: \"Get a single workspace by slug or id.\",\n inputShape: {\n workspace: z\n .string()\n .min(1)\n .describe(\"Workspace slug or UUID\"),\n },\n handler: async ({ workspace }, { client }) =>\n client.request(`/v1/workspaces/${encodeURIComponent(workspace)}`),\n});\n\nexport const createWorkspace = defineTool({\n name: \"create_workspace\",\n description:\n \"Create a new Prysmid workspace. Provisioning runs in the background; the response returns immediately with state=provisioning. Poll `get_workspace` until state=active (~30s).\",\n inputShape: {\n slug: z\n .string()\n .min(2)\n .max(63)\n .regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric and hyphens only\")\n .describe(\"Subdomain-safe slug — becomes auth.<slug>.prysmid.com\"),\n display_name: z.string().min(1).max(255),\n },\n handler: async (input, { client }) =>\n client.request(\"/v1/workspaces\", { method: \"POST\", body: input }),\n});\n\nexport const tools = [listWorkspaces, getWorkspace, createWorkspace] as const;\n"],"mappings":";;;AAQA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACA9B,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YACE,SACgB,QACA,MACA,MAChB;AACA,UAAM,OAAO;AAJG;AACA;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AAAA,EANkB;AAAA,EACA;AAAA,EACA;AAKpB;AAQO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YACmB,KACA,KACjB;AAFiB;AACA;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA,EAGnB,MAAM,QAAqB,MAAc,OAAuB,CAAC,GAAe;AAC9E,QAAI,CAAC,KAAK,IAAI,UAAU;AACtB,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;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MAAM,MAAM,cAAc,GAAG,MAAM;AAAA,IAC1D;AACA,WAAO,OAAO,IAAI,YAAY,WAAW,IAAI,UAAU;AAAA,EACzD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,OAAsB;AAC1C,QAAM,MAAM,WAAW;AACvB,QAAM,MAAM,WAAW,GAAG;AAC1B,QAAM,SAAS,IAAI,cAAc,KAAK,GAAG;AAEzC,QAAM,SAAS,IAAI,UAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS,YAAY;AAAA,EACvB,CAAC;AAED,QAAM,WAAW;AAAA,IACf,GAAGC;AAAA,IACH,GAAG;AAAA,IACH,GAAGA;AAAA,IACH,GAAGA;AAAA,IACH,GAAGA;AAAA,IACH,GAAGA;AAAA,IACH,GAAGA;AAAA,IACH,GAAGA;AAAA,EACL;AAEA,cAAY,QAAQ,EAAE,QAAQ,IAAI,GAAG,QAAQ;AAE7C,MAAI,KAAK,wBAAwB;AAAA,IAC/B,SAAS,IAAI;AAAA,IACb,OAAO,SAAS;AAAA,IAChB,UAAU,IAAI,WAAW,WAAW;AAAA,EACtC,CAAC;AAED,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAMA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,UAAU,eAAe,QAAQ,IAAI,QAAQ,GAAG;AAAA,CAAI;AACzE,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["tools","z","z","tools","z","z","tools","z","z","tools","z","z","tools","z","z","tools","z","z","tools","z","z","tools","tools"]}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@prysmid/mcp",
3
+ "version": "0.1.1",
4
+ "description": "Official Prysmid MCP server — manage workspaces, apps OIDC, login policy, IdPs, branding, users from any MCP-compatible agent (Claude Code, Cursor, etc.)",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://prysmid.com",
7
+ "bugs": "https://github.com/PrysmID/mcp-server/issues",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/PrysmID/mcp-server.git"
11
+ },
12
+ "type": "module",
13
+ "main": "dist/index.js",
14
+ "bin": {
15
+ "prysmid-mcp": "dist/index.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "engines": {
23
+ "node": ">=20.0.0"
24
+ },
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsx src/index.ts",
28
+ "test": "vitest run",
29
+ "test:watch": "vitest",
30
+ "typecheck": "tsc --noEmit",
31
+ "gen-tools": "tsx scripts/generate-tools.ts",
32
+ "prepare": "tsup"
33
+ },
34
+ "dependencies": {
35
+ "@modelcontextprotocol/sdk": "^1.0.4",
36
+ "zod": "^3.23.8"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.9.0",
40
+ "tsup": "^8.3.5",
41
+ "tsx": "^4.19.2",
42
+ "typescript": "^5.6.3",
43
+ "vitest": "^2.1.5"
44
+ },
45
+ "keywords": [
46
+ "mcp",
47
+ "model-context-protocol",
48
+ "prysmid",
49
+ "auth",
50
+ "oidc",
51
+ "zitadel",
52
+ "agents"
53
+ ]
54
+ }