feat(mcp): add registryUrl to initialState for improved package manag… (#4279)

* feat(mcp): add registryUrl to initialState for improved package management

* feat(mcp): initialize registryUrl in MCP server state for future enhancements

* fix(inputbar):mcp server list

* refactor(Inputbar): remove unused MCP server variable and console log for cleaner code

* fix(Inputbar): 还原

* fix(Inputbar): Add activedMcpServers to Inputbar component props
This commit is contained in:
MyPrototypeWhat 2025-04-03 18:51:29 +08:00 committed by GitHub
parent 06c730aaf6
commit 23de48ecbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 7 deletions

View File

@ -180,15 +180,11 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
if (mentionModels) { if (mentionModels) {
userMessage.mentions = mentionModels userMessage.mentions = mentionModels
} }
if (isFunctionCallingModel(model)) { if (isFunctionCallingModel(model)) {
if (!isEmpty(enabledMCPs) && !isEmpty(activedMcpServers)) { if (!isEmpty(enabledMCPs) && !isEmpty(activedMcpServers)) {
userMessage.enabledMCPs = activedMcpServers.filter((server) => userMessage.enabledMCPs = activedMcpServers.filter((server) => enabledMCPs?.some((s) => s.id === server.id))
enabledMCPs?.some((s) => s.id === server.id)
)
} }
} }
userMessage.usage = await estimateMessageUsage(userMessage) userMessage.usage = await estimateMessageUsage(userMessage)
currentMessageId.current = userMessage.id currentMessageId.current = userMessage.id
@ -208,7 +204,6 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
console.error('Failed to send message:', error) console.error('Failed to send message:', error)
} }
}, [ }, [
activedMcpServers,
assistant, assistant,
dispatch, dispatch,
files, files,
@ -219,7 +214,9 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
resizeTextArea, resizeTextArea,
selectedKnowledgeBases, selectedKnowledgeBases,
text, text,
topic topic,
enabledMCPs,
activedMcpServers
]) ])
const translate = async () => { const translate = async () => {

View File

@ -11,6 +11,7 @@ const initialState: MCPConfig = {
baseUrl: '', baseUrl: '',
command: 'npx', command: 'npx',
args: ['-y', '@mcpmarket/mcp-auto-install', 'connect', '--json'], args: ['-y', '@mcpmarket/mcp-auto-install', 'connect', '--json'],
registryUrl: 'https://registry.npmmirror.com',
env: {}, env: {},
isActive: false isActive: false
} }

View File

@ -245,6 +245,7 @@ export async function callMCPTool(tool: MCPTool): Promise<any> {
command: resp.data.command, command: resp.data.command,
args: resp.data.args, args: resp.data.args,
env: resp.data.env, env: resp.data.env,
registryUrl: '',
isActive: false isActive: false
} }
store.dispatch(addMCPServer(mcpServer)) store.dispatch(addMCPServer(mcpServer))