Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
554b2ca8
authored
May 15, 2025
by
Archer
Committed by
GitHub
May 15, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: mcp tool type (#4820)
parent
4e83840c
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
74 additions
and
61 deletions
+74
-61
packages/global/core/app/mcpTools/utils.ts
+4
-4
packages/global/core/app/type.d.ts
+10
-10
packages/global/core/workflow/runtime/type.d.ts
+5
-2
packages/global/core/workflow/type/node.d.ts
+11
-3
packages/service/core/app/mcp.ts
+2
-2
projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
+1
-1
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx
+2
-1
projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx
+4
-4
projects/app/src/pageComponents/app/detail/MCPTools/Edit.tsx
+5
-5
projects/app/src/pageComponents/app/detail/MCPTools/EditForm.tsx
+7
-7
projects/app/src/pageComponents/app/detail/MCPTools/Header.tsx
+2
-2
projects/app/src/pageComponents/app/detail/MCPTools/index.tsx
+5
-3
projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeToolSet.tsx
+3
-2
projects/app/src/pageComponents/dashboard/apps/MCPToolsEditModal.tsx
+3
-5
projects/app/src/pages/api/core/app/mcpTools/create.ts
+2
-2
projects/app/src/pages/api/core/app/mcpTools/update.ts
+2
-2
projects/app/src/pages/api/support/mcp/client/getTools.ts
+2
-2
projects/app/src/pages/dashboard/apps/index.tsx
+1
-1
projects/app/src/pages/dataset/list/index.tsx
+1
-1
projects/app/src/web/core/app/api/plugin.ts
+2
-2
No files found.
packages/global/core/app/mcpTools/utils.ts
View file @
554b2ca8
...
@@ -5,7 +5,7 @@ import {
...
@@ -5,7 +5,7 @@ import {
FlowNodeTypeEnum
FlowNodeTypeEnum
}
from
'../../workflow/node/constant'
;
}
from
'../../workflow/node/constant'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
type
Tool
Type
}
from
'../type'
;
import
{
type
McpToolConfig
Type
}
from
'../type'
;
import
{
i18nT
}
from
'../../../../web/i18n/utils'
;
import
{
i18nT
}
from
'../../../../web/i18n/utils'
;
import
{
type
RuntimeNodeItemType
}
from
'../../workflow/runtime/type'
;
import
{
type
RuntimeNodeItemType
}
from
'../../workflow/runtime/type'
;
...
@@ -16,7 +16,7 @@ export const getMCPToolSetRuntimeNode = ({
...
@@ -16,7 +16,7 @@ export const getMCPToolSetRuntimeNode = ({
avatar
avatar
}:
{
}:
{
url
:
string
;
url
:
string
;
toolList
:
Tool
Type
[];
toolList
:
McpToolConfig
Type
[];
name
?:
string
;
name
?:
string
;
avatar
?:
string
;
avatar
?:
string
;
}):
RuntimeNodeItemType
=>
{
}):
RuntimeNodeItemType
=>
{
...
@@ -45,7 +45,7 @@ export const getMCPToolRuntimeNode = ({
...
@@ -45,7 +45,7 @@ export const getMCPToolRuntimeNode = ({
url
,
url
,
avatar
=
'core/app/type/mcpToolsFill'
avatar
=
'core/app/type/mcpToolsFill'
}:
{
}:
{
tool
:
Tool
Type
;
tool
:
McpToolConfig
Type
;
url
:
string
;
url
:
string
;
avatar
?:
string
;
avatar
?:
string
;
}):
RuntimeNodeItemType
=>
{
}):
RuntimeNodeItemType
=>
{
...
@@ -65,7 +65,7 @@ export const getMCPToolRuntimeNode = ({
...
@@ -65,7 +65,7 @@ export const getMCPToolRuntimeNode = ({
...
Object
.
entries
(
tool
.
inputSchema
?.
properties
||
{}).
map
(([
key
,
value
])
=>
({
...
Object
.
entries
(
tool
.
inputSchema
?.
properties
||
{}).
map
(([
key
,
value
])
=>
({
key
,
key
,
label
:
key
,
label
:
key
,
valueType
:
value
.
type
as
WorkflowIOValueTypeEnum
,
valueType
:
value
.
type
as
WorkflowIOValueTypeEnum
,
// TODO: 这里需要做一个映射
description
:
value
.
description
,
description
:
value
.
description
,
toolDescription
:
value
.
description
||
key
,
toolDescription
:
value
.
description
||
key
,
required
:
tool
.
inputSchema
?.
required
?.
includes
(
key
)
||
false
,
required
:
tool
.
inputSchema
?.
required
?.
includes
(
key
)
||
false
,
...
...
packages/global/core/app/type.d.ts
View file @
554b2ca8
...
@@ -16,16 +16,6 @@ import { FlowNodeInputTypeEnum } from '../../core/workflow/node/constant';
...
@@ -16,16 +16,6 @@ import { FlowNodeInputTypeEnum } from '../../core/workflow/node/constant';
import
type
{
WorkflowTemplateBasicType
}
from
'@fastgpt/global/core/workflow/type'
;
import
type
{
WorkflowTemplateBasicType
}
from
'@fastgpt/global/core/workflow/type'
;
import
type
{
SourceMemberType
}
from
'../../support/user/type'
;
import
type
{
SourceMemberType
}
from
'../../support/user/type'
;
export
type
ToolType
=
{
name
:
string
;
description
:
string
;
inputSchema
:
{
type
:
string
;
properties
?:
Record
<
string
,
{
type
:
string
;
description
?:
string
}
>
;
required
?:
string
[];
};
};
export
type
AppSchema
=
{
export
type
AppSchema
=
{
_id
:
string
;
_id
:
string
;
parentId
?:
ParentIdType
;
parentId
?:
ParentIdType
;
...
@@ -117,6 +107,16 @@ export type AppSimpleEditFormType = {
...
@@ -117,6 +107,16 @@ export type AppSimpleEditFormType = {
chatConfig
:
AppChatConfigType
;
chatConfig
:
AppChatConfigType
;
};
};
export
type
McpToolConfigType
=
{
name
:
string
;
description
:
string
;
inputSchema
:
{
type
:
string
;
properties
?:
Record
<
string
,
{
type
:
string
;
description
?:
string
}
>
;
required
?:
string
[];
};
};
/* app chat config type */
/* app chat config type */
export
type
AppChatConfigType
=
{
export
type
AppChatConfigType
=
{
welcomeText
?:
string
;
welcomeText
?:
string
;
...
...
packages/global/core/workflow/runtime/type.d.ts
View file @
554b2ca8
...
@@ -7,7 +7,7 @@ import type {
...
@@ -7,7 +7,7 @@ import type {
}
from
'../../chat/type'
;
}
from
'../../chat/type'
;
import
{
NodeOutputItemType
}
from
'../../chat/type'
;
import
{
NodeOutputItemType
}
from
'../../chat/type'
;
import
type
{
FlowNodeInputItemType
,
FlowNodeOutputItemType
}
from
'../type/io.d'
;
import
type
{
FlowNodeInputItemType
,
FlowNodeOutputItemType
}
from
'../type/io.d'
;
import
type
{
StoreNodeItemType
}
from
'../type/node'
;
import
type
{
NodeToolConfigType
,
StoreNodeItemType
}
from
'../type/node'
;
import
type
{
DispatchNodeResponseKeyEnum
}
from
'./constants'
;
import
type
{
DispatchNodeResponseKeyEnum
}
from
'./constants'
;
import
type
{
StoreEdgeItemType
}
from
'../type/edge'
;
import
type
{
StoreEdgeItemType
}
from
'../type/edge'
;
import
type
{
NodeInputKeyEnum
}
from
'../constants'
;
import
type
{
NodeInputKeyEnum
}
from
'../constants'
;
...
@@ -102,6 +102,9 @@ export type RuntimeNodeItemType = {
...
@@ -102,6 +102,9 @@ export type RuntimeNodeItemType = {
pluginId
?:
string
;
// workflow id / plugin id
pluginId
?:
string
;
// workflow id / plugin id
version
?:
string
;
version
?:
string
;
// tool
toolConfig
?:
NodeToolConfigType
;
};
};
export
type
RuntimeEdgeItemType
=
StoreEdgeItemType
&
{
export
type
RuntimeEdgeItemType
=
StoreEdgeItemType
&
{
...
@@ -114,7 +117,7 @@ export type DispatchNodeResponseType = {
...
@@ -114,7 +117,7 @@ export type DispatchNodeResponseType = {
runningTime
?:
number
;
runningTime
?:
number
;
query
?:
string
;
query
?:
string
;
textOutput
?:
string
;
textOutput
?:
string
;
error
?:
Record
<
string
,
any
>
;
error
?:
Record
<
string
,
any
>
|
string
;
customInputs
?:
Record
<
string
,
any
>
;
customInputs
?:
Record
<
string
,
any
>
;
customOutputs
?:
Record
<
string
,
any
>
;
customOutputs
?:
Record
<
string
,
any
>
;
nodeInputs
?:
Record
<
string
,
any
>
;
nodeInputs
?:
Record
<
string
,
any
>
;
...
...
packages/global/core/workflow/type/node.d.ts
View file @
554b2ca8
...
@@ -20,11 +20,17 @@ import { RuntimeNodeItemType } from '../runtime/type';
...
@@ -20,11 +20,17 @@ import { RuntimeNodeItemType } from '../runtime/type';
import
{
PluginTypeEnum
}
from
'../../plugin/constants'
;
import
{
PluginTypeEnum
}
from
'../../plugin/constants'
;
import
{
RuntimeEdgeItemType
,
StoreEdgeItemType
}
from
'./edge'
;
import
{
RuntimeEdgeItemType
,
StoreEdgeItemType
}
from
'./edge'
;
import
{
NextApiResponse
}
from
'next'
;
import
{
NextApiResponse
}
from
'next'
;
import
{
AppDetailType
,
AppSchema
}
from
'../../app/type'
;
import
type
{
AppDetailType
,
AppSchema
,
McpToolConfigType
}
from
'../../app/type'
;
import
type
{
ParentIdType
}
from
'common/parentFolder/type'
;
import
type
{
ParentIdType
}
from
'common/parentFolder/type'
;
import
{
AppTypeEnum
}
from
'
core
/app/constants'
;
import
{
AppTypeEnum
}
from
'
../..
/app/constants'
;
import
type
{
WorkflowInteractiveResponseType
}
from
'../template/system/interactive/type'
;
import
type
{
WorkflowInteractiveResponseType
}
from
'../template/system/interactive/type'
;
export
type
NodeToolConfigType
=
{
mcpTool
?:
McpToolConfigType
&
{
url
:
string
;
};
};
export
type
FlowNodeCommonType
=
{
export
type
FlowNodeCommonType
=
{
parentNodeId
?:
string
;
parentNodeId
?:
string
;
flowNodeType
:
FlowNodeTypeEnum
;
// render node card
flowNodeType
:
FlowNodeTypeEnum
;
// render node card
...
@@ -46,8 +52,10 @@ export type FlowNodeCommonType = {
...
@@ -46,8 +52,10 @@ export type FlowNodeCommonType = {
// plugin data
// plugin data
pluginId
?:
string
;
pluginId
?:
string
;
isFolder
?:
boolean
;
isFolder
?:
boolean
;
// pluginType?: AppTypeEnum;
pluginData
?:
PluginDataType
;
pluginData
?:
PluginDataType
;
// tool data
toolData
?:
NodeToolConfigType
;
};
};
export
type
PluginDataType
=
{
export
type
PluginDataType
=
{
...
...
packages/service/core/app/mcp.ts
View file @
554b2ca8
import
{
Client
}
from
'@modelcontextprotocol/sdk/client/index.js'
;
import
{
Client
}
from
'@modelcontextprotocol/sdk/client/index.js'
;
import
{
SSEClientTransport
}
from
'@modelcontextprotocol/sdk/client/sse.js'
;
import
{
SSEClientTransport
}
from
'@modelcontextprotocol/sdk/client/sse.js'
;
import
{
StreamableHTTPClientTransport
}
from
'@modelcontextprotocol/sdk/client/streamableHttp.js'
;
import
{
StreamableHTTPClientTransport
}
from
'@modelcontextprotocol/sdk/client/streamableHttp.js'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
addLog
}
from
'../../common/system/log'
;
import
{
addLog
}
from
'../../common/system/log'
;
import
{
retryFn
}
from
'@fastgpt/global/common/system/utils'
;
import
{
retryFn
}
from
'@fastgpt/global/common/system/utils'
;
...
@@ -41,7 +41,7 @@ export class MCPClient {
...
@@ -41,7 +41,7 @@ export class MCPClient {
* Get available tools list
* Get available tools list
* @returns List of tools
* @returns List of tools
*/
*/
public
async
getTools
():
Promise
<
Tool
Type
[]
>
{
public
async
getTools
():
Promise
<
McpToolConfig
Type
[]
>
{
try
{
try
{
const
client
=
await
this
.
getConnection
();
const
client
=
await
this
.
getConnection
();
const
response
=
await
client
.
listTools
();
const
response
=
await
client
.
listTools
();
...
...
projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx
View file @
554b2ca8
...
@@ -553,7 +553,7 @@ const ChatBox = ({
...
@@ -553,7 +553,7 @@ const ChatBox = ({
const
responseData
=
mergeChatResponseData
(
item
.
responseData
||
[]);
const
responseData
=
mergeChatResponseData
(
item
.
responseData
||
[]);
if
(
responseData
[
responseData
.
length
-
1
]?.
error
)
{
if
(
responseData
[
responseData
.
length
-
1
]?.
error
)
{
toast
({
toast
({
title
:
t
(
responseData
[
responseData
.
length
-
1
].
error
?.
message
),
title
:
t
(
getErrText
(
responseData
[
responseData
.
length
-
1
].
error
)
),
status
:
'error'
status
:
'error'
});
});
}
}
...
...
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/context.tsx
View file @
554b2ca8
...
@@ -22,6 +22,7 @@ import { ChatRecordContext } from '@/web/core/chat/context/chatRecordContext';
...
@@ -22,6 +22,7 @@ import { ChatRecordContext } from '@/web/core/chat/context/chatRecordContext';
import
{
type
AppFileSelectConfigType
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
AppFileSelectConfigType
}
from
'@fastgpt/global/core/app/type'
;
import
{
defaultAppSelectFileConfig
}
from
'@fastgpt/global/core/app/constants'
;
import
{
defaultAppSelectFileConfig
}
from
'@fastgpt/global/core/app/constants'
;
import
{
mergeChatResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
import
{
mergeChatResponseData
}
from
'@fastgpt/global/core/chat/utils'
;
import
{
getErrText
}
from
'@fastgpt/global/common/error/utils'
;
type
PluginRunContextType
=
PluginRunBoxProps
&
{
type
PluginRunContextType
=
PluginRunBoxProps
&
{
isChatting
:
boolean
;
isChatting
:
boolean
;
...
@@ -258,7 +259,7 @@ const PluginRunContextProvider = ({
...
@@ -258,7 +259,7 @@ const PluginRunContextProvider = ({
const
responseData
=
mergeChatResponseData
(
item
.
responseData
||
[]);
const
responseData
=
mergeChatResponseData
(
item
.
responseData
||
[]);
if
(
responseData
[
responseData
.
length
-
1
]?.
error
)
{
if
(
responseData
[
responseData
.
length
-
1
]?.
error
)
{
toast
({
toast
({
title
:
t
(
responseData
[
responseData
.
length
-
1
].
error
?.
message
),
title
:
t
(
getErrText
(
responseData
[
responseData
.
length
-
1
].
error
)
),
status
:
'error'
status
:
'error'
});
});
}
}
...
...
projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx
View file @
554b2ca8
...
@@ -7,7 +7,7 @@ import ChatRecordContextProvider from '@/web/core/chat/context/chatRecordContext
...
@@ -7,7 +7,7 @@ import ChatRecordContextProvider from '@/web/core/chat/context/chatRecordContext
import
{
Box
,
Button
,
Flex
,
Switch
,
Textarea
}
from
'@chakra-ui/react'
;
import
{
Box
,
Button
,
Flex
,
Switch
,
Textarea
}
from
'@chakra-ui/react'
;
import
{
cardStyles
}
from
'../constants'
;
import
{
cardStyles
}
from
'../constants'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
FormLabel
from
'@fastgpt/web/components/common/MyBox/FormLabel'
;
import
FormLabel
from
'@fastgpt/web/components/common/MyBox/FormLabel'
;
import
QuestionTip
from
'@fastgpt/web/components/common/MyTooltip/QuestionTip'
;
import
QuestionTip
from
'@fastgpt/web/components/common/MyTooltip/QuestionTip'
;
import
{
Controller
,
useForm
}
from
'react-hook-form'
;
import
{
Controller
,
useForm
}
from
'react-hook-form'
;
...
@@ -19,7 +19,7 @@ import { postRunMCPTool } from '@/web/core/app/api/plugin';
...
@@ -19,7 +19,7 @@ import { postRunMCPTool } from '@/web/core/app/api/plugin';
const
JsonEditor
=
dynamic
(()
=>
import
(
'@fastgpt/web/components/common/Textarea/JsonEditor'
));
const
JsonEditor
=
dynamic
(()
=>
import
(
'@fastgpt/web/components/common/Textarea/JsonEditor'
));
const
ChatTest
=
({
currentTool
,
url
}:
{
currentTool
:
Tool
Type
|
null
;
url
:
string
})
=>
{
const
ChatTest
=
({
currentTool
,
url
}:
{
currentTool
:
McpToolConfig
Type
|
null
;
url
:
string
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
[
output
,
setOutput
]
=
useState
<
string
>
(
''
);
const
[
output
,
setOutput
]
=
useState
<
string
>
(
''
);
...
@@ -135,7 +135,7 @@ const ChatTest = ({ currentTool, url }: { currentTool: ToolType | null; url: str
...
@@ -135,7 +135,7 @@ const ChatTest = ({ currentTool, url }: { currentTool: ToolType | null; url: str
);
);
};
};
const
Render
=
({
currentTool
,
url
}:
{
currentTool
:
Tool
Type
|
null
;
url
:
string
})
=>
{
const
Render
=
({
currentTool
,
url
}:
{
currentTool
:
McpToolConfig
Type
|
null
;
url
:
string
})
=>
{
const
{
chatId
}
=
useChatStore
();
const
{
chatId
}
=
useChatStore
();
const
{
appDetail
}
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
);
const
{
appDetail
}
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
);
...
@@ -178,7 +178,7 @@ const RenderToolInput = ({
...
@@ -178,7 +178,7 @@ const RenderToolInput = ({
type
:
string
;
type
:
string
;
description
?:
string
;
description
?:
string
;
};
};
toolData
:
Tool
Type
|
null
;
toolData
:
McpToolConfig
Type
|
null
;
value
:
any
;
value
:
any
;
onChange
:
(
value
:
any
)
=>
void
;
onChange
:
(
value
:
any
)
=>
void
;
isInvalid
:
boolean
;
isInvalid
:
boolean
;
...
...
projects/app/src/pageComponents/app/detail/MCPTools/Edit.tsx
View file @
554b2ca8
...
@@ -7,7 +7,7 @@ import AppCard from './AppCard';
...
@@ -7,7 +7,7 @@ import AppCard from './AppCard';
import
ChatTest
from
'./ChatTest'
;
import
ChatTest
from
'./ChatTest'
;
import
MyBox
from
'@fastgpt/web/components/common/MyBox'
;
import
MyBox
from
'@fastgpt/web/components/common/MyBox'
;
import
EditForm
from
'./EditForm'
;
import
EditForm
from
'./EditForm'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
const
Edit
=
({
const
Edit
=
({
url
,
url
,
...
@@ -19,10 +19,10 @@ const Edit = ({
...
@@ -19,10 +19,10 @@ const Edit = ({
}:
{
}:
{
url
:
string
;
url
:
string
;
setUrl
:
(
url
:
string
)
=>
void
;
setUrl
:
(
url
:
string
)
=>
void
;
toolList
:
Tool
Type
[];
toolList
:
McpToolConfig
Type
[];
setToolList
:
(
toolList
:
Tool
Type
[])
=>
void
;
setToolList
:
(
toolList
:
McpToolConfig
Type
[])
=>
void
;
currentTool
:
Tool
Type
|
null
;
currentTool
:
McpToolConfig
Type
|
null
;
setCurrentTool
:
(
tool
:
Tool
Type
)
=>
void
;
setCurrentTool
:
(
tool
:
McpToolConfig
Type
)
=>
void
;
})
=>
{
})
=>
{
const
{
isPc
}
=
useSystem
();
const
{
isPc
}
=
useSystem
();
...
...
projects/app/src/pageComponents/app/detail/MCPTools/EditForm.tsx
View file @
554b2ca8
...
@@ -7,7 +7,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
...
@@ -7,7 +7,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import
{
AppContext
}
from
'../context'
;
import
{
AppContext
}
from
'../context'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
MyIconButton
from
'@fastgpt/web/components/common/Icon/button'
;
import
MyIconButton
from
'@fastgpt/web/components/common/Icon/button'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
MyModal
from
'@fastgpt/web/components/common/MyModal'
;
import
MyModal
from
'@fastgpt/web/components/common/MyModal'
;
import
Avatar
from
'@fastgpt/web/components/common/Avatar'
;
import
Avatar
from
'@fastgpt/web/components/common/Avatar'
;
import
MyBox
from
'@fastgpt/web/components/common/MyBox'
;
import
MyBox
from
'@fastgpt/web/components/common/MyBox'
;
...
@@ -24,14 +24,14 @@ const EditForm = ({
...
@@ -24,14 +24,14 @@ const EditForm = ({
}:
{
}:
{
url
:
string
;
url
:
string
;
setUrl
:
(
url
:
string
)
=>
void
;
setUrl
:
(
url
:
string
)
=>
void
;
toolList
:
Tool
Type
[];
toolList
:
McpToolConfig
Type
[];
setToolList
:
(
toolList
:
Tool
Type
[])
=>
void
;
setToolList
:
(
toolList
:
McpToolConfig
Type
[])
=>
void
;
currentTool
:
Tool
Type
|
null
;
currentTool
:
McpToolConfig
Type
|
null
;
setCurrentTool
:
(
tool
:
Tool
Type
)
=>
void
;
setCurrentTool
:
(
tool
:
McpToolConfig
Type
)
=>
void
;
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
[
toolDetail
,
setToolDetail
]
=
useState
<
Tool
Type
|
null
>
(
null
);
const
[
toolDetail
,
setToolDetail
]
=
useState
<
McpToolConfig
Type
|
null
>
(
null
);
const
{
runAsync
:
runGetMCPTools
,
loading
:
isGettingTools
}
=
useRequest2
(
const
{
runAsync
:
runGetMCPTools
,
loading
:
isGettingTools
}
=
useRequest2
(
async
(
data
:
getMCPToolsBody
)
=>
await
getMCPTools
(
data
),
async
(
data
:
getMCPToolsBody
)
=>
await
getMCPTools
(
data
),
...
@@ -180,7 +180,7 @@ const EditForm = ({
...
@@ -180,7 +180,7 @@ const EditForm = ({
export
default
React
.
memo
(
EditForm
);
export
default
React
.
memo
(
EditForm
);
const
ToolDetailModal
=
({
tool
,
onClose
}:
{
tool
:
Tool
Type
;
onClose
:
()
=>
void
})
=>
{
const
ToolDetailModal
=
({
tool
,
onClose
}:
{
tool
:
McpToolConfig
Type
;
onClose
:
()
=>
void
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
appDetail
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
.
appDetail
);
const
appDetail
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
.
appDetail
);
...
...
projects/app/src/pageComponents/app/detail/MCPTools/Header.tsx
View file @
554b2ca8
...
@@ -8,10 +8,10 @@ import { getAppFolderPath } from '@/web/core/app/api/app';
...
@@ -8,10 +8,10 @@ import { getAppFolderPath } from '@/web/core/app/api/app';
import
{
useCallback
}
from
'react'
;
import
{
useCallback
}
from
'react'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
postUpdateMCPTools
}
from
'@/web/core/app/api/plugin'
;
import
{
postUpdateMCPTools
}
from
'@/web/core/app/api/plugin'
;
const
Header
=
({
url
,
toolList
}:
{
url
:
string
;
toolList
:
Tool
Type
[]
})
=>
{
const
Header
=
({
url
,
toolList
}:
{
url
:
string
;
toolList
:
McpToolConfig
Type
[]
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
appId
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
.
appId
);
const
appId
=
useContextSelector
(
AppContext
,
(
v
)
=>
v
.
appId
);
const
router
=
useRouter
();
const
router
=
useRouter
();
...
...
projects/app/src/pageComponents/app/detail/MCPTools/index.tsx
View file @
554b2ca8
...
@@ -5,7 +5,7 @@ import Edit from './Edit';
...
@@ -5,7 +5,7 @@ import Edit from './Edit';
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
AppContext
}
from
'../context'
;
import
{
AppContext
}
from
'../context'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
MCPToolSetData
}
from
'@/pageComponents/dashboard/apps/MCPToolsEditModal'
;
import
{
type
MCPToolSetData
}
from
'@/pageComponents/dashboard/apps/MCPToolsEditModal'
;
const
MCPTools
=
()
=>
{
const
MCPTools
=
()
=>
{
...
@@ -18,8 +18,10 @@ const MCPTools = () => {
...
@@ -18,8 +18,10 @@ const MCPTools = () => {
},
[
appDetail
.
modules
]);
},
[
appDetail
.
modules
]);
const
[
url
,
setUrl
]
=
useState
(
toolSetData
?.
url
||
''
);
const
[
url
,
setUrl
]
=
useState
(
toolSetData
?.
url
||
''
);
const
[
toolList
,
setToolList
]
=
useState
<
ToolType
[]
>
(
toolSetData
?.
toolList
||
[]);
const
[
toolList
,
setToolList
]
=
useState
<
McpToolConfigType
[]
>
(
toolSetData
?.
toolList
||
[]);
const
[
currentTool
,
setCurrentTool
]
=
useState
<
ToolType
|
null
>
(
toolSetData
?.
toolList
[
0
]
||
null
);
const
[
currentTool
,
setCurrentTool
]
=
useState
<
McpToolConfigType
|
null
>
(
toolSetData
?.
toolList
[
0
]
||
null
);
return
(
return
(
<
Flex
h=
{
'100%'
}
flexDirection=
{
'column'
}
px=
{
[
3
,
0
]
}
pr=
{
[
3
,
3
]
}
>
<
Flex
h=
{
'100%'
}
flexDirection=
{
'column'
}
px=
{
[
3
,
0
]
}
pr=
{
[
3
,
3
]
}
>
...
...
projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeToolSet.tsx
View file @
554b2ca8
...
@@ -5,14 +5,15 @@ import NodeCard from './render/NodeCard';
...
@@ -5,14 +5,15 @@ import NodeCard from './render/NodeCard';
import
IOTitle
from
'../components/IOTitle'
;
import
IOTitle
from
'../components/IOTitle'
;
import
Container
from
'../components/Container'
;
import
Container
from
'../components/Container'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
Box
,
Flex
}
from
'@chakra-ui/react'
;
import
{
Box
,
Flex
}
from
'@chakra-ui/react'
;
const
NodeToolSet
=
({
data
,
selected
}:
NodeProps
<
FlowNodeItemType
>
)
=>
{
const
NodeToolSet
=
({
data
,
selected
}:
NodeProps
<
FlowNodeItemType
>
)
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
{
inputs
}
=
data
;
const
{
inputs
}
=
data
;
const
toolList
:
ToolType
[]
=
inputs
.
find
((
item
)
=>
item
.
key
===
'toolSetData'
)?.
value
?.
toolList
;
const
toolList
:
McpToolConfigType
[]
=
inputs
.
find
((
item
)
=>
item
.
key
===
'toolSetData'
)?.
value
?.
toolList
;
return
(
return
(
<
NodeCard
minW=
{
'350px'
}
selected=
{
selected
}
{
...
data
}
>
<
NodeCard
minW=
{
'350px'
}
selected=
{
selected
}
{
...
data
}
>
...
...
projects/app/src/pageComponents/dashboard/apps/MCPToolsEditModal.tsx
View file @
554b2ca8
...
@@ -20,17 +20,16 @@ import Avatar from '@fastgpt/web/components/common/Avatar';
...
@@ -20,17 +20,16 @@ import Avatar from '@fastgpt/web/components/common/Avatar';
import
MyModal
from
'@fastgpt/web/components/common/MyModal'
;
import
MyModal
from
'@fastgpt/web/components/common/MyModal'
;
import
MyTooltip
from
'@fastgpt/web/components/common/MyTooltip'
;
import
MyTooltip
from
'@fastgpt/web/components/common/MyTooltip'
;
import
{
useRequest2
}
from
'@fastgpt/web/hooks/useRequest'
;
import
{
useRequest2
}
from
'@fastgpt/web/hooks/useRequest'
;
import
{
useToast
}
from
'@fastgpt/web/hooks/useToast'
;
import
{
useForm
}
from
'react-hook-form'
;
import
{
useForm
}
from
'react-hook-form'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
AppListContext
}
from
'./context'
;
import
{
AppListContext
}
from
'./context'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
type
{
getMCPToolsBody
}
from
'@/pages/api/support/mcp/client/getTools'
;
import
type
{
getMCPToolsBody
}
from
'@/pages/api/support/mcp/client/getTools'
;
export
type
MCPToolSetData
=
{
export
type
MCPToolSetData
=
{
url
:
string
;
url
:
string
;
toolList
:
Tool
Type
[];
toolList
:
McpToolConfig
Type
[];
};
};
export
type
EditMCPToolsProps
=
{
export
type
EditMCPToolsProps
=
{
...
@@ -41,7 +40,6 @@ export type EditMCPToolsProps = {
...
@@ -41,7 +40,6 @@ export type EditMCPToolsProps = {
const
MCPToolsEditModal
=
({
onClose
}:
{
onClose
:
()
=>
void
})
=>
{
const
MCPToolsEditModal
=
({
onClose
}:
{
onClose
:
()
=>
void
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
{
toast
}
=
useToast
();
const
{
parentId
,
loadMyApps
}
=
useContextSelector
(
AppListContext
,
(
v
)
=>
v
);
const
{
parentId
,
loadMyApps
}
=
useContextSelector
(
AppListContext
,
(
v
)
=>
v
);
...
@@ -81,7 +79,7 @@ const MCPToolsEditModal = ({ onClose }: { onClose: () => void }) => {
...
@@ -81,7 +79,7 @@ const MCPToolsEditModal = ({ onClose }: { onClose: () => void }) => {
const
{
runAsync
:
runGetMCPTools
,
loading
:
isGettingTools
}
=
useRequest2
(
const
{
runAsync
:
runGetMCPTools
,
loading
:
isGettingTools
}
=
useRequest2
(
(
data
:
getMCPToolsBody
)
=>
getMCPTools
(
data
),
(
data
:
getMCPToolsBody
)
=>
getMCPTools
(
data
),
{
{
onSuccess
:
(
res
:
Tool
Type
[])
=>
{
onSuccess
:
(
res
:
McpToolConfig
Type
[])
=>
{
setValue
(
'mcpData.toolList'
,
res
);
setValue
(
'mcpData.toolList'
,
res
);
},
},
errorToast
:
t
(
'app:MCP_tools_parse_failed'
)
errorToast
:
t
(
'app:MCP_tools_parse_failed'
)
...
...
projects/app/src/pages/api/core/app/mcpTools/create.ts
View file @
554b2ca8
...
@@ -4,7 +4,7 @@ import { TeamAppCreatePermissionVal } from '@fastgpt/global/support/permission/u
...
@@ -4,7 +4,7 @@ import { TeamAppCreatePermissionVal } from '@fastgpt/global/support/permission/u
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
authUserPer
}
from
'@fastgpt/service/support/permission/user/auth'
;
import
{
authUserPer
}
from
'@fastgpt/service/support/permission/user/auth'
;
import
{
type
CreateAppBody
,
onCreateApp
}
from
'../create'
;
import
{
type
CreateAppBody
,
onCreateApp
}
from
'../create'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
mongoSessionRun
}
from
'@fastgpt/service/common/mongo/sessionRun'
;
import
{
mongoSessionRun
}
from
'@fastgpt/service/common/mongo/sessionRun'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
import
{
AppTypeEnum
}
from
'@fastgpt/global/core/app/constants'
;
import
{
import
{
...
@@ -22,7 +22,7 @@ export type createMCPToolsBody = Omit<
...
@@ -22,7 +22,7 @@ export type createMCPToolsBody = Omit<
'type'
|
'modules'
|
'edges'
|
'chatConfig'
'type'
|
'modules'
|
'edges'
|
'chatConfig'
>
&
{
>
&
{
url
:
string
;
url
:
string
;
toolList
:
Tool
Type
[];
toolList
:
McpToolConfig
Type
[];
};
};
export
type
createMCPToolsResponse
=
{};
export
type
createMCPToolsResponse
=
{};
...
...
projects/app/src/pages/api/core/app/mcpTools/update.ts
View file @
554b2ca8
import
type
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
type
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
type
AppDetailType
,
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
AppDetailType
,
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
authApp
}
from
'@fastgpt/service/support/permission/app/auth'
;
import
{
ManagePermissionVal
}
from
'@fastgpt/global/support/permission/constant'
;
import
{
ManagePermissionVal
}
from
'@fastgpt/global/support/permission/constant'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
import
{
FlowNodeTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
...
@@ -24,7 +24,7 @@ export type updateMCPToolsQuery = {};
...
@@ -24,7 +24,7 @@ export type updateMCPToolsQuery = {};
export
type
updateMCPToolsBody
=
{
export
type
updateMCPToolsBody
=
{
appId
:
string
;
appId
:
string
;
url
:
string
;
url
:
string
;
toolList
:
Tool
Type
[];
toolList
:
McpToolConfig
Type
[];
};
};
export
type
updateMCPToolsResponse
=
{};
export
type
updateMCPToolsResponse
=
{};
...
...
projects/app/src/pages/api/support/mcp/client/getTools.ts
View file @
554b2ca8
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
NextAPI
}
from
'@/service/middleware/entry'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
type
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
type
{
ApiRequestProps
,
ApiResponseType
}
from
'@fastgpt/service/type/next'
;
import
{
MCPClient
}
from
'@fastgpt/service/core/app/mcp'
;
import
{
MCPClient
}
from
'@fastgpt/service/core/app/mcp'
;
...
@@ -7,7 +7,7 @@ export type getMCPToolsQuery = {};
...
@@ -7,7 +7,7 @@ export type getMCPToolsQuery = {};
export
type
getMCPToolsBody
=
{
url
:
string
};
export
type
getMCPToolsBody
=
{
url
:
string
};
export
type
getMCPToolsResponse
=
Tool
Type
[];
export
type
getMCPToolsResponse
=
McpToolConfig
Type
[];
async
function
handler
(
async
function
handler
(
req
:
ApiRequestProps
<
getMCPToolsBody
,
getMCPToolsQuery
>
,
req
:
ApiRequestProps
<
getMCPToolsBody
,
getMCPToolsQuery
>
,
...
...
projects/app/src/pages/dashboard/apps/index.tsx
View file @
554b2ca8
...
@@ -262,7 +262,7 @@ const MyApps = ({ MenuIcon }: { MenuIcon: JSX.Element }) => {
...
@@ -262,7 +262,7 @@ const MyApps = ({ MenuIcon }: { MenuIcon: JSX.Element }) => {
{
/* Folder slider */
}
{
/* Folder slider */
}
{
!!
folderDetail
&&
isPc
&&
(
{
!!
folderDetail
&&
isPc
&&
(
<
Box
pt=
{
[
4
,
6
]
}
pr=
{
[
4
,
6
]
}
>
<
Box
pt=
{
[
4
,
6
]
}
pr=
{
[
4
,
6
]
}
h=
{
'100%'
}
pb=
{
4
}
overflow=
{
'auto'
}
>
<
FolderSlideCard
<
FolderSlideCard
refetchResource=
{
()
=>
Promise
.
all
([
refetchFolderDetail
(),
loadMyApps
()])
}
refetchResource=
{
()
=>
Promise
.
all
([
refetchFolderDetail
(),
loadMyApps
()])
}
resumeInheritPermission=
{
()
=>
resumeInheritPer
(
folderDetail
.
_id
)
}
resumeInheritPermission=
{
()
=>
resumeInheritPer
(
folderDetail
.
_id
)
}
...
...
projects/app/src/pages/dataset/list/index.tsx
View file @
554b2ca8
...
@@ -223,7 +223,7 @@ const Dataset = () => {
...
@@ -223,7 +223,7 @@ const Dataset = () => {
</
Flex
>
</
Flex
>
{
!!
folderDetail
&&
isPc
&&
(
{
!!
folderDetail
&&
isPc
&&
(
<
Box
ml=
"6"
>
<
Box
ml=
"6"
h=
{
'100%'
}
pb=
{
4
}
overflow=
{
'auto'
}
>
<
FolderSlideCard
<
FolderSlideCard
resumeInheritPermission=
{
()
=>
resumeInheritPer
(
folderDetail
.
_id
)
}
resumeInheritPermission=
{
()
=>
resumeInheritPer
(
folderDetail
.
_id
)
}
isInheritPermission=
{
folderDetail
.
inheritPermission
}
isInheritPermission=
{
folderDetail
.
inheritPermission
}
...
...
projects/app/src/web/core/app/api/plugin.ts
View file @
554b2ca8
...
@@ -20,7 +20,7 @@ import type { PluginGroupSchemaType } from '@fastgpt/service/core/app/plugin/typ
...
@@ -20,7 +20,7 @@ import type { PluginGroupSchemaType } from '@fastgpt/service/core/app/plugin/typ
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
defaultGroup
}
from
'@fastgpt/web/core/workflow/constants'
;
import
{
defaultGroup
}
from
'@fastgpt/web/core/workflow/constants'
;
import
type
{
createMCPToolsBody
}
from
'@/pages/api/core/app/mcpTools/create'
;
import
type
{
createMCPToolsBody
}
from
'@/pages/api/core/app/mcpTools/create'
;
import
{
type
Tool
Type
}
from
'@fastgpt/global/core/app/type'
;
import
{
type
McpToolConfig
Type
}
from
'@fastgpt/global/core/app/type'
;
import
type
{
updateMCPToolsBody
}
from
'@/pages/api/core/app/mcpTools/update'
;
import
type
{
updateMCPToolsBody
}
from
'@/pages/api/core/app/mcpTools/update'
;
import
type
{
RunMCPToolBody
}
from
'@/pages/api/support/mcp/client/runTool'
;
import
type
{
RunMCPToolBody
}
from
'@/pages/api/support/mcp/client/runTool'
;
import
type
{
getMCPToolsBody
}
from
'@/pages/api/support/mcp/client/getTools'
;
import
type
{
getMCPToolsBody
}
from
'@/pages/api/support/mcp/client/getTools'
;
...
@@ -79,7 +79,7 @@ export const postUpdateMCPTools = (data: updateMCPToolsBody) =>
...
@@ -79,7 +79,7 @@ export const postUpdateMCPTools = (data: updateMCPToolsBody) =>
POST
(
'/core/app/mcpTools/update'
,
data
);
POST
(
'/core/app/mcpTools/update'
,
data
);
export
const
getMCPTools
=
(
data
:
getMCPToolsBody
)
=>
export
const
getMCPTools
=
(
data
:
getMCPToolsBody
)
=>
POST
<
Tool
Type
[]
>
(
'/support/mcp/client/getTools'
,
data
);
POST
<
McpToolConfig
Type
[]
>
(
'/support/mcp/client/getTools'
,
data
);
export
const
postRunMCPTool
=
(
data
:
RunMCPToolBody
)
=>
POST
(
'/support/mcp/client/runTool'
,
data
);
export
const
postRunMCPTool
=
(
data
:
RunMCPToolBody
)
=>
POST
(
'/support/mcp/client/runTool'
,
data
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment