feat: add active MCP servers filtering to useMCPServers hook and update MCPToolsButton
- Introduced activedMcpServers to filter and expose only active MCP servers in the useMCPServers hook. - Updated MCPToolsButton to utilize activedMcpServers, rendering null if no active servers are present.
This commit is contained in:
parent
b441d76991
commit
295454a85e
@ -12,6 +12,7 @@ ipcRenderer.on('mcp:servers-changed', (_event, servers) => {
|
||||
|
||||
export const useMCPServers = () => {
|
||||
const mcpServers = useAppSelector((state) => state.mcp.servers)
|
||||
const activedMcpServers = useAppSelector((state) => state.mcp.servers?.filter((server) => server.isActive))
|
||||
|
||||
const addMCPServer = async (server: MCPServer) => {
|
||||
try {
|
||||
@ -59,6 +60,7 @@ export const useMCPServers = () => {
|
||||
|
||||
return {
|
||||
mcpServers,
|
||||
activedMcpServers,
|
||||
addMCPServer,
|
||||
updateMCPServer,
|
||||
deleteMCPServer,
|
||||
|
||||
@ -14,7 +14,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const MCPToolsButton: FC<Props> = ({ enabledMCPs, toggelEnableMCP, ToolbarButton }) => {
|
||||
const { mcpServers } = useMCPServers()
|
||||
const { mcpServers, activedMcpServers } = useMCPServers()
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
const dropdownRef = useRef<any>(null)
|
||||
const menuRef = useRef<HTMLDivElement>(null)
|
||||
@ -74,6 +74,10 @@ const MCPToolsButton: FC<Props> = ({ enabledMCPs, toggelEnableMCP, ToolbarButton
|
||||
</div>
|
||||
)
|
||||
|
||||
if (activedMcpServers.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
dropdownRender={() => menu}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user