@mandujs/mcp 0.28.1 → 0.28.2

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/tools/brain.ts +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/mcp",
3
- "version": "0.28.1",
3
+ "version": "0.28.2",
4
4
  "description": "Mandu MCP Server - Agent-native interface for Mandu framework operations",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@mandujs/core": "^0.41.1",
37
+ "@mandujs/core": "^0.41.2",
38
38
  "@mandujs/ate": "^0.24.0",
39
39
  "@mandujs/skills": "^0.18.0",
40
40
  "@modelcontextprotocol/sdk": "^1.25.3"
@@ -212,6 +212,40 @@ export const brainToolDefinitions: Tool[] = [
212
212
  /** Module-level unsubscribe handle for MCP warning notifications */
213
213
  let mcpWarningUnsubscribe: (() => void) | null = null;
214
214
 
215
+ /**
216
+ * #236 — surface a clear error when a stale `@mandujs/core` resolves
217
+ * under `node_modules/@mandujs/mcp/node_modules/` (Bun's installer
218
+ * sometimes lands an older nested copy even with `linker=hoisted`).
219
+ * Without this check the user saw `getCredentialStore is not a
220
+ * function` / `undefined is not a constructor` with no hint.
221
+ */
222
+ function assertBrainAuthSurface(core: Record<string, unknown>): void {
223
+ const missing: string[] = [];
224
+ if (typeof core.getCredentialStore !== "function")
225
+ missing.push("getCredentialStore");
226
+ if (typeof core.resolveBrainAdapter !== "function")
227
+ missing.push("resolveBrainAdapter");
228
+ if (typeof core.ChatGPTAuth !== "function") missing.push("ChatGPTAuth");
229
+ if (typeof core.AnthropicOAuthAdapter !== "function")
230
+ missing.push("AnthropicOAuthAdapter");
231
+ if (typeof core.revokeConsent !== "function") missing.push("revokeConsent");
232
+ if (missing.length === 0) return;
233
+
234
+ const pkgVersion =
235
+ typeof core.__MANDU_CORE_VERSION__ === "string"
236
+ ? core.__MANDU_CORE_VERSION__
237
+ : "unknown";
238
+ throw new Error(
239
+ `[mandu-mcp] The resolved @mandujs/core (v${pkgVersion}) is missing brain-auth exports: ${missing.join(
240
+ ", ",
241
+ )}. ` +
242
+ `This usually means Bun's installer placed a stale nested copy at ` +
243
+ `node_modules/@mandujs/mcp/node_modules/@mandujs/core instead of hoisting to the top level. ` +
244
+ `Fix: \`rm -rf node_modules bun.lock && bun install\` (or confirm linker=hoisted in bunfig.toml). ` +
245
+ `See https://github.com/konamgil/mandu/issues/236 for details.`,
246
+ );
247
+ }
248
+
215
249
  export function brainTools(projectRoot: string, server?: Server, monitor?: ActivityMonitor) {
216
250
  const paths = getProjectPaths(projectRoot);
217
251
 
@@ -600,6 +634,7 @@ export function brainTools(projectRoot: string, server?: Server, monitor?: Activ
600
634
  // #235 followup — brain auth tools (status / login / logout).
601
635
  handlers["mandu.brain.status"] = async () => {
602
636
  const core = await import("@mandujs/core");
637
+ assertBrainAuthSurface(core);
603
638
  const store = core.getCredentialStore();
604
639
  const resolution = await core.resolveBrainAdapter({
605
640
  adapter: "auto",
@@ -661,6 +696,7 @@ export function brainTools(projectRoot: string, server?: Server, monitor?: Activ
661
696
 
662
697
  if (provider === "openai") {
663
698
  const core = await import("@mandujs/core");
699
+ assertBrainAuthSurface(core);
664
700
  const auth = new core.ChatGPTAuth();
665
701
  const existing = auth.locateAuthFile();
666
702
  if (existing) {
@@ -751,6 +787,7 @@ export function brainTools(projectRoot: string, server?: Server, monitor?: Activ
751
787
 
752
788
  // Anthropic — Mandu-managed OAuth loopback flow.
753
789
  const core = await import("@mandujs/core");
790
+ assertBrainAuthSurface(core);
754
791
  try {
755
792
  const adapter = new core.AnthropicOAuthAdapter({
756
793
  credentialStore: core.getCredentialStore(),
@@ -803,6 +840,7 @@ export function brainTools(projectRoot: string, server?: Server, monitor?: Activ
803
840
  provider?: "openai" | "anthropic" | "all";
804
841
  };
805
842
  const core = await import("@mandujs/core");
843
+ assertBrainAuthSurface(core);
806
844
  const store = core.getCredentialStore();
807
845
  const targets =
808
846
  provider === "all"