secondbrainos-mcp-server 1.4.6 → 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.
- package/build/index.js +32 -3
- 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
|
-
//
|
|
166
|
-
|
|
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;
|