Mcp db fix (#5096)

* fix: correct input schema property name in getTools method

* fix: refactor schema definitions for AppSchema and AppVersionSchema
This commit is contained in:
Theresa
2025-06-26 12:59:34 +08:00
committed by GitHub
parent 626055836f
commit 25c00cdef6
2 changed files with 129 additions and 119 deletions

View File

@@ -22,102 +22,107 @@ export const chatConfigType = {
}; };
// schema // schema
const AppSchema = new Schema({ const AppSchema = new Schema(
parentId: { {
type: Schema.Types.ObjectId, parentId: {
ref: AppCollectionName, type: Schema.Types.ObjectId,
default: null ref: AppCollectionName,
}, default: null
teamId: { },
type: Schema.Types.ObjectId, teamId: {
ref: TeamCollectionName, type: Schema.Types.ObjectId,
required: true ref: TeamCollectionName,
}, required: true
tmbId: { },
type: Schema.Types.ObjectId, tmbId: {
ref: TeamMemberCollectionName, type: Schema.Types.ObjectId,
required: true ref: TeamMemberCollectionName,
}, required: true
name: { },
type: String, name: {
required: true type: String,
}, required: true
type: { },
type: String,
default: AppTypeEnum.workflow,
enum: Object.values(AppTypeEnum)
},
version: {
type: String,
enum: ['v1', 'v2']
},
avatar: {
type: String,
default: '/icon/logo.svg'
},
intro: {
type: String,
default: ''
},
updateTime: {
type: Date,
default: () => new Date()
},
// role and auth
teamTags: {
type: [String]
},
// save app(Not publish)
modules: {
type: Array,
default: []
},
edges: {
type: Array,
default: []
},
chatConfig: {
type: chatConfigType
},
// plugin config
pluginData: {
type: { type: {
nodeVersion: String, type: String,
pluginUniId: String, default: AppTypeEnum.workflow,
apiSchemaStr: String, // http plugin enum: Object.values(AppTypeEnum)
customHeaders: String // http plugin
}
},
scheduledTriggerConfig: {
cronString: {
type: String
}, },
timezone: { version: {
type: String type: String,
enum: ['v1', 'v2']
},
avatar: {
type: String,
default: '/icon/logo.svg'
},
intro: {
type: String,
default: ''
}, },
defaultPrompt: {
type: String
}
},
scheduledTriggerNextTime: {
type: Date
},
inited: { updateTime: {
type: Boolean type: Date,
}, default: () => new Date()
inheritPermission: { },
type: Boolean,
default: true
},
// abandoned // role and auth
defaultPermission: Number teamTags: {
}); type: [String]
},
// save app(Not publish)
modules: {
type: Array,
default: []
},
edges: {
type: Array,
default: []
},
chatConfig: {
type: chatConfigType
},
// plugin config
pluginData: {
type: {
nodeVersion: String,
pluginUniId: String,
apiSchemaStr: String, // http plugin
customHeaders: String // http plugin
}
},
scheduledTriggerConfig: {
cronString: {
type: String
},
timezone: {
type: String
},
defaultPrompt: {
type: String
}
},
scheduledTriggerNextTime: {
type: Date
},
inited: {
type: Boolean
},
inheritPermission: {
type: Boolean,
default: true
},
// abandoned
defaultPermission: Number
},
{
minimize: false
}
);
AppSchema.index({ type: 1 }); AppSchema.index({ type: 1 });
AppSchema.index({ teamId: 1, updateTime: -1 }); AppSchema.index({ teamId: 1, updateTime: -1 });

View File

@@ -6,35 +6,40 @@ import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/cons
export const AppVersionCollectionName = 'app_versions'; export const AppVersionCollectionName = 'app_versions';
const AppVersionSchema = new Schema({ const AppVersionSchema = new Schema(
tmbId: { {
type: String, tmbId: {
ref: TeamMemberCollectionName, type: String,
required: true ref: TeamMemberCollectionName,
required: true
},
appId: {
type: Schema.Types.ObjectId,
ref: AppVersionCollectionName,
required: true
},
time: {
type: Date,
default: () => new Date()
},
nodes: {
type: Array,
default: []
},
edges: {
type: Array,
default: []
},
chatConfig: {
type: chatConfigType
},
isPublish: Boolean,
versionName: String
}, },
appId: { {
type: Schema.Types.ObjectId, minimize: false
ref: AppVersionCollectionName, }
required: true );
},
time: {
type: Date,
default: () => new Date()
},
nodes: {
type: Array,
default: []
},
edges: {
type: Array,
default: []
},
chatConfig: {
type: chatConfigType
},
isPublish: Boolean,
versionName: String
});
try { try {
AppVersionSchema.index({ appId: 1, time: -1 }); AppVersionSchema.index({ appId: 1, time: -1 });