diff --git a/gui/src/pages/config/sections/McpSection.tsx b/gui/src/pages/config/sections/McpSection.tsx deleted file mode 100644 index c24a9dbf4..000000000 --- a/gui/src/pages/config/sections/McpSection.tsx +++ /dev/null @@ -1,379 +0,0 @@ -import { ConfigYaml, parseConfigYaml } from "@continuedev/config-yaml"; -import { - ArrowPathIcon, - ChevronDownIcon, - CircleStackIcon, - CommandLineIcon, - GlobeAltIcon, - UserCircleIcon, - WrenchScrewdriverIcon, -} from "@heroicons/react/24/outline"; -import { MCPServerStatus } from "core"; -import { useContext, useMemo, useState } from "react"; -import { ToolTip } from "../../../components/gui/Tooltip"; -import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton"; -import { Button, Card } from "../../../components/ui"; -import { useAuth } from "../../../context/Auth"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { updateConfig } from "../../../redux/slices/configSlice"; -import { selectCurrentOrg } from "../../../redux/slices/profilesSlice"; -import { ConfigHeader } from "../components/ConfigHeader"; - -interface MCPServerStatusProps { - server: MCPServerStatus; - serverFromYaml?: NonNullable[number]; -} -function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) { - const [isExpanded, setIsExpanded] = useState(false); - const ideMessenger = useContext(IdeMessengerContext); - const config = useAppSelector((store) => store.config.config); - const dispatch = useAppDispatch(); - - const updateMCPServerStatus = (status: MCPServerStatus["status"]) => { - // optimistic config update - dispatch( - updateConfig({ - ...config, - mcpServerStatuses: config.mcpServerStatuses.map((s) => - s.id === server.id - ? { - ...s, - status, - } - : s, - ), - }), - ); - }; - - const onAuthenticate = async () => { - updateMCPServerStatus("authenticating"); - await ideMessenger.request("mcp/startAuthentication", server); - }; - - const onRemoveAuth = async () => { - updateMCPServerStatus("authenticating"); - await ideMessenger.request("mcp/removeAuthentication", server); - }; - - const onRefresh = async () => { - updateMCPServerStatus("connecting"); - ideMessenger.post("mcp/reloadServer", { - id: server.id, - }); - }; - - const handleToggleExpanded = (e: React.MouseEvent) => { - // Don't expand if clicking on buttons - if ((e.target as HTMLElement).closest("button")) { - return; - } - setIsExpanded(!isExpanded); - }; - - return ( -
-
-
- -
-

0 ? "text-error" : ""}`} - > - {server.name} -

-
-
- -
- {server.isProtectedResource && ( - - - - )} - - - - - - - -
-
-
- - {isExpanded && server.status === "connected" && ( -
- {/* Tools, Prompts, Resources with counts */} -
- - {server.tools.map((tool, idx) => ( -
-
- {tool.name} - {tool.description && ( - - {tool.description} - - )} - {tool.inputSchema?.properties && - Object.keys(tool.inputSchema.properties).length > - 0 && ( -
- - Args: - -
- {Object.entries( - tool.inputSchema.properties, - ).map(([paramName, paramSchema], paramIdx) => ( -
- - {paramName} - - {paramSchema && - typeof paramSchema === "object" && - "type" in paramSchema && ( - - ({paramSchema.type}) - - )} -
- ))} -
-
- )} -
- {idx < server.tools.length - 1 && ( -
- )} -
- ))} - {server.tools.length === 0 && ( - No tools - )} - - } - > -
- - Tools: {server.tools.length} -
-
- - - {server.prompts.map((prompt, idx) => ( - {prompt.name} - ))} - {server.prompts.length === 0 && ( - No prompts - )} - - } - > -
- - - Prompts: {server.prompts.length} - -
-
- - - {[...server.resources, ...server.resourceTemplates].map( - (resource, idx) => ( - {resource.name} - ), - )} - {server.resources.length === 0 && ( - No resources - )} - - } - > -
- - - Resources:{" "} - {server.resources.length + server.resourceTemplates.length} - -
-
-
-
- )} - - {/* Error display below expandable section */} - {server.errors && server.errors.length > 0 && ( -
- {server.errors.map((error, errorIndex) => ( -
-
- - {error.length > 150 ? error.substring(0, 150) + "..." : error} - - {error.length > 150 && ( - - )} -
-
- ))} -
- )} -
- ); -} - -function McpSection() { - const currentOrg = useAppSelector(selectCurrentOrg); - const servers = useAppSelector( - (store) => store.config.config.mcpServerStatuses, - ); - const { selectedProfile } = useAuth(); - const ideMessenger = useContext(IdeMessengerContext); - const disableMcp = currentOrg?.policy?.allowMcpServers === false; - const isLocal = selectedProfile?.profileType === "local"; - - const mergedBlocks = useMemo(() => { - const parsed = selectedProfile?.rawYaml - ? parseConfigYaml(selectedProfile?.rawYaml ?? "") - : undefined; - return (servers ?? []).map((doc, index) => ({ - block: doc, - blockFromYaml: parsed?.mcpServers?.[index], - })); - }, [servers, selectedProfile]); - - const handleAddMcpServer = () => { - if (isLocal) { - void ideMessenger.request("config/addLocalWorkspaceBlock", { - blockType: "mcpServers", - }); - } else { - void ideMessenger.request("controlPlane/openUrl", { - path: "new?type=block&blockType=mcpServers", - orgSlug: undefined, - }); - } - }; - - if (disableMcp) { - return ( -
- - MCP servers are disabled in your organization - -
- ); - } - - return ( -
- - -
- {mergedBlocks && mergedBlocks.length > 0 ? ( - mergedBlocks.map(({ block, blockFromYaml }, index) => ( -
- - - - {index < mergedBlocks.length - 1 &&
} -
- )) - ) : ( - -
- - No MCP servers configured. Click the + button to add your first - server. - -
-
- )} -
-
- ); -} - -export { McpSection };