Skip to content

fix: mcp not response output #5388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/service/common/file/image/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { readFromSecondary } from '../../mongo/utils';
import { addHours } from 'date-fns';
import { imageFileType } from '@fastgpt/global/common/file/constants';
import { retryFn } from '@fastgpt/global/common/system/utils';
import { UserError } from '@fastgpt/global/common/error/utils';

export const maxImgSize = 1024 * 1024 * 12;
const base64MimeRegex = /data:image\/([^\)]+);base64/;
Expand Down Expand Up @@ -105,7 +106,7 @@ export async function readMongoImg({ id }: { id: string }) {
...readFromSecondary
});
if (!data) {
return Promise.reject('Image not found');
return Promise.reject(new UserError('Image not found'));
}

return {
Expand Down
7 changes: 6 additions & 1 deletion packages/service/common/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { proxyError, ERROR_RESPONSE, ERROR_ENUM } from '@fastgpt/global/common/e
import { addLog } from '../system/log';
import { clearCookie } from '../../support/permission/controller';
import { replaceSensitiveText } from '@fastgpt/global/common/string/tools';
import { UserError } from '@fastgpt/global/common/error/utils';

export interface ResponseType<T = any> {
code: number;
Expand Down Expand Up @@ -59,7 +60,11 @@ export const jsonRes = <T = any>(
msg = error?.error?.message;
}

addLog.error(`Api response error: ${url}, ${msg}`, error);
if (error instanceof UserError) {
addLog.info(`Request error: ${url}, ${msg}`);
} else {
addLog.error(`System unexpected error: ${url}, ${msg}`, error);
}
}

res.status(code).json({
Expand Down
5 changes: 3 additions & 2 deletions packages/service/core/dataset/image/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { setCron } from '../../../common/system/cron';
import { checkTimerLock } from '../../../common/system/timerLock/utils';
import { TimerIdEnum } from '../../../common/system/timerLock/constants';
import { addLog } from '../../../common/system/log';
import { UserError } from '@fastgpt/global/common/error/utils';

const getGridBucket = () => {
return new connectionMongo.mongo.GridFSBucket(connectionMongo.connection.db!, {
Expand Down Expand Up @@ -69,7 +70,7 @@ export const getDatasetImageReadData = async (imageId: string) => {
_id: new Types.ObjectId(imageId)
}).lean();
if (!fileInfo) {
return Promise.reject('Image not found');
return Promise.reject(new UserError('Image not found'));
}

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

// Get image stream from GridFS
Expand Down
3 changes: 2 additions & 1 deletion packages/service/core/workflow/dispatch/child/runTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type RunToolProps = ModuleDispatchProps<{

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

const result = await mcpClient.toolCall(toolName, params);
return {
data: { [NodeOutputKeyEnum.rawResponse]: result },
[DispatchNodeResponseKeyEnum.nodeResponse]: {
toolRes: result,
moduleLogo: avatar
Expand Down
Loading