import { Anchor, Group, List, Text, Switch, TextInput, ActionIcon, Tooltip, Stack, Alert, } from "@mantine/core"; import { useAtom } from "jotai"; import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts"; import React, { useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import { updateWorkspace } from "@/features/workspace/services/workspace-service.ts"; import { notifications } from "@mantine/notifications"; import { useHasFeature } from "@/ee/hooks/use-feature"; import { Feature } from "@/ee/features"; import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label"; import { getAppUrl } from "@/lib/config.ts"; import { IconCheck, IconCopy, IconInfoCircle } from "@tabler/icons-react"; import { CopyButton } from "@/components/common/copy-button.tsx"; export default function McpSettings() { const { t } = useTranslation(); const [workspace, setWorkspace] = useAtom(workspaceAtom); const [checked, setChecked] = useState(workspace?.settings?.ai?.mcp); const hasAccess = useHasFeature(Feature.MCP); const upgradeLabel = useUpgradeLabel(); const mcpUrl = `${getAppUrl()}/mcp`; const handleChange = async (event: React.ChangeEvent) => { const value = event.currentTarget.checked; try { const updatedWorkspace = await updateWorkspace({ mcpEnabled: value }); setChecked(value); setWorkspace(updatedWorkspace); } catch (err) { notifications.show({ message: err?.response?.data?.message, color: "red", }); } }; return ( {!hasAccess && ( } title={upgradeLabel} color="blue"> {t( "MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.", )} )}
{t("Model Context Protocol (MCP)")} {t( "Enable the MCP server to allow AI assistants and tools to interact with your workspace content.", )}{" "} , }} />
{checked && (
{t("MCP Server URL")} {({ copied, copy }) => ( {copied ? : } )} {t( "Use your API key for authentication. You can manage API keys in your account settings.", )}
{t("Supported tools")} search_pages, get_page, create_page, update_page list_pages, list_child_pages, duplicate_page copy_page_to_space, move_page, move_page_to_space get_space, list_spaces, create_space, update_space get_comments, create_comment, update_comment search_attachments, list_workspace_members, get_current_user
)}
); }