@burdenoff/mcp-libs 2026.1013.2 → 2026.1013.3

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.
@@ -52,37 +52,36 @@ Hint: ${hint}` : message;
52
52
 
53
53
  // src/modules/devportal/operations.ts
54
54
  var LIST_ORGANIZATIONS = `
55
- query ListOrganizations($limit: Int, $offset: Int) {
56
- myOrganizations(limit: $limit, offset: $offset) {
57
- items { id name slug status }
58
- total
55
+ query ListDevportalOrganizations {
56
+ myDeveloperOrganizations {
57
+ id name slug description createdAt
59
58
  }
60
59
  }
61
60
  `;
62
61
  var GET_ORGANIZATION = `
63
- query GetOrganization($id: ID!) {
64
- organization(id: $id) {
65
- id name description status
62
+ query GetDevportalOrganization($id: ID!) {
63
+ developerOrganization(id: $id) {
64
+ id name slug description createdAt
66
65
  }
67
66
  }
68
67
  `;
69
68
  var CREATE_ORGANIZATION = `
70
- mutation CreateOrganization($input: CreateOrganizationInput!) {
71
- createOrganization(input: $input) {
72
- id name slug status
69
+ mutation CreateDevportalOrganization($input: CreateDeveloperOrganizationInput!) {
70
+ createDeveloperOrganization(input: $input) {
71
+ id name slug description createdAt
73
72
  }
74
73
  }
75
74
  `;
76
75
  var UPDATE_ORGANIZATION = `
77
- mutation UpdateOrganization($id: ID!, $input: UpdateOrganizationInput!) {
78
- updateOrganization(id: $id, input: $input) {
79
- id name updatedAt
76
+ mutation UpdateDevportalOrganization($id: ID!, $input: UpdateDeveloperOrganizationInput!) {
77
+ updateDeveloperOrganization(id: $id, input: $input) {
78
+ id name slug description createdAt
80
79
  }
81
80
  }
82
81
  `;
83
82
  var DELETE_ORGANIZATION = `
84
- mutation DeleteOrganization($id: ID!) {
85
- deleteOrganization(id: $id)
83
+ mutation DeleteDevportalOrganization($id: ID!) {
84
+ deleteDeveloperOrganization(id: $id)
86
85
  }
87
86
  `;
88
87
  var LIST_APPLICATIONS = `
@@ -252,18 +251,15 @@ function registerDevportalTools(server, ctx, track) {
252
251
  track(mcpToolName(ctx.productName, "devportal_orgs_list")),
253
252
  {
254
253
  title: "List Devportal Organizations",
255
- description: "List publisher organizations the caller owns (uses `myOrganizations` on the live supergraph).",
256
- inputSchema: {
257
- limit: zod.z.number().optional().describe("Page size (default 50)"),
258
- offset: zod.z.number().optional().describe("Skip results")
259
- }
254
+ description: "List developer organizations the caller is a member of (uses `myDeveloperOrganizations` on the global-devportal subgraph). Returns a flat array \u2014 pagination is client-side.",
255
+ inputSchema: {}
260
256
  },
261
- async ({ limit, offset }) => {
257
+ async () => {
262
258
  try {
263
- const data = await ctx.gql.global.request(LIST_ORGANIZATIONS, { limit: limit ?? 50, offset: offset ?? 0 });
259
+ const data = await ctx.gql.global.request(LIST_ORGANIZATIONS, {});
264
260
  return jsonResult({
265
- items: data.myOrganizations.items,
266
- totalCount: data.myOrganizations.total
261
+ items: data.myDeveloperOrganizations,
262
+ totalCount: data.myDeveloperOrganizations.length
267
263
  });
268
264
  } catch (error) {
269
265
  ctx.logger.error("devportal_orgs_list failed", { error: String(error) });
@@ -277,17 +273,14 @@ function registerDevportalTools(server, ctx, track) {
277
273
  track(mcpToolName(ctx.productName, "devportal_orgs_get")),
278
274
  {
279
275
  title: "Get Devportal Organization",
280
- description: "Get a publisher organization by ID.",
276
+ description: "Get a developer organization by ID.",
281
277
  inputSchema: { id: zod.z.string().describe("Organization ID") }
282
278
  },
283
279
  async ({ id }) => {
284
280
  try {
285
- const data = await ctx.gql.global.request(
286
- GET_ORGANIZATION,
287
- { id }
288
- );
289
- if (!data.organization) return errorResult(`Organization ${id} not found`);
290
- return jsonResult(data.organization);
281
+ const data = await ctx.gql.global.request(GET_ORGANIZATION, { id });
282
+ if (!data.developerOrganization) return errorResult(`Organization ${id} not found`);
283
+ return jsonResult(data.developerOrganization);
291
284
  } catch (error) {
292
285
  ctx.logger.error("devportal_orgs_get failed", { error: String(error) });
293
286
  return errorResult(
@@ -299,8 +292,8 @@ function registerDevportalTools(server, ctx, track) {
299
292
  server.registerTool(
300
293
  track(mcpToolName(ctx.productName, "devportal_orgs_create")),
301
294
  {
302
- title: "Create Publisher Organization",
303
- description: "Create a publisher organization. The live supergraph requires `slug` \u2014 auto-derive from the name (kebab-case) if not supplied.",
295
+ title: "Create Developer Organization",
296
+ description: "Create a developer organization. `slug` is auto-derived from `name` (kebab-case) when not supplied.",
304
297
  inputSchema: {
305
298
  name: zod.z.string().describe("Organization name"),
306
299
  slug: zod.z.string().optional().describe("URL slug \u2014 auto-derived from `name` (kebab-case) when omitted"),
@@ -315,7 +308,7 @@ function registerDevportalTools(server, ctx, track) {
315
308
  CREATE_ORGANIZATION,
316
309
  { input }
317
310
  );
318
- return jsonResult(data.createOrganization);
311
+ return jsonResult(data.createDeveloperOrganization);
319
312
  } catch (error) {
320
313
  ctx.logger.error("devportal_orgs_create failed", { error: String(error) });
321
314
  return errorResult(
@@ -327,8 +320,8 @@ function registerDevportalTools(server, ctx, track) {
327
320
  server.registerTool(
328
321
  track(mcpToolName(ctx.productName, "devportal_orgs_update")),
329
322
  {
330
- title: "Update Publisher Organization",
331
- description: "Update a publisher organization.",
323
+ title: "Update Developer Organization",
324
+ description: "Update a developer organization. `slug` is immutable after creation \u2014 only `name`, `description`, and contact / metadata fields can be updated.",
332
325
  inputSchema: {
333
326
  id: zod.z.string().describe("Organization ID"),
334
327
  name: zod.z.string().optional(),
@@ -345,7 +338,7 @@ function registerDevportalTools(server, ctx, track) {
345
338
  UPDATE_ORGANIZATION,
346
339
  { id, input }
347
340
  );
348
- return jsonResult(data.updateOrganization);
341
+ return jsonResult(data.updateDeveloperOrganization);
349
342
  } catch (error) {
350
343
  ctx.logger.error("devportal_orgs_update failed", { error: String(error) });
351
344
  return errorResult(
@@ -357,8 +350,8 @@ function registerDevportalTools(server, ctx, track) {
357
350
  server.registerTool(
358
351
  track(mcpToolName(ctx.productName, "devportal_orgs_delete")),
359
352
  {
360
- title: "Delete Publisher Organization",
361
- description: "Delete a publisher organization.",
353
+ title: "Delete Developer Organization",
354
+ description: "Delete a developer organization.",
362
355
  inputSchema: { id: zod.z.string().describe("Organization ID") }
363
356
  },
364
357
  async ({ id }) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/devportal/operations.ts","../../../src/modules/devportal/tools.ts","../../../src/modules/devportal/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;AC1BA,IAAM,oBAAA,GAAuB,EAAA;AAE7B,SAAS,cAAA,CAAe,MAAc,IAAA,EAA8C;AAClF,EAAA,IAAuB,IAAA,CAAK,MAAA,GAAS,oBAAA,EAAsB;AACzD,IAAA,MAAM,IAAI,gBAAA;AAAA,MACR,CAAA,WAAA,EAAc,IAAI,CAAA,UAAA,EAAa,oBAAoB,CAAA,8CAAA;AAAA,KACrD;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAMO,SAAS,WAAA,CAAY,gBAAwB,KAAA,EAAyB;AAC3E,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,MAAM,IAAI,iBAAiB,sCAAsC,CAAA;AAAA,EACnE;AACA,EAAA,MAAM,IAAA,GAAO,CAAC,WAAA,EAAa,GAAG,KAAK,EAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAC7D,EAAA,OAAO,cAAA,CAAe,IAAY,CAAA;AACpC;;;ACOO,SAAS,UAAA,CAAW,MAAe,UAAA,EAAkD;AAC1F,EAAA,MAAM,MAAA,GAAqB;AAAA,IACzB,OAAA,EAAS,CAAC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.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n\n/**\n * Name-based hint heuristics for MCP `annotations` (readOnlyHint /\n * destructiveHint). Used by tool-governance.ts to auto-fill annotations for\n * the fleet of product modules that call `server.registerTool` directly\n * (bypassing the `registerTool()` core helper) and so never set them\n * explicitly today (BOFF-3903). Deliberately conservative — matched against\n * whole `_`-delimited segments so e.g. `timeentries_delete` and\n * `pomodoro_delete_goal` match, but a hypothetical `undeletable_check`\n * would not.\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()`.\n */\nconst DESTRUCTIVE_NAME_SEGMENT = /(?:^|_)delete(?:_|$)/i;\nconst READ_ONLY_NAME_SEGMENT = /(?:^|_)(?:list|get|search|check|read|count|stats|by_date)(?:_|$)/i;\n\n/** True when a tool name looks destructive (irreversibly deletes data) by naming convention. */\nexport function inferDestructiveHint(toolName: string): boolean {\n return DESTRUCTIVE_NAME_SEGMENT.test(toolName);\n}\n\n/**\n * True when a tool name looks read-only by naming convention. Never true for\n * a name that also looks destructive (a tool can't be both).\n */\nexport function inferReadOnlyHint(toolName: string): boolean {\n return !inferDestructiveHint(toolName) && READ_ONLY_NAME_SEGMENT.test(toolName);\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\nimport type { ToolAnnotations } from './tool-governance.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n /**\n * Explicit MCP annotations (readOnlyHint / destructiveHint / ...). Optional\n * — when omitted, `wrapServerWithToolGovernance` (applied centrally in\n * `createMcpServer`) infers them from the tool name. Set this to override\n * the inference for a tool whose name doesn't match the naming convention.\n */\n annotations?: ToolAnnotations;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n ...(metadata.annotations ? { annotations: metadata.annotations } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n { _meta?: { progressToken?: string | number } } | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Devportal GraphQL operations — aligned with the LIVE alpha supergraph.\n *\n * Background (BOFF-8190, BOFF-8191):\n * The previous draft of this file referenced the devportal-svc v0 contract\n * (`organizations`, `adminReviews`, `applicationVersions`, `apiKeys`,\n * `oauthClients`, `delegations`, `organizationRevenue`, `revokeApiKey`,\n * `deleteOAuthClient`, plus a handful of typed inputs that the live\n * supergraph doesn't expose). The deployed backend has since been\n * refactored: most entities moved onto the workspace-app context\n * (`app(id)`, `applications(organizationId, status)`, `appReviews`,\n * `appApiKeys`, `revokeAPIKey(keyId)`, `currentUserDelegations`,\n * `grantDelegation(input: GrantDelegationInput)`, `generateAPIKey(input:\n * GenerateAPIKeyInput)`, `webhooks(applicationId)`, etc.) and several\n * GraphQL-level drift issues (scalar selection on Boolean!, missing\n * `id` field on WebhookCreated, etc.) accumulated.\n *\n * This file is the rewritten set of operations that match the LIVE\n * schema. The matching tools live in ./tools.ts.\n *\n * For tools whose underlying feature is no longer exposed at all\n * (`revenue`, OAuth client management, application-version listing),\n * the tool returns a clear \"feature has moved to the auth module\"\n * error rather than a stubbed mutation — see tools.ts:stubbedTool.\n */\n\n// ── Organizations ─────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.organizations` no longer exists in the live supergraph.\n// Use `myOrganizations(limit, offset)`; it returns `OrganizationList` with\n// `items { id name slug status }` + `total` (no `edges`/`pageInfo` connection).\nexport const LIST_ORGANIZATIONS = `\n query ListOrganizations($limit: Int, $offset: Int) {\n myOrganizations(limit: $limit, offset: $offset) {\n items { id name slug status }\n total\n }\n }\n`;\n\nexport const GET_ORGANIZATION = `\n query GetOrganization($id: ID!) {\n organization(id: $id) {\n id name description status\n }\n }\n`;\n\n// BOFF-8191: `CreateOrganizationInput` on the live schema does NOT include\n// `tier` (and has no current equivalent). The tool drops `tier` from the\n// input shape and forwards only `{ name, slug, description? }`.\nexport const CREATE_ORGANIZATION = `\n mutation CreateOrganization($input: CreateOrganizationInput!) {\n createOrganization(input: $input) {\n id name slug status\n }\n }\n`;\n\nexport const UPDATE_ORGANIZATION = `\n mutation UpdateOrganization($id: ID!, $input: UpdateOrganizationInput!) {\n updateOrganization(id: $id, input: $input) {\n id name updatedAt\n }\n }\n`;\n\nexport const DELETE_ORGANIZATION = `\n mutation DeleteOrganization($id: ID!) {\n deleteOrganization(id: $id)\n }\n`;\n\n// ── Applications ─────────────────────────────────────────────────────────\n\n// BOFF-8191: `$status: String` no longer matches the live `AppStatus` enum;\n// callers must pass the enum token (DRAFT|REVIEW|PUBLISHED|ARCHIVED), which\n// the schema coerces up-front.\nexport const LIST_APPLICATIONS = `\n query ListApplications($organizationId: ID, $status: AppStatus, $limit: Int) {\n applications(organizationId: $organizationId, status: $status, limit: $limit) {\n edges { node { id name status installCount averageRating } }\n totalCount\n }\n }\n`;\n\nexport const GET_APPLICATION = `\n query GetApplication($id: ID!) {\n application(id: $id) {\n id name status reviewStatus publishedAt installCount\n }\n }\n`;\n\n// BOFF-8191: `CreateApplicationInput` does NOT include `organizationId`.\n// The mutation is implicitly scoped to the caller's default organization.\n// `organizationId` was previously forwarded in the input but the schema\n// rejects it (\"organizationId is not defined by type CreateApplicationInput\").\n// Tool now forwards only `{ name, appType, description? }`.\nexport const CREATE_APPLICATION = `\n mutation CreateApplication($input: CreateApplicationInput!) {\n createApplication(input: $input) {\n id name status appId\n }\n }\n`;\n\nexport const UPDATE_APPLICATION = `\n mutation UpdateApplication($id: ID!, $input: UpdateApplicationInput!) {\n updateApplication(id: $id, input: $input) {\n id description updatedAt\n }\n }\n`;\n\nexport const SUBMIT_APPLICATION_FOR_REVIEW = `\n mutation SubmitApplicationForReview($id: ID!, $notes: String) {\n submitApplicationForReview(id: $id, notes: $notes) {\n id status reviewStatus submittedAt\n }\n }\n`;\n\nexport const PUBLISH_APPLICATION = `\n mutation PublishApplication($id: ID!) {\n publishApplication(id: $id) {\n id status publishedAt\n }\n }\n`;\n\n// BOFF-8191: `deleteApplication` returns `Boolean!` — selecting `{ success }`\n// was the GraphQL validation error before. No selection set on Boolean.\nexport const DELETE_APPLICATION = `\n mutation DeleteApplication($id: ID!) {\n deleteApplication(id: $id)\n }\n`;\n\n// ── Versions ─────────────────────────────────────────────────────────────\n\n// `Query.applicationVersions(applicationId)` was REMOVED from the live\n// schema. Versions are now embedded in the application context (see\n// `app(id)` — note: in this workspace the schema advertises no `versions`\n// field either). The tool is registered as a stub returning a clear\n// \"feature moved\" error rather than firing a doomed query.\n//\n// `CREATE_APPLICATION_VERSION` is still live and matches the devportal\n// service mutation.\nexport const CREATE_APPLICATION_VERSION = `\n mutation CreateApplicationVersion($applicationId: ID!, $input: CreateApplicationVersionInput!) {\n createApplicationVersion(applicationId: $applicationId, input: $input) {\n id version status publishedAt\n }\n }\n`;\n\n// ── Webhooks ─────────────────────────────────────────────────────────────\n\n// Live schema: `webhooks(applicationId)` returns a flat `Webhook` array\n// (not a connection) on the GLOBAL gateway. The `applicationId` argument\n// is required.\nexport const LIST_WEBHOOKS = `\n query ListDevportalWebhooks($applicationId: ID!) {\n webhooks(applicationId: $applicationId) {\n id name url events isActive status failureCount\n }\n }\n`;\n\n// BOFF-8190 + 8191: `createWebhook` on the live schema takes the\n// `applicationId` as a TOP-LEVEL argument and the body as `input: ...`.\n// Result is `{ webhook { id ... } }` — `WebhookCreated` itself has no\n// `id`, so the old direct `{ id name url status }` selection failed.\nexport const CREATE_WEBHOOK = `\n mutation CreateDevportalWebhook($applicationId: ID!, $input: CreateWebhookInput!) {\n createWebhook(applicationId: $applicationId, input: $input) {\n webhook { id name url events isActive status failureCount }\n }\n }\n`;\n\n// BOFF-8191: `deleteWebhook` returns `Boolean!` — drop the `{ success }`\n// selection set.\nexport const DELETE_WEBHOOK = `\n mutation DeleteDevportalWebhook($id: ID!) {\n deleteWebhook(id: $id)\n }\n`;\n\n// ── Analytics ────────────────────────────────────────────────────────────\n\nexport const APPLICATION_ANALYTICS = `\n query ApplicationAnalytics($applicationId: ID!, $period: String!, $startDate: DateTime, $endDate: DateTime) {\n applicationAnalytics(applicationId: $applicationId, period: $period, startDate: $startDate, endDate: $endDate) {\n date period activeUsers apiCalls avgResponseTime sessions\n }\n }\n`;\n\n// ── Revenue ──────────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.organizationRevenue` is no longer on the live schema,\n// nor is `revenue` under `organization` or `app`. Tool is registered as\n// a stub with a clear \"use the global billing tools instead\" message.\n\n// ── Admin reviews ────────────────────────────────────────────────────────\n\n// BOFF-8190 + 8191: `Query.adminReviews(status: AppReviewStatus)` was\n// removed. The replacement is `appReviews(applicationId: ID!, status:\n// AppReviewStatus, limit: Int, offset: Int)` — a relay-connection that\n// lives at GLOBAL `Query`. The `AppReview` node on alpha exposes only\n// `id` + `applicationId` (no `reviewStatus`/`reviewNotes`), so the\n// connection fields come from the wrapper. Pagination is via `limit` +\n// `offset` (NOT `first`/`after`).\nexport const ADMIN_REVIEWS = `\n query AdminReviews($applicationId: ID!, $status: AppReviewStatus, $limit: Int, $offset: Int) {\n appReviews(applicationId: $applicationId, status: $status, limit: $limit, offset: $offset) {\n edges { cursor node { id applicationId } }\n pageInfo { hasNextPage }\n totalCount\n }\n }\n`;\n\nexport const APPROVE_APPLICATION = `\n mutation ApproveApplication($id: ID!, $notes: String) {\n approveApplication(id: $id, notes: $notes) {\n id status reviewStatus publishedAt\n }\n }\n`;\n\nexport const REJECT_APPLICATION = `\n mutation RejectApplication($id: ID!, $notes: String!) {\n rejectApplication(id: $id, notes: $notes) {\n id status reviewStatus reviewNotes\n }\n }\n`;\n\n// ── API Keys ─────────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.apiKeys(applicationId)` was replaced by\n// `appApiKeys(appId: ID!): APIKeyConnection`. The `APIKeyConnection`\n// shape is `{ apiKeys { id appId ... } }` (not a relay connection —\n// no `edges`/`pageInfo`; the inner field is `apiKeys`). The `APIKey`\n// type on alpha exposes only `id`, `appId`, `name`, `prefix`, `scopes`,\n// `expiresAt`, `lastUsedAt`, `createdAt` — `isActive` was removed.\nexport const LIST_API_KEYS = `\n query ApiKeys($appId: ID!) {\n appApiKeys(appId: $appId) {\n apiKeys { id appId name prefix scopes expiresAt lastUsedAt createdAt }\n }\n }\n`;\n\n// BOFF-8190 + 8191: `createApiKey(input: CreateApiKeyInput!)` was replaced\n// by `generateAPIKey(input: GenerateAPIKeyInput!)`. The new input drops\n// `applicationId` and renames it to `appId`, plus `scopes` is renamed\n// `scope` and is now NON-OPTIONAL.\nexport const CREATE_API_KEY = `\n mutation CreateApiKey($input: GenerateAPIKeyInput!) {\n generateAPIKey(input: $input) {\n keyId apiKey apiSecret\n }\n }\n`;\n\n// BOFF-8190: `revokeApiKey(id)` was renamed to `revokeAPIKey(keyId: String!)`,\n// lives on the GLOBAL `Mutation`, and returns `Boolean!` (`true` on success).\nexport const REVOKE_API_KEY = `\n mutation RevokeApiKey($keyId: String!) {\n revokeAPIKey(keyId: $keyId)\n }\n`;\n\n// ── OAuth Clients ────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.oauthClients(applicationId)`, `Mutation.createOAuthClient`,\n// and `Mutation.deleteOAuthClient` are no longer on the live supergraph.\n// There is no nested `oauthClients` field on `app`/`application` either.\n// The corresponding tools are registered as stubs pointing the user to\n// the auth module's OAuth API (`auth_*` MCP tools) which is the surviving\n// implementation surface on alpha.\n\n// ── Delegations ──────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.delegations(applicationId, workspaceId)` was replaced\n// by `currentUserDelegations(pagination: PaginationInput)` (caller-scoped)\n// — the auth module already exposes this. The devportal tool now proxies\n// through the auth field for parity.\n//\n// `currentUserDelegations` returns `AppUserDelegationConnection` whose\n// only nested list field is `delegations` (NOT a relay connection).\nexport const LIST_DELEGATIONS = `\n query Delegations($first: Int) {\n currentUserDelegations(pagination: { limit: $first }) {\n delegations {\n id appId userId grantedBy grantedAt expiresAt scopes status workspaceIds\n app { id name }\n }\n }\n }\n`;\n\n// BOFF-8190 + 8191: `createDelegation(input: CreateDelegationInput!)` was\n// renamed to `grantDelegation(input: GrantDelegationInput!)`. The new\n// input drops `applicationId`/`workspaceId`/`scopes` in favor of\n// `appId`/`userId`/`scopes`-as-required-String-array and removes `expiresAt`\n// from the canonical GrantDelegationInput shape (optional elsewhere).\nexport const CREATE_DELEGATION = `\n mutation CreateDelegation($input: GrantDelegationInput!) {\n grantDelegation(input: $input) {\n id appId userId grantedBy grantedAt expiresAt scopes workspaceIds status\n }\n }\n`;\n\n// BOFF-8191: `revokeDelegation(id: ID!)` returns `Boolean!` on the live\n// schema — drop the legacy `{ success }` selection set. (Field still\n// exists despite BOFF-8190's title — the cluster message is just the\n// schema-validation failure on the selection set.)\nexport const REVOKE_DELEGATION = `\n mutation RevokeDelegation($id: ID!) {\n revokeDelegation(id: $id)\n }\n`;\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface OrgRow {\n id: string;\n name: string;\n slug?: string;\n status?: string;\n}\n\ninterface OrgRowWithDescription extends OrgRow {\n description?: string;\n}\n\ninterface AppRow {\n id: string;\n name: string;\n status?: string;\n reviewStatus?: string;\n publishedAt?: string;\n installCount?: number;\n averageRating?: number;\n}\n\ninterface AppRowWithAppId extends AppRow {\n appId?: string;\n}\n\ninterface VersionRow {\n id: string;\n version: string;\n status?: string;\n isLatest?: boolean;\n isStable?: boolean;\n releaseNotes?: string;\n}\n\ninterface WebhookRow {\n id: string;\n name: string;\n url: string;\n events?: string[];\n isActive?: boolean;\n status?: string;\n failureCount?: number;\n}\n\ninterface ApiKeyRow {\n id: string;\n appId?: string;\n name: string;\n prefix?: string;\n scopes?: string[];\n lastUsedAt?: string;\n isActive?: boolean;\n createdAt?: string;\n}\n\ninterface DelegationRow {\n id: string;\n appId?: string;\n userId?: string;\n grantedBy?: string;\n grantedAt?: string;\n expiresAt?: string;\n scopes?: string[];\n workspaceIds?: string[];\n status: string;\n}\n\nconst AppStatusEnum = z\n .enum(['DRAFT', 'REVIEW', 'PUBLISHED', 'ARCHIVED'])\n .describe('Application status');\n\nconst AppReviewStatusEnum = z\n .enum(['PENDING', 'APPROVED', 'REJECTED'])\n .describe('Application review status');\n\n/**\n * Register a tool that is intentionally a no-op on the current alpha\n * supergraph because the underlying GraphQL surface has been moved,\n * refactored, or removed. We keep the tool registered (so agentic callers\n * that may probe the name get a meaningful answer rather than a silent\n * schema-validation error) and return a clear pointer to the survivor\n * implementation. Background: BOFF-8190 / BOFF-8191.\n */\ntype StubInputSchema = Record<string, z.ZodTypeAny>;\nfunction stubbedTool(\n server: McpServer,\n // productName is reserved for future stub messages that need to embed the\n // real tool prefix; current stubs produce a placeholder note that does\n // not reference it.\n _productName: string,\n toolName: string,\n title: string,\n description: string,\n featureNote: string,\n inputSchema: StubInputSchema,\n altSuggestions: string[],\n): void {\n server.registerTool(\n toolName,\n {\n title,\n description: `${description} [intentionally stubbed: ${featureNote} Use ${altSuggestions.join(', ')} instead.]`,\n inputSchema,\n },\n async () =>\n errorResult(\n `[stubbed] ${featureNote} Use ${altSuggestions.join(', ')} instead. The tool remains registered so callers receive a meaningful response instead of a schema-validation error.`,\n ),\n );\n}\n\nexport function registerDevportalTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Organizations ───────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_list')),\n {\n title: 'List Devportal Organizations',\n description:\n 'List publisher organizations the caller owns (uses `myOrganizations` on the live supergraph).',\n inputSchema: {\n limit: z.number().optional().describe('Page size (default 50)'),\n offset: z.number().optional().describe('Skip results'),\n },\n },\n async ({ limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{\n myOrganizations: { items: OrgRow[]; total: number };\n }>(ops.LIST_ORGANIZATIONS, { limit: limit ?? 50, offset: offset ?? 0 });\n return jsonResult({\n items: data.myOrganizations.items,\n totalCount: data.myOrganizations.total,\n });\n } catch (error) {\n ctx.logger.error('devportal_orgs_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_get')),\n {\n title: 'Get Devportal Organization',\n description: 'Get a publisher organization by ID.',\n inputSchema: { id: z.string().describe('Organization ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ organization: OrgRowWithDescription | null }>(\n ops.GET_ORGANIZATION,\n { id },\n );\n if (!data.organization) return errorResult(`Organization ${id} not found`);\n return jsonResult(data.organization);\n } catch (error) {\n ctx.logger.error('devportal_orgs_get failed', { error: String(error) });\n return errorResult(\n `Failed to get organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_create')),\n {\n title: 'Create Publisher Organization',\n description:\n 'Create a publisher organization. The live supergraph requires `slug` — auto-derive from the name (kebab-case) if not supplied.',\n inputSchema: {\n name: z.string().describe('Organization name'),\n slug: z\n .string()\n .optional()\n .describe('URL slug — auto-derived from `name` (kebab-case) when omitted'),\n description: z.string().optional(),\n },\n },\n async ({ name, slug, description }) => {\n try {\n const input: Record<string, unknown> = { name, slug: slug ?? slugify(name) };\n if (description !== undefined) input.description = description;\n const data = await ctx.gql.global.request<{ createOrganization: OrgRow }>(\n ops.CREATE_ORGANIZATION,\n { input },\n );\n return jsonResult(data.createOrganization);\n } catch (error) {\n ctx.logger.error('devportal_orgs_create failed', { error: String(error) });\n return errorResult(\n `Failed to create organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_update')),\n {\n title: 'Update Publisher Organization',\n description: 'Update a publisher organization.',\n inputSchema: {\n id: z.string().describe('Organization ID'),\n name: z.string().optional(),\n description: z.string().optional(),\n },\n },\n async ({ id, name, description }) => {\n try {\n const input: Record<string, unknown> = {};\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (!Object.keys(input).length) return errorResult('No updates specified');\n const data = await ctx.gql.global.request<{ updateOrganization: OrgRow }>(\n ops.UPDATE_ORGANIZATION,\n { id, input },\n );\n return jsonResult(data.updateOrganization);\n } catch (error) {\n ctx.logger.error('devportal_orgs_update failed', { error: String(error) });\n return errorResult(\n `Failed to update organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_delete')),\n {\n title: 'Delete Publisher Organization',\n description: 'Delete a publisher organization.',\n inputSchema: { id: z.string().describe('Organization ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.DELETE_ORGANIZATION, { id });\n return jsonResult({ status: 'success', message: 'Organization deleted', orgId: id });\n } catch (error) {\n ctx.logger.error('devportal_orgs_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Applications ────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_list')),\n {\n title: 'List Devportal Applications',\n description:\n 'List devportal applications. `status` is the live `AppStatus` enum (DRAFT|REVIEW|PUBLISHED|ARCHIVED).',\n inputSchema: {\n organizationId: z.string().optional(),\n status: AppStatusEnum.optional(),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ organizationId, status, limit }) => {\n try {\n const data = await ctx.gql.global.request<{\n applications: { edges: Array<{ node: AppRow }>; totalCount: number };\n }>(ops.LIST_APPLICATIONS, {\n organizationId,\n status,\n limit: limit ?? 50,\n });\n return jsonResult({\n items: data.applications.edges.map((e) => e.node),\n totalCount: data.applications.totalCount,\n });\n } catch (error) {\n ctx.logger.error('devportal_apps_list failed', { error: String(error) });\n return errorResult(\n `Failed to list applications: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_get')),\n {\n title: 'Get Devportal Application',\n description: 'Get a devportal application by ID.',\n inputSchema: { id: z.string().describe('Application ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ application: AppRow | null }>(\n ops.GET_APPLICATION,\n { id },\n );\n if (!data.application) return errorResult(`Application ${id} not found`);\n return jsonResult(data.application);\n } catch (error) {\n ctx.logger.error('devportal_apps_get failed', { error: String(error) });\n return errorResult(\n `Failed to get application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_create')),\n {\n title: 'Create Devportal Application',\n description:\n 'Create a devportal application under the caller\\'s default organization. The live `CreateApplicationInput` does NOT accept `organizationId` (was previously forwarded; rejected by the schema with \"Field organizationId is not defined by type CreateApplicationInput\").',\n inputSchema: {\n name: z.string().describe('Application name'),\n appType: AppStatusEnum.describe(\n 'API_INTEGRATION|WEB_APP|MOBILE_APP (default API_INTEGRATION)',\n ).optional(),\n description: z.string().optional(),\n },\n },\n async ({ name, appType, description }) => {\n try {\n const input: Record<string, unknown> = {\n name,\n appType: (appType ?? 'API_INTEGRATION').toUpperCase(),\n };\n if (description !== undefined) input.description = description;\n const data = await ctx.gql.global.request<{\n createApplication: AppRowWithAppId;\n }>(ops.CREATE_APPLICATION, { input });\n return jsonResult(data.createApplication);\n } catch (error) {\n ctx.logger.error('devportal_apps_create failed', { error: String(error) });\n return errorResult(\n `Failed to create application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_update')),\n {\n title: 'Update Devportal Application',\n description: 'Update a devportal application.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n description: z.string().optional(),\n pricingType: z.string().optional().describe('FREE|PAID_ONETIME|SUBSCRIPTION'),\n documentationUrl: z.string().optional(),\n },\n },\n async ({ id, description, pricingType, documentationUrl }) => {\n try {\n const input: Record<string, unknown> = {};\n if (description !== undefined) input.description = description;\n if (pricingType !== undefined) input.pricingType = pricingType.toUpperCase();\n if (documentationUrl !== undefined) input.documentationUrl = documentationUrl;\n if (!Object.keys(input).length) return errorResult('No updates specified');\n const data = await ctx.gql.global.request<{ updateApplication: AppRow }>(\n ops.UPDATE_APPLICATION,\n { id, input },\n );\n return jsonResult(data.updateApplication);\n } catch (error) {\n ctx.logger.error('devportal_apps_update failed', { error: String(error) });\n return errorResult(\n `Failed to update application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_submit_review')),\n {\n title: 'Submit Application For Review',\n description: 'Submit an application for admin review.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n notes: z.string().optional().describe('Optional submission notes'),\n },\n },\n async ({ id, notes }) => {\n try {\n const data = await ctx.gql.global.request<{ submitApplicationForReview: AppRow }>(\n ops.SUBMIT_APPLICATION_FOR_REVIEW,\n { id, notes },\n );\n return jsonResult(data.submitApplicationForReview);\n } catch (error) {\n ctx.logger.error('devportal_apps_submit_review failed', { error: String(error) });\n return errorResult(\n `Failed to submit for review: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_publish')),\n {\n title: 'Publish Application',\n description:\n 'Publish an approved application. Note: in the legacy CLI this opened a browser; here it just calls the publish mutation directly.',\n inputSchema: { id: z.string().describe('Application ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ publishApplication: AppRow }>(\n ops.PUBLISH_APPLICATION,\n { id },\n );\n return jsonResult(data.publishApplication);\n } catch (error) {\n ctx.logger.error('devportal_apps_publish failed', { error: String(error) });\n return errorResult(\n `Failed to publish application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_delete')),\n {\n title: 'Delete Devportal Application',\n description:\n 'Delete a devportal application. Live mutation returns Boolean! (no selection set).',\n inputSchema: { id: z.string().describe('Application ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.DELETE_APPLICATION, { id });\n return jsonResult({ status: 'success', message: 'Application deleted', appId: id });\n } catch (error) {\n ctx.logger.error('devportal_apps_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Versions ────────────────────────────────────────────────────────────\n\n // BOFF-8190: `applicationVersions(applicationId)` is gone. Versions live\n // nowhere addressable via the devportal on alpha today. Stub it so\n // callers get an actionable message.\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_apps_versions_list')),\n 'List Application Versions',\n 'List versions for an application.',\n '`Query.applicationVersions(applicationId)` was removed from the alpha devportal supergraph; there is no surviving `versions` field on `app(applicationId)`.',\n {\n applicationId: z.string().describe('Application ID'),\n },\n [`\\`_devportal_apps_versions_create\\``, `\\`_devportal_apps_analytics\\``],\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_versions_create')),\n {\n title: 'Create Application Version',\n description: 'Create a new version for an application.',\n inputSchema: {\n applicationId: z.string().describe('Application ID'),\n version: z.string().describe('Version string (e.g. \"1.2.0\")'),\n releaseNotes: z.string().optional(),\n packageUrl: z.string().optional(),\n },\n },\n async ({ applicationId, version, releaseNotes, packageUrl }) => {\n try {\n const input: Record<string, unknown> = { version };\n if (releaseNotes !== undefined) input.releaseNotes = releaseNotes;\n if (packageUrl !== undefined) input.packageUrl = packageUrl;\n const data = await ctx.gql.global.request<{ createApplicationVersion: VersionRow }>(\n ops.CREATE_APPLICATION_VERSION,\n { applicationId, input },\n );\n return jsonResult(data.createApplicationVersion);\n } catch (error) {\n ctx.logger.error('devportal_apps_versions_create failed', { error: String(error) });\n return errorResult(\n `Failed to create version: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Webhooks ────────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_webhooks_list')),\n {\n title: 'List Application Webhooks',\n description:\n 'List webhooks attached to an application (live global `Query.webhooks(applicationId)`).',\n inputSchema: { applicationId: z.string().describe('Application ID') },\n },\n async ({ applicationId }) => {\n try {\n const data = await ctx.gql.global.request<{ webhooks: WebhookRow[] }>(ops.LIST_WEBHOOKS, {\n applicationId,\n });\n return jsonResult(data.webhooks);\n } catch (error) {\n ctx.logger.error('devportal_apps_webhooks_list failed', { error: String(error) });\n return errorResult(\n `Failed to list webhooks: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_webhooks_add')),\n {\n title: 'Add Application Webhook',\n description:\n 'Add a webhook to an application. The live mutation takes `applicationId` as a top-level argument plus `input: CreateWebhookInput!`. The result is `WebhookCreated { webhook { ... } }` (the type itself has no `id`).',\n inputSchema: {\n applicationId: z.string().describe('Application ID'),\n name: z.string().describe('Webhook name'),\n url: z.string().describe('Delivery URL'),\n events: z.array(z.string()).describe('Event names'),\n maxRetries: z.number().optional().describe('Default 5'),\n },\n },\n async ({ applicationId, name, url, events, maxRetries }) => {\n try {\n const input: Record<string, unknown> = {\n name,\n url,\n events,\n retryEnabled: true,\n maxRetries: maxRetries ?? 5,\n };\n const data = await ctx.gql.global.request<{\n createWebhook: { webhook: WebhookRow };\n }>(ops.CREATE_WEBHOOK, { applicationId, input });\n return jsonResult(data.createWebhook.webhook);\n } catch (error) {\n ctx.logger.error('devportal_apps_webhooks_add failed', { error: String(error) });\n return errorResult(\n `Failed to create webhook: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_webhooks_remove')),\n {\n title: 'Remove Application Webhook',\n description: 'Remove a webhook by ID. Live mutation returns Boolean! (no selection set).',\n inputSchema: { id: z.string().describe('Webhook ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.DELETE_WEBHOOK, { id });\n return jsonResult({ status: 'success', message: 'Webhook removed', webhookId: id });\n } catch (error) {\n ctx.logger.error('devportal_apps_webhooks_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove webhook: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Analytics ───────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_analytics')),\n {\n title: 'Application Analytics',\n description: 'Get analytics for an application over a period.',\n inputSchema: {\n applicationId: z.string().describe('Application ID'),\n period: z\n .string()\n .optional()\n .describe('LAST_7_DAYS|LAST_30_DAYS|CUSTOM (default LAST_30_DAYS)'),\n startDate: z.string().optional().describe('ISO 8601 (required when period=CUSTOM)'),\n endDate: z.string().optional().describe('ISO 8601'),\n },\n },\n async ({ applicationId, period, startDate, endDate }) => {\n try {\n const data = await ctx.gql.global.request<{\n applicationAnalytics: Array<Record<string, unknown>>;\n }>(ops.APPLICATION_ANALYTICS, {\n applicationId,\n period: (period ?? 'LAST_30_DAYS').toUpperCase(),\n startDate,\n endDate,\n });\n return jsonResult(data.applicationAnalytics);\n } catch (error) {\n ctx.logger.error('devportal_apps_analytics failed', { error: String(error) });\n return errorResult(\n `Failed to fetch analytics: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Revenue ─────────────────────────────────────────────────────────────\n\n // BOFF-8190: `Query.organizationRevenue` is GONE; `organization` and `app`\n // types do NOT expose `revenue` either. Stub — point at billing tools.\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_revenue')),\n 'Organization Revenue',\n 'Get revenue summary for an organization.',\n '`Query.organizationRevenue` (and any `revenue` field on `organization` / `app`) was removed from the alpha supergraph.',\n {\n organizationId: z.string().describe('Organization ID'),\n period: z.string().optional().describe('LAST_7_DAYS|LAST_30_DAYS|YTD (default LAST_30_DAYS)'),\n },\n [`\\`_billing_invoices_list\\``, `\\`_billing_subscriptions_list\\``],\n );\n\n // ── Admin reviews ───────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_admin_reviews_list')),\n {\n title: 'List Admin Application Reviews',\n description:\n 'List applications in the admin review queue. Live query is `appReviews(applicationId, status, limit, offset)` (the unscoped `adminReviews` field was removed). `applicationId` is required, `status` filters the connection server-side, and pagination uses `limit` + `offset` (NOT `first`/`after`).',\n inputSchema: {\n applicationId: z.string().describe('Application ID to scope the review queue to'),\n status: AppReviewStatusEnum.optional(),\n limit: z.number().optional().describe('Page size (default 20)'),\n offset: z.number().optional().describe('Skip results'),\n },\n },\n async ({ applicationId, status, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{\n appReviews: {\n edges: Array<{ cursor: string; node: { id: string; applicationId: string } }>;\n pageInfo: { hasNextPage: boolean };\n totalCount: number;\n };\n }>(ops.ADMIN_REVIEWS, {\n applicationId,\n status,\n limit: limit ?? 20,\n offset: offset ?? 0,\n });\n return jsonResult({\n items: data.appReviews.edges.map((e) => e.node),\n totalCount: data.appReviews.totalCount,\n pageInfo: data.appReviews.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('devportal_admin_reviews_list failed', { error: String(error) });\n return errorResult(\n `Failed to list reviews: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_admin_reviews_approve')),\n {\n title: 'Approve Application',\n description: 'Approve a pending application.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n notes: z.string().optional(),\n },\n },\n async ({ id, notes }) => {\n try {\n const data = await ctx.gql.global.request<{ approveApplication: AppRow }>(\n ops.APPROVE_APPLICATION,\n { id, notes },\n );\n return jsonResult(data.approveApplication);\n } catch (error) {\n ctx.logger.error('devportal_admin_reviews_approve failed', { error: String(error) });\n return errorResult(\n `Failed to approve application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_admin_reviews_reject')),\n {\n title: 'Reject Application',\n description: 'Reject a pending application.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n notes: z.string().describe('Reason for rejection (required)'),\n },\n },\n async ({ id, notes }) => {\n try {\n const data = await ctx.gql.global.request<{ rejectApplication: AppRow }>(\n ops.REJECT_APPLICATION,\n { id, notes },\n );\n return jsonResult(data.rejectApplication);\n } catch (error) {\n ctx.logger.error('devportal_admin_reviews_reject failed', { error: String(error) });\n return errorResult(\n `Failed to reject application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── API Keys ───────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_api_keys_list')),\n {\n title: 'List API Keys',\n description: 'List API keys for an application. Live query is `appApiKeys(appId: ID!)`.',\n inputSchema: {\n applicationId: z.string().describe('Application ID (forwarded as `appId`)'),\n },\n },\n async ({ applicationId }) => {\n try {\n const data = await ctx.gql.global.request<{\n appApiKeys: { apiKeys: ApiKeyRow[] };\n }>(ops.LIST_API_KEYS, { appId: applicationId });\n return jsonResult(data.appApiKeys.apiKeys);\n } catch (error) {\n ctx.logger.error('devportal_api_keys_list failed', { error: String(error) });\n return errorResult(\n `Failed to list API keys: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_api_keys_create')),\n {\n title: 'Create API Key',\n description:\n 'Mint a new API key via `generateAPIKey(input: GenerateAPIKeyInput!)` (live auth mutation). Returns the full key including the one-time-visible `apiKey`/`apiSecret`.',\n inputSchema: {\n applicationId: z.string().describe('Application ID (forwarded as `appId`)'),\n name: z.string().min(1).describe('Human-readable name for the key'),\n scopes: z\n .array(z.string())\n .min(1)\n .describe(\n 'Scope identifiers granted to the key — REQUIRED on the live `GenerateAPIKeyInput.scope`',\n ),\n expiresAt: z.string().optional().describe('ISO 8601 expiry timestamp'),\n },\n },\n async ({ applicationId, name, scopes, expiresAt }) => {\n try {\n const input: Record<string, unknown> = {\n appId: applicationId,\n name,\n scope: scopes,\n };\n if (expiresAt !== undefined) input.expiresAt = expiresAt;\n const data = await ctx.gql.global.request<{\n generateAPIKey: { keyId: string; apiKey: string; apiSecret: string };\n }>(ops.CREATE_API_KEY, { input });\n return jsonResult({ ...data.generateAPIKey, name, scopes, applicationId });\n } catch (error) {\n ctx.logger.error('devportal_api_keys_create failed', { error: String(error) });\n return errorResult(\n `Failed to create API key: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_api_keys_revoke')),\n {\n title: 'Revoke API Key',\n description:\n 'Revoke an API key via `revokeAPIKey(keyId: String!)` (live global mutation, returns Boolean!).',\n inputSchema: { id: z.string().describe('API key ID (forwarded as `keyId`)') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.REVOKE_API_KEY, { keyId: id });\n return jsonResult({ status: 'success', message: 'API key revoked', apiKeyId: id });\n } catch (error) {\n ctx.logger.error('devportal_api_keys_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to revoke API key: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── OAuth Clients ───────────────────────────────────────────────────────\n\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_oauth_list')),\n 'List OAuth Clients',\n 'List OAuth 2.0 clients registered for a devportal application.',\n '`Query.oauthClients(applicationId)` no longer exists on the alpha supergraph, and `app(id)` does not expose a nested `oauthClients` field either.',\n {\n applicationId: z.string().describe('Application ID'),\n },\n [`\\`_auth_current_user_apps\\``],\n );\n\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_oauth_create')),\n 'Create OAuth Client',\n 'Register a new OAuth 2.0 client for an application.',\n '`Mutation.createOAuthClient` (and `CreateOAuthClientInput`) have been removed from the alpha supergraph.',\n {\n applicationId: z.string().describe('Application ID'),\n name: z.string().describe('Client name'),\n redirectUris: z.array(z.string()).optional(),\n grantTypes: z.array(z.string()).optional(),\n },\n [`\\`_auth_current_user_apps\\` (read-only on alpha)`],\n );\n\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_oauth_delete')),\n 'Delete OAuth Client',\n 'Delete an OAuth 2.0 client by ID.',\n '`Mutation.deleteOAuthClient` has been removed from the alpha supergraph (no successor field).',\n {\n id: z.string().describe('OAuth client ID'),\n },\n [`\\`_auth_*\\` surface for current OAuth flows`],\n );\n\n // ── Delegations ────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_delegations_list')),\n {\n title: 'List Delegations',\n description:\n 'List workspace delegations issued to applications. Live impl proxies through the global `Query.currentUserDelegations` (calls scoped to the caller). Note: in-scope filtering by application/workspace is not supported on the live schema — pass `first` to paginate.',\n inputSchema: {\n first: z\n .number()\n .optional()\n .describe(\n 'Page size (default 50). Filter args from the old `delegations(...)` were dropped.',\n ),\n },\n },\n async ({ first }) => {\n try {\n const data = await ctx.gql.global.request<{\n currentUserDelegations: { delegations: DelegationRow[] };\n }>(ops.LIST_DELEGATIONS, { first: first ?? 50 });\n return jsonResult(data.currentUserDelegations.delegations);\n } catch (error) {\n ctx.logger.error('devportal_delegations_list failed', { error: String(error) });\n return errorResult(\n `Failed to list delegations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_delegations_create')),\n {\n title: 'Create Delegation',\n description:\n 'Grant a workspace delegation to an application. Live impl is `grantDelegation(input: GrantDelegationInput!)` (renamed from `CreateDelegationInput`); `appId` replaces `applicationId`. The grant is implicitly to the calling actor — `GrantDelegationInput` does NOT take a `userId`.',\n inputSchema: {\n applicationId: z\n .string()\n .describe('Application ID receiving the delegation (forwarded as `appId`)'),\n scopes: z\n .array(z.string())\n .min(1)\n .describe(\n 'Scope identifiers granted to the application — REQUIRED on the live GrantDelegationInput',\n ),\n workspaceIds: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional list of workspace IDs scoping the delegation (forwarded as `workspaceIds`)',\n ),\n expiresAt: z\n .string()\n .optional()\n .describe(\n 'ISO 8601 expiry timestamp (DateTime scalar — must be a full ISO 8601 instant, not a date)',\n ),\n },\n },\n async ({ applicationId, scopes, workspaceIds, expiresAt }) => {\n try {\n const input: Record<string, unknown> = { appId: applicationId, scopes };\n if (workspaceIds !== undefined) input.workspaceIds = workspaceIds;\n if (expiresAt !== undefined) input.expiresAt = expiresAt;\n const data = await ctx.gql.global.request<{\n grantDelegation: DelegationRow;\n }>(ops.CREATE_DELEGATION, { input });\n return jsonResult(data.grantDelegation);\n } catch (error) {\n ctx.logger.error('devportal_delegations_create failed', { error: String(error) });\n return errorResult(\n `Failed to create delegation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_delegations_revoke')),\n {\n title: 'Revoke Delegation',\n description:\n 'Revoke a workspace delegation via `revokeDelegation(id: ID!)` (live schema, returns Boolean!; no selection set).',\n inputSchema: { id: z.string().describe('Delegation ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.REVOKE_DELEGATION, { id });\n return jsonResult({ status: 'success', message: 'Delegation revoked', delegationId: id });\n } catch (error) {\n ctx.logger.error('devportal_delegations_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to revoke delegation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n\nfunction slugify(s: string): string {\n return (\n s\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 64) || 'org'\n );\n}\n","/**\n * Devportal module — publisher orgs, applications, versions, webhooks, analytics, revenue, admin reviews.\n *\n * Backend: global-devportal-svc.\n * Ported from cli-sdk/src/modules/devportal/. Browser-only flows (open-in-browser\n * publish handoffs) are not exposed; the publish tool calls the publish mutation directly.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerDevportalTools } from './tools.js';\n\nconst devportalModule: McpModule = {\n id: 'devportal',\n version: '0.0.1',\n displayName: 'Developer Portal',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerDevportalTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default devportalModule;\n"]}
1
+ {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/devportal/operations.ts","../../../src/modules/devportal/tools.ts","../../../src/modules/devportal/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;AC1BA,IAAM,oBAAA,GAAuB,EAAA;AAE7B,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zB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,sBAAA,CAAuB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAEzC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,iBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n\n/**\n * Name-based hint heuristics for MCP `annotations` (readOnlyHint /\n * destructiveHint). Used by tool-governance.ts to auto-fill annotations for\n * the fleet of product modules that call `server.registerTool` directly\n * (bypassing the `registerTool()` core helper) and so never set them\n * explicitly today (BOFF-3903). Deliberately conservative — matched against\n * whole `_`-delimited segments so e.g. `timeentries_delete` and\n * `pomodoro_delete_goal` match, but a hypothetical `undeletable_check`\n * would not.\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()`.\n */\nconst DESTRUCTIVE_NAME_SEGMENT = /(?:^|_)delete(?:_|$)/i;\nconst READ_ONLY_NAME_SEGMENT = /(?:^|_)(?:list|get|search|check|read|count|stats|by_date)(?:_|$)/i;\n\n/** True when a tool name looks destructive (irreversibly deletes data) by naming convention. */\nexport function inferDestructiveHint(toolName: string): boolean {\n return DESTRUCTIVE_NAME_SEGMENT.test(toolName);\n}\n\n/**\n * True when a tool name looks read-only by naming convention. Never true for\n * a name that also looks destructive (a tool can't be both).\n */\nexport function inferReadOnlyHint(toolName: string): boolean {\n return !inferDestructiveHint(toolName) && READ_ONLY_NAME_SEGMENT.test(toolName);\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\nimport type { ToolAnnotations } from './tool-governance.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n /**\n * Explicit MCP annotations (readOnlyHint / destructiveHint / ...). Optional\n * — when omitted, `wrapServerWithToolGovernance` (applied centrally in\n * `createMcpServer`) infers them from the tool name. Set this to override\n * the inference for a tool whose name doesn't match the naming convention.\n */\n annotations?: ToolAnnotations;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n ...(metadata.annotations ? { annotations: metadata.annotations } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n { _meta?: { progressToken?: string | number } } | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Devportal GraphQL operations — aligned with the LIVE alpha supergraph.\n *\n * Background (BOFF-8190, BOFF-8191):\n * The previous draft of this file referenced the devportal-svc v0 contract\n * (`organizations`, `adminReviews`, `applicationVersions`, `apiKeys`,\n * `oauthClients`, `delegations`, `organizationRevenue`, `revokeApiKey`,\n * `deleteOAuthClient`, plus a handful of typed inputs that the live\n * supergraph doesn't expose). The deployed backend has since been\n * refactored: most entities moved onto the workspace-app context\n * (`app(id)`, `applications(organizationId, status)`, `appReviews`,\n * `appApiKeys`, `revokeAPIKey(keyId)`, `currentUserDelegations`,\n * `grantDelegation(input: GrantDelegationInput)`, `generateAPIKey(input:\n * GenerateAPIKeyInput)`, `webhooks(applicationId)`, etc.) and several\n * GraphQL-level drift issues (scalar selection on Boolean!, missing\n * `id` field on WebhookCreated, etc.) accumulated.\n *\n * This file is the rewritten set of operations that match the LIVE\n * schema. The matching tools live in ./tools.ts.\n *\n * For tools whose underlying feature is no longer exposed at all\n * (`revenue`, OAuth client management, application-version listing),\n * the tool returns a clear \"feature has moved to the auth module\"\n * error rather than a stubbed mutation — see tools.ts:stubbedTool.\n */\n\n// ── Developer Organizations ────────────────────────────────────────────────\n//\n// BOFF-9212 review (cv-arun): the previous draft of these operations pointed\n// at the TENANT `Organization` surface (`myOrganizations`, `organization(id)`,\n// `createOrganization`, `updateOrganization`, `deleteOrganization`) which\n// lives on `global-tenant-svc`. Devportal orgs are a different entity —\n// `DeveloperOrganization` on `global-devportal-svc` — with its own CRUD.\n// Re-pointed here so `devportal_orgs_*` reaches the right subgraph.\n\n// `myDeveloperOrganizations` takes NO arguments; returns a flat\n// `[DeveloperOrganization!]!` (not a connection). Pagination is client-side.\nexport const LIST_ORGANIZATIONS = `\n query ListDevportalOrganizations {\n myDeveloperOrganizations {\n id name slug description createdAt\n }\n }\n`;\n\nexport const GET_ORGANIZATION = `\n query GetDevportalOrganization($id: ID!) {\n developerOrganization(id: $id) {\n id name slug description createdAt\n }\n }\n`;\n\n// `CreateDeveloperOrganizationInput` includes `slug` + `description` +\n// optional contact / legal / metadata fields.\nexport const CREATE_ORGANIZATION = `\n mutation CreateDevportalOrganization($input: CreateDeveloperOrganizationInput!) {\n createDeveloperOrganization(input: $input) {\n id name slug description createdAt\n }\n }\n`;\n\n// `UpdateDeveloperOrganizationInput` does NOT include `slug` (immutable\n// after creation). Only `name`, `description`, contact / metadata fields.\nexport const UPDATE_ORGANIZATION = `\n mutation UpdateDevportalOrganization($id: ID!, $input: UpdateDeveloperOrganizationInput!) {\n updateDeveloperOrganization(id: $id, input: $input) {\n id name slug description createdAt\n }\n }\n`;\n\nexport const DELETE_ORGANIZATION = `\n mutation DeleteDevportalOrganization($id: ID!) {\n deleteDeveloperOrganization(id: $id)\n }\n`;\n\n// ── Applications ─────────────────────────────────────────────────────────\n\n// BOFF-8191: `$status: String` no longer matches the live `AppStatus` enum;\n// callers must pass the enum token (DRAFT|REVIEW|PUBLISHED|ARCHIVED), which\n// the schema coerces up-front.\nexport const LIST_APPLICATIONS = `\n query ListApplications($organizationId: ID, $status: AppStatus, $limit: Int) {\n applications(organizationId: $organizationId, status: $status, limit: $limit) {\n edges { node { id name status installCount averageRating } }\n totalCount\n }\n }\n`;\n\nexport const GET_APPLICATION = `\n query GetApplication($id: ID!) {\n application(id: $id) {\n id name status reviewStatus publishedAt installCount\n }\n }\n`;\n\n// BOFF-8191: `CreateApplicationInput` does NOT include `organizationId`.\n// The mutation is implicitly scoped to the caller's default organization.\n// `organizationId` was previously forwarded in the input but the schema\n// rejects it (\"organizationId is not defined by type CreateApplicationInput\").\n// Tool now forwards only `{ name, appType, description? }`.\nexport const CREATE_APPLICATION = `\n mutation CreateApplication($input: CreateApplicationInput!) {\n createApplication(input: $input) {\n id name status appId\n }\n }\n`;\n\nexport const UPDATE_APPLICATION = `\n mutation UpdateApplication($id: ID!, $input: UpdateApplicationInput!) {\n updateApplication(id: $id, input: $input) {\n id description updatedAt\n }\n }\n`;\n\nexport const SUBMIT_APPLICATION_FOR_REVIEW = `\n mutation SubmitApplicationForReview($id: ID!, $notes: String) {\n submitApplicationForReview(id: $id, notes: $notes) {\n id status reviewStatus submittedAt\n }\n }\n`;\n\nexport const PUBLISH_APPLICATION = `\n mutation PublishApplication($id: ID!) {\n publishApplication(id: $id) {\n id status publishedAt\n }\n }\n`;\n\n// BOFF-8191: `deleteApplication` returns `Boolean!` — selecting `{ success }`\n// was the GraphQL validation error before. No selection set on Boolean.\nexport const DELETE_APPLICATION = `\n mutation DeleteApplication($id: ID!) {\n deleteApplication(id: $id)\n }\n`;\n\n// ── Versions ─────────────────────────────────────────────────────────────\n\n// `Query.applicationVersions(applicationId)` was REMOVED from the live\n// schema. Versions are now embedded in the application context (see\n// `app(id)` — note: in this workspace the schema advertises no `versions`\n// field either). The tool is registered as a stub returning a clear\n// \"feature moved\" error rather than firing a doomed query.\n//\n// `CREATE_APPLICATION_VERSION` is still live and matches the devportal\n// service mutation.\nexport const CREATE_APPLICATION_VERSION = `\n mutation CreateApplicationVersion($applicationId: ID!, $input: CreateApplicationVersionInput!) {\n createApplicationVersion(applicationId: $applicationId, input: $input) {\n id version status publishedAt\n }\n }\n`;\n\n// ── Webhooks ─────────────────────────────────────────────────────────────\n\n// Live schema: `webhooks(applicationId)` returns a flat `Webhook` array\n// (not a connection) on the GLOBAL gateway. The `applicationId` argument\n// is required.\nexport const LIST_WEBHOOKS = `\n query ListDevportalWebhooks($applicationId: ID!) {\n webhooks(applicationId: $applicationId) {\n id name url events isActive status failureCount\n }\n }\n`;\n\n// BOFF-8190 + 8191: `createWebhook` on the live schema takes the\n// `applicationId` as a TOP-LEVEL argument and the body as `input: ...`.\n// Result is `{ webhook { id ... } }` — `WebhookCreated` itself has no\n// `id`, so the old direct `{ id name url status }` selection failed.\nexport const CREATE_WEBHOOK = `\n mutation CreateDevportalWebhook($applicationId: ID!, $input: CreateWebhookInput!) {\n createWebhook(applicationId: $applicationId, input: $input) {\n webhook { id name url events isActive status failureCount }\n }\n }\n`;\n\n// BOFF-8191: `deleteWebhook` returns `Boolean!` — drop the `{ success }`\n// selection set.\nexport const DELETE_WEBHOOK = `\n mutation DeleteDevportalWebhook($id: ID!) {\n deleteWebhook(id: $id)\n }\n`;\n\n// ── Analytics ────────────────────────────────────────────────────────────\n\nexport const APPLICATION_ANALYTICS = `\n query ApplicationAnalytics($applicationId: ID!, $period: String!, $startDate: DateTime, $endDate: DateTime) {\n applicationAnalytics(applicationId: $applicationId, period: $period, startDate: $startDate, endDate: $endDate) {\n date period activeUsers apiCalls avgResponseTime sessions\n }\n }\n`;\n\n// ── Admin reviews ────────────────────────────────────────────────────────\n\n// BOFF-8190 + 8191: `Query.adminReviews(status: AppReviewStatus)` was\n// removed. The replacement is `appReviews(applicationId: ID!, status:\n// AppReviewStatus, limit: Int, offset: Int)` — a relay-connection that\n// lives at GLOBAL `Query`. The `AppReview` node on alpha exposes only\n// `id` + `applicationId` (no `reviewStatus`/`reviewNotes`), so the\n// connection fields come from the wrapper. Pagination is via `limit` +\n// `offset` (NOT `first`/`after`).\nexport const ADMIN_REVIEWS = `\n query AdminReviews($applicationId: ID!, $status: AppReviewStatus, $limit: Int, $offset: Int) {\n appReviews(applicationId: $applicationId, status: $status, limit: $limit, offset: $offset) {\n edges { cursor node { id applicationId } }\n pageInfo { hasNextPage }\n totalCount\n }\n }\n`;\n\nexport const APPROVE_APPLICATION = `\n mutation ApproveApplication($id: ID!, $notes: String) {\n approveApplication(id: $id, notes: $notes) {\n id status reviewStatus publishedAt\n }\n }\n`;\n\nexport const REJECT_APPLICATION = `\n mutation RejectApplication($id: ID!, $notes: String!) {\n rejectApplication(id: $id, notes: $notes) {\n id status reviewStatus reviewNotes\n }\n }\n`;\n\n// ── API Keys ─────────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.apiKeys(applicationId)` was replaced by\n// `appApiKeys(appId: ID!): APIKeyConnection`. The `APIKeyConnection`\n// shape is `{ apiKeys { id appId ... } }` (not a relay connection —\n// no `edges`/`pageInfo`; the inner field is `apiKeys`). The `APIKey`\n// type on alpha exposes only `id`, `appId`, `name`, `prefix`, `scopes`,\n// `expiresAt`, `lastUsedAt`, `createdAt` — `isActive` was removed.\nexport const LIST_API_KEYS = `\n query ApiKeys($appId: ID!) {\n appApiKeys(appId: $appId) {\n apiKeys { id appId name prefix scopes expiresAt lastUsedAt createdAt }\n }\n }\n`;\n\n// BOFF-8190 + 8191: `createApiKey(input: CreateApiKeyInput!)` was replaced\n// by `generateAPIKey(input: GenerateAPIKeyInput!)`. The new input drops\n// `applicationId` and renames it to `appId`, plus `scopes` is renamed\n// `scope` and is now NON-OPTIONAL.\nexport const CREATE_API_KEY = `\n mutation CreateApiKey($input: GenerateAPIKeyInput!) {\n generateAPIKey(input: $input) {\n keyId apiKey apiSecret\n }\n }\n`;\n\n// BOFF-8190: `revokeApiKey(id)` was renamed to `revokeAPIKey(keyId: String!)`,\n// lives on the GLOBAL `Mutation`, and returns `Boolean!` (`true` on success).\nexport const REVOKE_API_KEY = `\n mutation RevokeApiKey($keyId: String!) {\n revokeAPIKey(keyId: $keyId)\n }\n`;\n\n// ── Delegations ──────────────────────────────────────────────────────────\n\n// BOFF-8190: `Query.delegations(applicationId, workspaceId)` was replaced\n// by `currentUserDelegations(pagination: PaginationInput)` (caller-scoped)\n// — the auth module already exposes this. The devportal tool now proxies\n// through the auth field for parity.\n//\n// `currentUserDelegations` returns `AppUserDelegationConnection` whose\n// only nested list field is `delegations` (NOT a relay connection).\nexport const LIST_DELEGATIONS = `\n query Delegations($first: Int) {\n currentUserDelegations(pagination: { limit: $first }) {\n delegations {\n id appId userId grantedBy grantedAt expiresAt scopes status workspaceIds\n app { id name }\n }\n }\n }\n`;\n\n// BOFF-8190 + 8191: `createDelegation(input: CreateDelegationInput!)` was\n// renamed to `grantDelegation(input: GrantDelegationInput!)`. The new\n// input drops `applicationId`/`workspaceId`/`scopes` in favor of\n// `appId`/`userId`/`scopes`-as-required-String-array and removes `expiresAt`\n// from the canonical GrantDelegationInput shape (optional elsewhere).\nexport const CREATE_DELEGATION = `\n mutation CreateDelegation($input: GrantDelegationInput!) {\n grantDelegation(input: $input) {\n id appId userId grantedBy grantedAt expiresAt scopes workspaceIds status\n }\n }\n`;\n\n// BOFF-8191: `revokeDelegation(id: ID!)` returns `Boolean!` on the live\n// schema — drop the legacy `{ success }` selection set. (Field still\n// exists despite BOFF-8190's title — the cluster message is just the\n// schema-validation failure on the selection set.)\nexport const REVOKE_DELEGATION = `\n mutation RevokeDelegation($id: ID!) {\n revokeDelegation(id: $id)\n }\n`;\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\n// BOFF-9212 review (cv-arun): repointed at `DeveloperOrganization` (was the\n// tenant `Organization`). `DeveloperOrganization` has no `status` field.\ninterface DeveloperOrgRow {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n createdAt?: string;\n}\n\ninterface AppRow {\n id: string;\n name: string;\n status?: string;\n reviewStatus?: string;\n publishedAt?: string;\n installCount?: number;\n averageRating?: number;\n}\n\ninterface AppRowWithAppId extends AppRow {\n appId?: string;\n}\n\ninterface VersionRow {\n id: string;\n version: string;\n status?: string;\n isLatest?: boolean;\n isStable?: boolean;\n releaseNotes?: string;\n}\n\ninterface WebhookRow {\n id: string;\n name: string;\n url: string;\n events?: string[];\n isActive?: boolean;\n status?: string;\n failureCount?: number;\n}\n\ninterface ApiKeyRow {\n id: string;\n appId?: string;\n name: string;\n prefix?: string;\n scopes?: string[];\n lastUsedAt?: string;\n isActive?: boolean;\n createdAt?: string;\n}\n\ninterface DelegationRow {\n id: string;\n appId?: string;\n userId?: string;\n grantedBy?: string;\n grantedAt?: string;\n expiresAt?: string;\n scopes?: string[];\n workspaceIds?: string[];\n status: string;\n}\n\nconst AppStatusEnum = z\n .enum(['DRAFT', 'REVIEW', 'PUBLISHED', 'ARCHIVED'])\n .describe('Application status');\n\nconst AppReviewStatusEnum = z\n .enum(['PENDING', 'APPROVED', 'REJECTED'])\n .describe('Application review status');\n\n/**\n * Register a tool that is intentionally a no-op on the current alpha\n * supergraph because the underlying GraphQL surface has been moved,\n * refactored, or removed. We keep the tool registered (so agentic callers\n * that may probe the name get a meaningful answer rather than a silent\n * schema-validation error) and return a clear pointer to the survivor\n * implementation. Background: BOFF-8190 / BOFF-8191.\n */\ntype StubInputSchema = Record<string, z.ZodTypeAny>;\nfunction stubbedTool(\n server: McpServer,\n // productName is reserved for future stub messages that need to embed the\n // real tool prefix; current stubs produce a placeholder note that does\n // not reference it.\n _productName: string,\n toolName: string,\n title: string,\n description: string,\n featureNote: string,\n inputSchema: StubInputSchema,\n altSuggestions: string[],\n): void {\n server.registerTool(\n toolName,\n {\n title,\n description: `${description} [intentionally stubbed: ${featureNote} Use ${altSuggestions.join(', ')} instead.]`,\n inputSchema,\n },\n async () =>\n errorResult(\n `[stubbed] ${featureNote} Use ${altSuggestions.join(', ')} instead. The tool remains registered so callers receive a meaningful response instead of a schema-validation error.`,\n ),\n );\n}\n\nexport function registerDevportalTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Developer Organizations ───────────────────────────────────────────────\n // BOFF-9212 review (cv-arun): repointed at the `DeveloperOrganization`\n // surface on `global-devportal-svc` (was incorrectly calling the TENANT\n // `Organization` operations on `global-tenant-svc`).\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_list')),\n {\n title: 'List Devportal Organizations',\n description:\n 'List developer organizations the caller is a member of (uses `myDeveloperOrganizations` on the global-devportal subgraph). Returns a flat array — pagination is client-side.',\n inputSchema: {},\n },\n async () => {\n try {\n const data = await ctx.gql.global.request<{\n myDeveloperOrganizations: DeveloperOrgRow[];\n }>(ops.LIST_ORGANIZATIONS, {});\n return jsonResult({\n items: data.myDeveloperOrganizations,\n totalCount: data.myDeveloperOrganizations.length,\n });\n } catch (error) {\n ctx.logger.error('devportal_orgs_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_get')),\n {\n title: 'Get Devportal Organization',\n description: 'Get a developer organization by ID.',\n inputSchema: { id: z.string().describe('Organization ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{\n developerOrganization: DeveloperOrgRow | null;\n }>(ops.GET_ORGANIZATION, { id });\n if (!data.developerOrganization) return errorResult(`Organization ${id} not found`);\n return jsonResult(data.developerOrganization);\n } catch (error) {\n ctx.logger.error('devportal_orgs_get failed', { error: String(error) });\n return errorResult(\n `Failed to get organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_create')),\n {\n title: 'Create Developer Organization',\n description:\n 'Create a developer organization. `slug` is auto-derived from `name` (kebab-case) when not supplied.',\n inputSchema: {\n name: z.string().describe('Organization name'),\n slug: z\n .string()\n .optional()\n .describe('URL slug — auto-derived from `name` (kebab-case) when omitted'),\n description: z.string().optional(),\n },\n },\n async ({ name, slug, description }) => {\n try {\n const input: Record<string, unknown> = { name, slug: slug ?? slugify(name) };\n if (description !== undefined) input.description = description;\n const data = await ctx.gql.global.request<{ createDeveloperOrganization: DeveloperOrgRow }>(\n ops.CREATE_ORGANIZATION,\n { input },\n );\n return jsonResult(data.createDeveloperOrganization);\n } catch (error) {\n ctx.logger.error('devportal_orgs_create failed', { error: String(error) });\n return errorResult(\n `Failed to create organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_update')),\n {\n title: 'Update Developer Organization',\n description:\n 'Update a developer organization. `slug` is immutable after creation — only `name`, `description`, and contact / metadata fields can be updated.',\n inputSchema: {\n id: z.string().describe('Organization ID'),\n name: z.string().optional(),\n description: z.string().optional(),\n },\n },\n async ({ id, name, description }) => {\n try {\n const input: Record<string, unknown> = {};\n if (name !== undefined) input.name = name;\n if (description !== undefined) input.description = description;\n if (!Object.keys(input).length) return errorResult('No updates specified');\n const data = await ctx.gql.global.request<{ updateDeveloperOrganization: DeveloperOrgRow }>(\n ops.UPDATE_ORGANIZATION,\n { id, input },\n );\n return jsonResult(data.updateDeveloperOrganization);\n } catch (error) {\n ctx.logger.error('devportal_orgs_update failed', { error: String(error) });\n return errorResult(\n `Failed to update organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_orgs_delete')),\n {\n title: 'Delete Developer Organization',\n description: 'Delete a developer organization.',\n inputSchema: { id: z.string().describe('Organization ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.DELETE_ORGANIZATION, { id });\n return jsonResult({ status: 'success', message: 'Organization deleted', orgId: id });\n } catch (error) {\n ctx.logger.error('devportal_orgs_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Applications ────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_list')),\n {\n title: 'List Devportal Applications',\n description:\n 'List devportal applications. `status` is the live `AppStatus` enum (DRAFT|REVIEW|PUBLISHED|ARCHIVED).',\n inputSchema: {\n organizationId: z.string().optional(),\n status: AppStatusEnum.optional(),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ organizationId, status, limit }) => {\n try {\n const data = await ctx.gql.global.request<{\n applications: { edges: Array<{ node: AppRow }>; totalCount: number };\n }>(ops.LIST_APPLICATIONS, {\n organizationId,\n status,\n limit: limit ?? 50,\n });\n return jsonResult({\n items: data.applications.edges.map((e) => e.node),\n totalCount: data.applications.totalCount,\n });\n } catch (error) {\n ctx.logger.error('devportal_apps_list failed', { error: String(error) });\n return errorResult(\n `Failed to list applications: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_get')),\n {\n title: 'Get Devportal Application',\n description: 'Get a devportal application by ID.',\n inputSchema: { id: z.string().describe('Application ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ application: AppRow | null }>(\n ops.GET_APPLICATION,\n { id },\n );\n if (!data.application) return errorResult(`Application ${id} not found`);\n return jsonResult(data.application);\n } catch (error) {\n ctx.logger.error('devportal_apps_get failed', { error: String(error) });\n return errorResult(\n `Failed to get application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_create')),\n {\n title: 'Create Devportal Application',\n description:\n 'Create a devportal application under the caller\\'s default organization. The live `CreateApplicationInput` does NOT accept `organizationId` (was previously forwarded; rejected by the schema with \"Field organizationId is not defined by type CreateApplicationInput\").',\n inputSchema: {\n name: z.string().describe('Application name'),\n appType: AppStatusEnum.describe(\n 'API_INTEGRATION|WEB_APP|MOBILE_APP (default API_INTEGRATION)',\n ).optional(),\n description: z.string().optional(),\n },\n },\n async ({ name, appType, description }) => {\n try {\n const input: Record<string, unknown> = {\n name,\n appType: (appType ?? 'API_INTEGRATION').toUpperCase(),\n };\n if (description !== undefined) input.description = description;\n const data = await ctx.gql.global.request<{\n createApplication: AppRowWithAppId;\n }>(ops.CREATE_APPLICATION, { input });\n return jsonResult(data.createApplication);\n } catch (error) {\n ctx.logger.error('devportal_apps_create failed', { error: String(error) });\n return errorResult(\n `Failed to create application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_update')),\n {\n title: 'Update Devportal Application',\n description: 'Update a devportal application.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n description: z.string().optional(),\n pricingType: z.string().optional().describe('FREE|PAID_ONETIME|SUBSCRIPTION'),\n documentationUrl: z.string().optional(),\n },\n },\n async ({ id, description, pricingType, documentationUrl }) => {\n try {\n const input: Record<string, unknown> = {};\n if (description !== undefined) input.description = description;\n if (pricingType !== undefined) input.pricingType = pricingType.toUpperCase();\n if (documentationUrl !== undefined) input.documentationUrl = documentationUrl;\n if (!Object.keys(input).length) return errorResult('No updates specified');\n const data = await ctx.gql.global.request<{ updateApplication: AppRow }>(\n ops.UPDATE_APPLICATION,\n { id, input },\n );\n return jsonResult(data.updateApplication);\n } catch (error) {\n ctx.logger.error('devportal_apps_update failed', { error: String(error) });\n return errorResult(\n `Failed to update application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_submit_review')),\n {\n title: 'Submit Application For Review',\n description: 'Submit an application for admin review.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n notes: z.string().optional().describe('Optional submission notes'),\n },\n },\n async ({ id, notes }) => {\n try {\n const data = await ctx.gql.global.request<{ submitApplicationForReview: AppRow }>(\n ops.SUBMIT_APPLICATION_FOR_REVIEW,\n { id, notes },\n );\n return jsonResult(data.submitApplicationForReview);\n } catch (error) {\n ctx.logger.error('devportal_apps_submit_review failed', { error: String(error) });\n return errorResult(\n `Failed to submit for review: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_publish')),\n {\n title: 'Publish Application',\n description:\n 'Publish an approved application. Note: in the legacy CLI this opened a browser; here it just calls the publish mutation directly.',\n inputSchema: { id: z.string().describe('Application ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ publishApplication: AppRow }>(\n ops.PUBLISH_APPLICATION,\n { id },\n );\n return jsonResult(data.publishApplication);\n } catch (error) {\n ctx.logger.error('devportal_apps_publish failed', { error: String(error) });\n return errorResult(\n `Failed to publish application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_delete')),\n {\n title: 'Delete Devportal Application',\n description:\n 'Delete a devportal application. Live mutation returns Boolean! (no selection set).',\n inputSchema: { id: z.string().describe('Application ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.DELETE_APPLICATION, { id });\n return jsonResult({ status: 'success', message: 'Application deleted', appId: id });\n } catch (error) {\n ctx.logger.error('devportal_apps_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Versions ────────────────────────────────────────────────────────────\n\n // BOFF-8190: `applicationVersions(applicationId)` is gone. Versions live\n // nowhere addressable via the devportal on alpha today. Stub it so\n // callers get an actionable message.\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_apps_versions_list')),\n 'List Application Versions',\n 'List versions for an application.',\n '`Query.applicationVersions(applicationId)` was removed from the alpha devportal supergraph; there is no surviving `versions` field on `app(applicationId)`.',\n {\n applicationId: z.string().describe('Application ID'),\n },\n [`\\`_devportal_apps_versions_create\\``, `\\`_devportal_apps_analytics\\``],\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_versions_create')),\n {\n title: 'Create Application Version',\n description: 'Create a new version for an application.',\n inputSchema: {\n applicationId: z.string().describe('Application ID'),\n version: z.string().describe('Version string (e.g. \"1.2.0\")'),\n releaseNotes: z.string().optional(),\n packageUrl: z.string().optional(),\n },\n },\n async ({ applicationId, version, releaseNotes, packageUrl }) => {\n try {\n const input: Record<string, unknown> = { version };\n if (releaseNotes !== undefined) input.releaseNotes = releaseNotes;\n if (packageUrl !== undefined) input.packageUrl = packageUrl;\n const data = await ctx.gql.global.request<{ createApplicationVersion: VersionRow }>(\n ops.CREATE_APPLICATION_VERSION,\n { applicationId, input },\n );\n return jsonResult(data.createApplicationVersion);\n } catch (error) {\n ctx.logger.error('devportal_apps_versions_create failed', { error: String(error) });\n return errorResult(\n `Failed to create version: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Webhooks ────────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_webhooks_list')),\n {\n title: 'List Application Webhooks',\n description:\n 'List webhooks attached to an application (live global `Query.webhooks(applicationId)`).',\n inputSchema: { applicationId: z.string().describe('Application ID') },\n },\n async ({ applicationId }) => {\n try {\n const data = await ctx.gql.global.request<{ webhooks: WebhookRow[] }>(ops.LIST_WEBHOOKS, {\n applicationId,\n });\n return jsonResult(data.webhooks);\n } catch (error) {\n ctx.logger.error('devportal_apps_webhooks_list failed', { error: String(error) });\n return errorResult(\n `Failed to list webhooks: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_webhooks_add')),\n {\n title: 'Add Application Webhook',\n description:\n 'Add a webhook to an application. The live mutation takes `applicationId` as a top-level argument plus `input: CreateWebhookInput!`. The result is `WebhookCreated { webhook { ... } }` (the type itself has no `id`).',\n inputSchema: {\n applicationId: z.string().describe('Application ID'),\n name: z.string().describe('Webhook name'),\n url: z.string().describe('Delivery URL'),\n events: z.array(z.string()).describe('Event names'),\n maxRetries: z.number().optional().describe('Default 5'),\n },\n },\n async ({ applicationId, name, url, events, maxRetries }) => {\n try {\n const input: Record<string, unknown> = {\n name,\n url,\n events,\n retryEnabled: true,\n maxRetries: maxRetries ?? 5,\n };\n const data = await ctx.gql.global.request<{\n createWebhook: { webhook: WebhookRow };\n }>(ops.CREATE_WEBHOOK, { applicationId, input });\n return jsonResult(data.createWebhook.webhook);\n } catch (error) {\n ctx.logger.error('devportal_apps_webhooks_add failed', { error: String(error) });\n return errorResult(\n `Failed to create webhook: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_webhooks_remove')),\n {\n title: 'Remove Application Webhook',\n description: 'Remove a webhook by ID. Live mutation returns Boolean! (no selection set).',\n inputSchema: { id: z.string().describe('Webhook ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.DELETE_WEBHOOK, { id });\n return jsonResult({ status: 'success', message: 'Webhook removed', webhookId: id });\n } catch (error) {\n ctx.logger.error('devportal_apps_webhooks_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove webhook: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Analytics ───────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_apps_analytics')),\n {\n title: 'Application Analytics',\n description: 'Get analytics for an application over a period.',\n inputSchema: {\n applicationId: z.string().describe('Application ID'),\n period: z\n .string()\n .optional()\n .describe('LAST_7_DAYS|LAST_30_DAYS|CUSTOM (default LAST_30_DAYS)'),\n startDate: z.string().optional().describe('ISO 8601 (required when period=CUSTOM)'),\n endDate: z.string().optional().describe('ISO 8601'),\n },\n },\n async ({ applicationId, period, startDate, endDate }) => {\n try {\n const data = await ctx.gql.global.request<{\n applicationAnalytics: Array<Record<string, unknown>>;\n }>(ops.APPLICATION_ANALYTICS, {\n applicationId,\n period: (period ?? 'LAST_30_DAYS').toUpperCase(),\n startDate,\n endDate,\n });\n return jsonResult(data.applicationAnalytics);\n } catch (error) {\n ctx.logger.error('devportal_apps_analytics failed', { error: String(error) });\n return errorResult(\n `Failed to fetch analytics: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Revenue ─────────────────────────────────────────────────────────────\n\n // BOFF-8190: `Query.organizationRevenue` is GONE; `organization` and `app`\n // types do NOT expose `revenue` either. Stub — point at billing tools.\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_revenue')),\n 'Organization Revenue',\n 'Get revenue summary for an organization.',\n '`Query.organizationRevenue` (and any `revenue` field on `organization` / `app`) was removed from the alpha supergraph.',\n {\n organizationId: z.string().describe('Organization ID'),\n period: z.string().optional().describe('LAST_7_DAYS|LAST_30_DAYS|YTD (default LAST_30_DAYS)'),\n },\n [`\\`_billing_invoices_list\\``, `\\`_billing_subscriptions_list\\``],\n );\n\n // ── Admin reviews ───────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_admin_reviews_list')),\n {\n title: 'List Admin Application Reviews',\n description:\n 'List applications in the admin review queue. Live query is `appReviews(applicationId, status, limit, offset)` (the unscoped `adminReviews` field was removed). `applicationId` is required, `status` filters the connection server-side, and pagination uses `limit` + `offset` (NOT `first`/`after`).',\n inputSchema: {\n applicationId: z.string().describe('Application ID to scope the review queue to'),\n status: AppReviewStatusEnum.optional(),\n limit: z.number().optional().describe('Page size (default 20)'),\n offset: z.number().optional().describe('Skip results'),\n },\n },\n async ({ applicationId, status, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{\n appReviews: {\n edges: Array<{ cursor: string; node: { id: string; applicationId: string } }>;\n pageInfo: { hasNextPage: boolean };\n totalCount: number;\n };\n }>(ops.ADMIN_REVIEWS, {\n applicationId,\n status,\n limit: limit ?? 20,\n offset: offset ?? 0,\n });\n return jsonResult({\n items: data.appReviews.edges.map((e) => e.node),\n totalCount: data.appReviews.totalCount,\n pageInfo: data.appReviews.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('devportal_admin_reviews_list failed', { error: String(error) });\n return errorResult(\n `Failed to list reviews: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_admin_reviews_approve')),\n {\n title: 'Approve Application',\n description: 'Approve a pending application.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n notes: z.string().optional(),\n },\n },\n async ({ id, notes }) => {\n try {\n const data = await ctx.gql.global.request<{ approveApplication: AppRow }>(\n ops.APPROVE_APPLICATION,\n { id, notes },\n );\n return jsonResult(data.approveApplication);\n } catch (error) {\n ctx.logger.error('devportal_admin_reviews_approve failed', { error: String(error) });\n return errorResult(\n `Failed to approve application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_admin_reviews_reject')),\n {\n title: 'Reject Application',\n description: 'Reject a pending application.',\n inputSchema: {\n id: z.string().describe('Application ID'),\n notes: z.string().describe('Reason for rejection (required)'),\n },\n },\n async ({ id, notes }) => {\n try {\n const data = await ctx.gql.global.request<{ rejectApplication: AppRow }>(\n ops.REJECT_APPLICATION,\n { id, notes },\n );\n return jsonResult(data.rejectApplication);\n } catch (error) {\n ctx.logger.error('devportal_admin_reviews_reject failed', { error: String(error) });\n return errorResult(\n `Failed to reject application: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── API Keys ───────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_api_keys_list')),\n {\n title: 'List API Keys',\n description: 'List API keys for an application. Live query is `appApiKeys(appId: ID!)`.',\n inputSchema: {\n applicationId: z.string().describe('Application ID (forwarded as `appId`)'),\n },\n },\n async ({ applicationId }) => {\n try {\n const data = await ctx.gql.global.request<{\n appApiKeys: { apiKeys: ApiKeyRow[] };\n }>(ops.LIST_API_KEYS, { appId: applicationId });\n return jsonResult(data.appApiKeys.apiKeys);\n } catch (error) {\n ctx.logger.error('devportal_api_keys_list failed', { error: String(error) });\n return errorResult(\n `Failed to list API keys: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_api_keys_create')),\n {\n title: 'Create API Key',\n description:\n 'Mint a new API key via `generateAPIKey(input: GenerateAPIKeyInput!)` (live auth mutation). Returns the full key including the one-time-visible `apiKey`/`apiSecret`.',\n inputSchema: {\n applicationId: z.string().describe('Application ID (forwarded as `appId`)'),\n name: z.string().min(1).describe('Human-readable name for the key'),\n scopes: z\n .array(z.string())\n .min(1)\n .describe(\n 'Scope identifiers granted to the key — REQUIRED on the live `GenerateAPIKeyInput.scope`',\n ),\n expiresAt: z.string().optional().describe('ISO 8601 expiry timestamp'),\n },\n },\n async ({ applicationId, name, scopes, expiresAt }) => {\n try {\n const input: Record<string, unknown> = {\n appId: applicationId,\n name,\n scope: scopes,\n };\n if (expiresAt !== undefined) input.expiresAt = expiresAt;\n const data = await ctx.gql.global.request<{\n generateAPIKey: { keyId: string; apiKey: string; apiSecret: string };\n }>(ops.CREATE_API_KEY, { input });\n return jsonResult({ ...data.generateAPIKey, name, scopes, applicationId });\n } catch (error) {\n ctx.logger.error('devportal_api_keys_create failed', { error: String(error) });\n return errorResult(\n `Failed to create API key: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_api_keys_revoke')),\n {\n title: 'Revoke API Key',\n description:\n 'Revoke an API key via `revokeAPIKey(keyId: String!)` (live global mutation, returns Boolean!).',\n inputSchema: { id: z.string().describe('API key ID (forwarded as `keyId`)') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.REVOKE_API_KEY, { keyId: id });\n return jsonResult({ status: 'success', message: 'API key revoked', apiKeyId: id });\n } catch (error) {\n ctx.logger.error('devportal_api_keys_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to revoke API key: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── OAuth Clients ───────────────────────────────────────────────────────\n\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_oauth_list')),\n 'List OAuth Clients',\n 'List OAuth 2.0 clients registered for a devportal application.',\n '`Query.oauthClients(applicationId)` no longer exists on the alpha supergraph, and `app(id)` does not expose a nested `oauthClients` field either.',\n {\n applicationId: z.string().describe('Application ID'),\n },\n [`\\`_auth_current_user_apps\\``],\n );\n\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_oauth_create')),\n 'Create OAuth Client',\n 'Register a new OAuth 2.0 client for an application.',\n '`Mutation.createOAuthClient` (and `CreateOAuthClientInput`) have been removed from the alpha supergraph.',\n {\n applicationId: z.string().describe('Application ID'),\n name: z.string().describe('Client name'),\n redirectUris: z.array(z.string()).optional(),\n grantTypes: z.array(z.string()).optional(),\n },\n [`\\`_auth_current_user_apps\\` (read-only on alpha)`],\n );\n\n stubbedTool(\n server,\n ctx.productName,\n track(mcpToolName(ctx.productName, 'devportal_oauth_delete')),\n 'Delete OAuth Client',\n 'Delete an OAuth 2.0 client by ID.',\n '`Mutation.deleteOAuthClient` has been removed from the alpha supergraph (no successor field).',\n {\n id: z.string().describe('OAuth client ID'),\n },\n [`\\`_auth_*\\` surface for current OAuth flows`],\n );\n\n // ── Delegations ────────────────────────────────────────────────────────\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_delegations_list')),\n {\n title: 'List Delegations',\n description:\n 'List workspace delegations issued to applications. Live impl proxies through the global `Query.currentUserDelegations` (calls scoped to the caller). Note: in-scope filtering by application/workspace is not supported on the live schema — pass `first` to paginate.',\n inputSchema: {\n first: z\n .number()\n .optional()\n .describe(\n 'Page size (default 50). Filter args from the old `delegations(...)` were dropped.',\n ),\n },\n },\n async ({ first }) => {\n try {\n const data = await ctx.gql.global.request<{\n currentUserDelegations: { delegations: DelegationRow[] };\n }>(ops.LIST_DELEGATIONS, { first: first ?? 50 });\n return jsonResult(data.currentUserDelegations.delegations);\n } catch (error) {\n ctx.logger.error('devportal_delegations_list failed', { error: String(error) });\n return errorResult(\n `Failed to list delegations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_delegations_create')),\n {\n title: 'Create Delegation',\n description:\n 'Grant a workspace delegation to an application. Live impl is `grantDelegation(input: GrantDelegationInput!)` (renamed from `CreateDelegationInput`); `appId` replaces `applicationId`. The grant is implicitly to the calling actor — `GrantDelegationInput` does NOT take a `userId`.',\n inputSchema: {\n applicationId: z\n .string()\n .describe('Application ID receiving the delegation (forwarded as `appId`)'),\n scopes: z\n .array(z.string())\n .min(1)\n .describe(\n 'Scope identifiers granted to the application — REQUIRED on the live GrantDelegationInput',\n ),\n workspaceIds: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional list of workspace IDs scoping the delegation (forwarded as `workspaceIds`)',\n ),\n expiresAt: z\n .string()\n .optional()\n .describe(\n 'ISO 8601 expiry timestamp (DateTime scalar — must be a full ISO 8601 instant, not a date)',\n ),\n },\n },\n async ({ applicationId, scopes, workspaceIds, expiresAt }) => {\n try {\n const input: Record<string, unknown> = { appId: applicationId, scopes };\n if (workspaceIds !== undefined) input.workspaceIds = workspaceIds;\n if (expiresAt !== undefined) input.expiresAt = expiresAt;\n const data = await ctx.gql.global.request<{\n grantDelegation: DelegationRow;\n }>(ops.CREATE_DELEGATION, { input });\n return jsonResult(data.grantDelegation);\n } catch (error) {\n ctx.logger.error('devportal_delegations_create failed', { error: String(error) });\n return errorResult(\n `Failed to create delegation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'devportal_delegations_revoke')),\n {\n title: 'Revoke Delegation',\n description:\n 'Revoke a workspace delegation via `revokeDelegation(id: ID!)` (live schema, returns Boolean!; no selection set).',\n inputSchema: { id: z.string().describe('Delegation ID') },\n },\n async ({ id }) => {\n try {\n await ctx.gql.global.request(ops.REVOKE_DELEGATION, { id });\n return jsonResult({ status: 'success', message: 'Delegation revoked', delegationId: id });\n } catch (error) {\n ctx.logger.error('devportal_delegations_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to revoke delegation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n\nfunction slugify(s: string): string {\n return (\n s\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 64) || 'org'\n );\n}\n","/**\n * Devportal module — publisher orgs, applications, versions, webhooks, analytics, revenue, admin reviews.\n *\n * Backend: global-devportal-svc.\n * Ported from cli-sdk/src/modules/devportal/. Browser-only flows (open-in-browser\n * publish handoffs) are not exposed; the publish tool calls the publish mutation directly.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerDevportalTools } from './tools.js';\n\nconst devportalModule: McpModule = {\n id: 'devportal',\n version: '0.0.1',\n displayName: 'Developer Portal',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerDevportalTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default devportalModule;\n"]}