@productbrain/mcp 0.0.1-beta.14272 → 0.0.1-beta.14280

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.
@@ -48,10 +48,10 @@ import {
48
48
  startAgentSession,
49
49
  startTimingLine,
50
50
  withAcceptPrompt
51
- } from "./chunk-F4FYLPGO.js";
51
+ } from "./chunk-RHPRF4OG.js";
52
52
 
53
53
  // src/server.ts
54
- import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
54
+ import { McpServer as McpServer2 } from "@modelcontextprotocol/server";
55
55
  import { z as z35 } from "zod/v3";
56
56
 
57
57
  // src/callerSession.ts
@@ -199,6 +199,15 @@ function orientationRefusalResult(err, lines) {
199
199
  }
200
200
  var ORIENT_REQUIRED_NOTE = "workflow checkpoints and organisation-structure writes (membership, ownership, parent) still require an oriented session.";
201
201
 
202
+ // src/servedSchema.ts
203
+ import { zodToJsonSchema } from "zod-to-json-schema";
204
+ function servedSchema(schema) {
205
+ const json = zodToJsonSchema(schema, { strictUnions: true, pipeStrategy: "input" });
206
+ const standard = schema["~standard"];
207
+ standard.jsonSchema = { input: () => json, output: () => json };
208
+ return schema;
209
+ }
210
+
202
211
  // src/lib/checklist.ts
203
212
  var FIRST_SPINE_SUBJECT = "work_package";
204
213
  var kindWord = (kind) => kind.replace(/_/g, " ");
@@ -11682,7 +11691,7 @@ function registerQuestionTools(server) {
11682
11691
  import { existsSync as existsSync3 } from "fs";
11683
11692
  import { dirname, join, resolve as resolve4 } from "path";
11684
11693
  import { fileURLToPath } from "url";
11685
- import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
11694
+ import { ResourceTemplate } from "@modelcontextprotocol/server";
11686
11695
 
11687
11696
  // src/resources/terminologyResource.ts
11688
11697
  async function buildTerminologyResourceText() {
@@ -11732,16 +11741,18 @@ function formatEntryMarkdown(entry) {
11732
11741
  return lines.join("\n");
11733
11742
  }
11734
11743
  function registerResources(server) {
11735
- server.resource(
11744
+ server.registerResource(
11736
11745
  "chain-terminology",
11737
11746
  "productbrain://terminology",
11747
+ {},
11738
11748
  async (uri) => ({
11739
11749
  contents: [{ uri: uri.href, text: await buildTerminologyResourceText(), mimeType: "text/markdown" }]
11740
11750
  })
11741
11751
  );
11742
- server.resource(
11752
+ server.registerResource(
11743
11753
  "chain-collections",
11744
11754
  "productbrain://collections",
11755
+ {},
11745
11756
  async (uri) => {
11746
11757
  const collections = await kernelQuery("chain.listCollections") ?? [];
11747
11758
  if (collections.length === 0) {
@@ -11762,7 +11773,7 @@ ${formatted}`, mimeType: "text/markdown" }]
11762
11773
  };
11763
11774
  }
11764
11775
  );
11765
- server.resource(
11776
+ server.registerResource(
11766
11777
  "chain-collection-entries",
11767
11778
  new ResourceTemplate("productbrain://{slug}/entries", {
11768
11779
  list: async () => {
@@ -11775,6 +11786,7 @@ ${formatted}`, mimeType: "text/markdown" }]
11775
11786
  };
11776
11787
  }
11777
11788
  }),
11789
+ {},
11778
11790
  async (uri, { slug }) => {
11779
11791
  const { rows, cutLine } = await listEntriesWithCut({ collectionSlug: slug });
11780
11792
  const formatted = rows.map(formatEntryMarkdown).join("\n\n---\n\n") || (cutLine ? "" : "No entries in this collection.");
@@ -11787,9 +11799,10 @@ ${formatted}`, mimeType: "text/markdown" }]
11787
11799
  };
11788
11800
  }
11789
11801
  );
11790
- server.resource(
11802
+ server.registerResource(
11791
11803
  "chain-labels",
11792
11804
  "productbrain://labels",
11805
+ {},
11793
11806
  async (uri) => {
11794
11807
  const labels = await kernelQuery("chain.listLabels") ?? [];
11795
11808
  if (labels.length === 0) {
@@ -11818,7 +11831,7 @@ ${lines.join("\n")}`, mimeType: "text/markdown" }]
11818
11831
  };
11819
11832
  }
11820
11833
  );
11821
- server.resource(
11834
+ server.registerResource(
11822
11835
  "chain-entry",
11823
11836
  new ResourceTemplate("productbrain://entries/{entryId}", {
11824
11837
  list: void 0,
@@ -11830,6 +11843,7 @@ ${lines.join("\n")}`, mimeType: "text/markdown" }]
11830
11843
  }
11831
11844
  }
11832
11845
  }),
11846
+ {},
11833
11847
  async (uri, { entryId }) => {
11834
11848
  const [entry, collections] = await Promise.all([
11835
11849
  kernelQuery("chain.getEntry", { entryId }),
@@ -11876,7 +11890,7 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
11876
11890
  };
11877
11891
  }
11878
11892
  );
11879
- server.resource(
11893
+ server.registerResource(
11880
11894
  "chain-context",
11881
11895
  new ResourceTemplate("productbrain://context/{entryId}", {
11882
11896
  list: void 0,
@@ -11888,6 +11902,7 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
11888
11902
  }
11889
11903
  }
11890
11904
  }),
11905
+ {},
11891
11906
  async (uri, { entryId }) => {
11892
11907
  const result2 = await kernelQuery("chain.gatherContext", {
11893
11908
  entryId,
@@ -11922,7 +11937,7 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
11922
11937
  };
11923
11938
  }
11924
11939
  );
11925
- server.resource(
11940
+ server.registerResource(
11926
11941
  "chain-collection-capture-contract",
11927
11942
  new ResourceTemplate("productbrain://collections/{slug}/capture-contract", {
11928
11943
  list: async () => {
@@ -11935,6 +11950,7 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
11935
11950
  };
11936
11951
  }
11937
11952
  }),
11953
+ {},
11938
11954
  async (uri, { slug }) => {
11939
11955
  const collectionSlug = slug;
11940
11956
  let contract = null;
@@ -11974,7 +11990,7 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
11974
11990
  };
11975
11991
  }
11976
11992
  );
11977
- server.resource(
11993
+ server.registerResource(
11978
11994
  "chain-search",
11979
11995
  new ResourceTemplate("productbrain://search/{query}", {
11980
11996
  list: void 0,
@@ -11985,6 +12001,7 @@ ${entry.labels.map((l) => `- ${l.name ?? l.slug}`).join("\n")}`);
11985
12001
  }
11986
12002
  }
11987
12003
  }),
12004
+ {},
11988
12005
  async (uri, { query }) => {
11989
12006
  const results = await kernelQuery("chain.searchEntries", { query });
11990
12007
  if (!results || results.length === 0) {
@@ -12091,31 +12108,36 @@ Format as a table: Name | Status | Canonical Form | Action Needed`
12091
12108
  };
12092
12109
  }
12093
12110
  function registerPrompts(server) {
12094
- server.prompt(
12111
+ server.registerPrompt(
12095
12112
  "review-against-rules",
12096
- "Review code or a design decision against the rules, focused on a given area. Fetches the rules and asks you to do a structured compliance review.",
12097
- { domain: z34.string().describe("Business rule domain (e.g. 'Identity & Access', 'Governance & Decision-Making')") },
12113
+ {
12114
+ description: "Review code or a design decision against the rules, focused on a given area. Fetches the rules and asks you to do a structured compliance review.",
12115
+ argsSchema: servedSchema(z34.object({ domain: z34.string().describe("Business rule domain (e.g. 'Identity & Access', 'Governance & Decision-Making')") }))
12116
+ },
12098
12117
  async ({ domain }) => buildReviewAgainstRulesPrompt(domain)
12099
12118
  );
12100
- server.prompt(
12119
+ server.registerPrompt(
12101
12120
  "name-check",
12102
- "Check variable names, field names, or API names against the glossary for terminology alignment. Flags drift from canonical terms.",
12103
- { names: z34.string().describe("Comma-separated list of names to check (e.g. 'user_id, workspace_id, entry_status')") },
12121
+ {
12122
+ description: "Check variable names, field names, or API names against the glossary for terminology alignment. Flags drift from canonical terms.",
12123
+ argsSchema: servedSchema(z34.object({ names: z34.string().describe("Comma-separated list of names to check (e.g. 'user_id, workspace_id, entry_status')") }))
12124
+ },
12104
12125
  async ({ names }) => buildNameCheckPrompt(names)
12105
12126
  );
12106
- server.prompt(
12127
+ server.registerPrompt(
12107
12128
  "draft-decision-record",
12108
- "Draft a structured decision record from a description of what was decided. Includes context from recent decisions and relevant rules.",
12109
- { context: z34.string().describe("Description of the decision (e.g. 'We decided to keep one body field per entry because...')") },
12129
+ {
12130
+ description: "Draft a structured decision record from a description of what was decided. Includes context from recent decisions and relevant rules.",
12131
+ argsSchema: servedSchema(z34.object({ context: z34.string().describe("Description of the decision (e.g. 'We decided to keep one body field per entry because...')") }))
12132
+ },
12110
12133
  async ({ context }) => buildDraftDecisionRecordPrompt(context)
12111
12134
  );
12112
- server.prompt(
12135
+ server.registerPrompt(
12113
12136
  "draft-rule-from-context",
12114
- "Draft a new business rule from an observation or discovery made while coding. Fetches existing rules for the domain to ensure consistency.",
12115
- {
12137
+ { description: "Draft a new business rule from an observation or discovery made while coding. Fetches existing rules for the domain to ensure consistency.", argsSchema: servedSchema(z34.object({
12116
12138
  observation: z34.string().describe("What you observed or discovered (e.g. 'A workspace can have more than one owner role')"),
12117
12139
  domain: z34.string().describe("Which domain this rule belongs to (e.g. 'Governance & Decision-Making')")
12118
- },
12140
+ })) },
12119
12141
  async ({ observation, domain }) => buildDraftRuleFromContextPrompt(observation, domain)
12120
12142
  );
12121
12143
  }
@@ -12224,7 +12246,7 @@ function acceptSessionIdOnEveryTool(server) {
12224
12246
  const register = server.registerTool.bind(server);
12225
12247
  server.registerTool = (name, config, cb) => register(
12226
12248
  name,
12227
- { ...config, inputSchema: config.inputSchema.extend({ sessionId: sessionIdArg }) },
12249
+ { ...config, inputSchema: servedSchema(config.inputSchema.extend({ sessionId: sessionIdArg })) },
12228
12250
  // TASK-893: the command opens here, so the session validation below carries the tool call's x-pb-command.
12229
12251
  async ({ sessionId, ...args }, extra) => runWithCommandId(async () => {
12230
12252
  if (typeof sessionId === "string" && sessionId.length > 0 && !(name === "session" && args.action === "start")) {
@@ -12237,6 +12259,7 @@ function acceptSessionIdOnEveryTool(server) {
12237
12259
  return cb(args, extra);
12238
12260
  })
12239
12261
  );
12262
+ return server;
12240
12263
  }
12241
12264
  async function validateOrRefuse(sessionId) {
12242
12265
  try {
@@ -12263,11 +12286,11 @@ async function validateOrRefuse(sessionId) {
12263
12286
  }
12264
12287
  }
12265
12288
  function createProductBrainServer() {
12266
- const server = new McpServer2(
12289
+ const mcp = new McpServer2(
12267
12290
  { name: "Product Brain", version: SERVER_VERSION },
12268
12291
  { capabilities: { logging: {} }, instructions: INSTRUCTIONS }
12269
12292
  );
12270
- acceptSessionIdOnEveryTool(server);
12293
+ const server = acceptSessionIdOnEveryTool(mcp);
12271
12294
  registerSessionTools(server);
12272
12295
  registerEntriesTools(server);
12273
12296
  registerRelationsTools(server);
@@ -12284,13 +12307,13 @@ function createProductBrainServer() {
12284
12307
  registerRoleTools(server);
12285
12308
  registerPeopleTools(server);
12286
12309
  registerOutcomeTools(server);
12287
- registerResources(server);
12288
- registerPrompts(server);
12289
- return server;
12310
+ registerResources(mcp);
12311
+ registerPrompts(mcp);
12312
+ return mcp;
12290
12313
  }
12291
12314
 
12292
12315
  export {
12293
12316
  SERVER_VERSION,
12294
12317
  createProductBrainServer
12295
12318
  };
12296
- //# sourceMappingURL=chunk-JEMDFT7G.js.map
12319
+ //# sourceMappingURL=chunk-TPOWHC6M.js.map