Skip to content

Commit 37648d5

Browse files
authored
fix: mcp not response output (#5388)
1 parent f870a2d commit 37648d5

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

packages/service/common/file/image/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { readFromSecondary } from '../../mongo/utils';
77
import { addHours } from 'date-fns';
88
import { imageFileType } from '@fastgpt/global/common/file/constants';
99
import { retryFn } from '@fastgpt/global/common/system/utils';
10+
import { UserError } from '@fastgpt/global/common/error/utils';
1011

1112
export const maxImgSize = 1024 * 1024 * 12;
1213
const base64MimeRegex = /data:image\/([^\)]+);base64/;
@@ -105,7 +106,7 @@ export async function readMongoImg({ id }: { id: string }) {
105106
...readFromSecondary
106107
});
107108
if (!data) {
108-
return Promise.reject('Image not found');
109+
return Promise.reject(new UserError('Image not found'));
109110
}
110111

111112
return {

packages/service/common/response/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { proxyError, ERROR_RESPONSE, ERROR_ENUM } from '@fastgpt/global/common/e
44
import { addLog } from '../system/log';
55
import { clearCookie } from '../../support/permission/controller';
66
import { replaceSensitiveText } from '@fastgpt/global/common/string/tools';
7+
import { UserError } from '@fastgpt/global/common/error/utils';
78

89
export interface ResponseType<T = any> {
910
code: number;
@@ -59,7 +60,11 @@ export const jsonRes = <T = any>(
5960
msg = error?.error?.message;
6061
}
6162

62-
addLog.error(`Api response error: ${url}, ${msg}`, error);
63+
if (error instanceof UserError) {
64+
addLog.info(`Request error: ${url}, ${msg}`);
65+
} else {
66+
addLog.error(`System unexpected error: ${url}, ${msg}`, error);
67+
}
6368
}
6469

6570
res.status(code).json({

packages/service/core/dataset/image/controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { setCron } from '../../../common/system/cron';
99
import { checkTimerLock } from '../../../common/system/timerLock/utils';
1010
import { TimerIdEnum } from '../../../common/system/timerLock/constants';
1111
import { addLog } from '../../../common/system/log';
12+
import { UserError } from '@fastgpt/global/common/error/utils';
1213

1314
const getGridBucket = () => {
1415
return new connectionMongo.mongo.GridFSBucket(connectionMongo.connection.db!, {
@@ -69,7 +70,7 @@ export const getDatasetImageReadData = async (imageId: string) => {
6970
_id: new Types.ObjectId(imageId)
7071
}).lean();
7172
if (!fileInfo) {
72-
return Promise.reject('Image not found');
73+
return Promise.reject(new UserError('Image not found'));
7374
}
7475

7576
const gridBucket = getGridBucket();
@@ -84,7 +85,7 @@ export const getDatasetImageBase64 = async (imageId: string) => {
8485
_id: new Types.ObjectId(imageId)
8586
}).lean();
8687
if (!fileInfo) {
87-
return Promise.reject('Image not found');
88+
return Promise.reject(new UserError('Image not found'));
8889
}
8990

9091
// Get image stream from GridFS

packages/service/core/workflow/dispatch/child/runTool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type RunToolProps = ModuleDispatchProps<{
3434

3535
type RunToolResponse = DispatchNodeResultType<
3636
{
37-
[NodeOutputKeyEnum.rawResponse]?: any;
37+
[NodeOutputKeyEnum.rawResponse]?: any; // MCP Tool
3838
[key: string]: any;
3939
},
4040
Record<string, any>
@@ -197,6 +197,7 @@ export const dispatchRunTool = async (props: RunToolProps): Promise<RunToolRespo
197197

198198
const result = await mcpClient.toolCall(toolName, params);
199199
return {
200+
data: { [NodeOutputKeyEnum.rawResponse]: result },
200201
[DispatchNodeResponseKeyEnum.nodeResponse]: {
201202
toolRes: result,
202203
moduleLogo: avatar

0 commit comments

Comments
 (0)