secondbrainos-mcp-server 1.4.5 → 1.4.7

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/build/index.js +37 -6
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { ListResourcesRequestSchema, ReadResourceRequestSchema, ListToolsRequestSchema, CallToolRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
4
- import { OpenApi, HttpLlm } from "@samchon/openapi";
4
+ import { OpenApi, HttpLlm, HttpError } from "@samchon/openapi";
5
5
  import axios from "axios";
6
6
  import dotenv from "dotenv";
7
7
  import yaml from 'js-yaml';
@@ -162,8 +162,37 @@ class SecondBrainOSServer {
162
162
  };
163
163
  }
164
164
  catch (error) {
165
- // Better error handling with HttpLlm
166
- if (axios.isAxiosError(error)) {
165
+ // HttpError from @samchon/openapi its constructor passes the
166
+ // parsed response body (an object) to super(), so Error coerces it
167
+ // to "[object Object]" and the original detail is lost.
168
+ // We can only rely on error.status for meaningful messages.
169
+ if (error instanceof HttpError) {
170
+ let mcpError;
171
+ switch (error.status) {
172
+ case 401:
173
+ mcpError = 'Authentication failed: Invalid or expired credentials';
174
+ break;
175
+ case 400:
176
+ mcpError = `Bad request (${error.method} ${error.path})`;
177
+ break;
178
+ case 403:
179
+ mcpError = `Insufficient credits or permissions (${error.method} ${error.path})`;
180
+ break;
181
+ case 404:
182
+ mcpError = `Service or resource not found (${error.method} ${error.path})`;
183
+ break;
184
+ default:
185
+ mcpError = `Error ${error.status} (${error.method} ${error.path})`;
186
+ }
187
+ return {
188
+ content: [{
189
+ type: 'text',
190
+ text: mcpError
191
+ }],
192
+ isError: true
193
+ };
194
+ }
195
+ else if (axios.isAxiosError(error)) {
167
196
  const status = error.response?.status;
168
197
  const rawError = error.response?.data?.error || error.response?.data?.message || error.message;
169
198
  const errorMessage = typeof rawError === 'object' ? JSON.stringify(rawError) : rawError;
@@ -192,16 +221,18 @@ class SecondBrainOSServer {
192
221
  isError: true
193
222
  };
194
223
  }
195
- else if (error instanceof Error) {
224
+ else {
225
+ const msg = error instanceof Error
226
+ ? error.message
227
+ : (typeof error === 'object' ? JSON.stringify(error) : String(error));
196
228
  return {
197
229
  content: [{
198
230
  type: 'text',
199
- text: `Error calling function: ${error.message}`
231
+ text: `Error calling function: ${msg}`
200
232
  }],
201
233
  isError: true
202
234
  };
203
235
  }
204
- throw error;
205
236
  }
206
237
  });
207
238
  // List available prompts (user's workflows + agents)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secondbrainos-mcp-server",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "description": "Second Brain OS MCP Server for Claude Desktop",
5
5
  "type": "module",
6
6
  "main": "build/index.js",