secondbrainos-mcp-server 1.4.6 → 1.4.8
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 +30 -46
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -142,68 +142,52 @@ class SecondBrainOSServer {
|
|
|
142
142
|
try {
|
|
143
143
|
// Intercept file_path arguments: upload local files to GCS
|
|
144
144
|
const processedArgs = await this.interceptFilePathArgs((request.params.arguments || {}));
|
|
145
|
-
// Use HttpLlm.
|
|
146
|
-
|
|
145
|
+
// Use HttpLlm.propagate to get full response (status + body)
|
|
146
|
+
// instead of HttpLlm.execute which throws HttpError and loses
|
|
147
|
+
// the response body (Error constructor coerces objects to "[object Object]")
|
|
148
|
+
const response = await HttpLlm.propagate({
|
|
147
149
|
connection: {
|
|
148
150
|
host: this.baseUrl,
|
|
149
151
|
headers: {
|
|
150
152
|
'Authorization': `Bearer ${this.userId}:${this.userSecret}`
|
|
151
153
|
}
|
|
152
154
|
},
|
|
153
|
-
application: this.application,
|
|
155
|
+
application: this.application,
|
|
154
156
|
function: func,
|
|
155
157
|
input: processedArgs
|
|
156
158
|
});
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
// Better error handling with HttpLlm
|
|
166
|
-
if (axios.isAxiosError(error)) {
|
|
167
|
-
const status = error.response?.status;
|
|
168
|
-
const rawError = error.response?.data?.error || error.response?.data?.message || error.message;
|
|
169
|
-
const errorMessage = typeof rawError === 'object' ? JSON.stringify(rawError) : rawError;
|
|
170
|
-
let mcpError;
|
|
171
|
-
switch (status) {
|
|
172
|
-
case 401:
|
|
173
|
-
mcpError = 'Authentication failed: Invalid or expired credentials';
|
|
174
|
-
break;
|
|
175
|
-
case 400:
|
|
176
|
-
mcpError = `Bad request: ${errorMessage}`;
|
|
177
|
-
break;
|
|
178
|
-
case 403:
|
|
179
|
-
mcpError = 'Insufficient credits or permissions';
|
|
180
|
-
break;
|
|
181
|
-
case 404:
|
|
182
|
-
mcpError = 'Service or resource not found';
|
|
183
|
-
break;
|
|
184
|
-
default:
|
|
185
|
-
mcpError = `Error calling function: ${errorMessage}`;
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
content: [{
|
|
189
|
-
type: 'text',
|
|
190
|
-
text: mcpError
|
|
191
|
-
}],
|
|
192
|
-
isError: true
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
const msg = error instanceof Error
|
|
197
|
-
? error.message
|
|
198
|
-
: (typeof error === 'object' ? JSON.stringify(error) : String(error));
|
|
159
|
+
// Non-success status — return the full error body
|
|
160
|
+
if (response.status !== 200 && response.status !== 201) {
|
|
161
|
+
const detail = typeof response.body === 'object'
|
|
162
|
+
? JSON.stringify(response.body)
|
|
163
|
+
: String(response.body ?? `HTTP ${response.status}`);
|
|
199
164
|
return {
|
|
200
165
|
content: [{
|
|
201
166
|
type: 'text',
|
|
202
|
-
text:
|
|
167
|
+
text: detail
|
|
203
168
|
}],
|
|
204
169
|
isError: true
|
|
205
170
|
};
|
|
206
171
|
}
|
|
172
|
+
return {
|
|
173
|
+
content: [{
|
|
174
|
+
type: 'text',
|
|
175
|
+
text: JSON.stringify(response.body, null, 2)
|
|
176
|
+
}]
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
// Connection failures or unexpected errors
|
|
181
|
+
const msg = error instanceof Error
|
|
182
|
+
? error.message
|
|
183
|
+
: (typeof error === 'object' ? JSON.stringify(error) : String(error));
|
|
184
|
+
return {
|
|
185
|
+
content: [{
|
|
186
|
+
type: 'text',
|
|
187
|
+
text: `Error calling function: ${msg}`
|
|
188
|
+
}],
|
|
189
|
+
isError: true
|
|
190
|
+
};
|
|
207
191
|
}
|
|
208
192
|
});
|
|
209
193
|
// List available prompts (user's workflows + agents)
|