Files
outline/app/scenes/Settings/Features.tsx
T
Tom Moor e49e3136b6 Increase MCP guidance limit (#12097)
* Increase MCP guidance limit
Add new controls for Input

* PR feedback
2026-04-17 23:22:50 -04:00

157 lines
5.0 KiB
TypeScript

import { observer } from "mobx-react";
import { CopyIcon, SparklesIcon } from "outline-icons";
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import { toast } from "sonner";
import { TeamPreference } from "@shared/types";
import { TeamValidation } from "@shared/validations";
import Heading from "~/components/Heading";
import Scene from "~/components/Scene";
import Switch from "~/components/Switch";
import Text from "~/components/Text";
import useCurrentTeam from "~/hooks/useCurrentTeam";
import SettingRow from "./components/SettingRow";
import Input from "~/components/Input";
import Tooltip from "~/components/Tooltip";
import CopyToClipboard from "~/components/CopyToClipboard";
import NudeButton from "~/components/NudeButton";
import { useTheme } from "styled-components";
function Features() {
const { t } = useTranslation();
const team = useCurrentTeam();
const theme = useTheme();
const handleMCPChange = React.useCallback(
async (checked: boolean) => {
team.setPreference(TeamPreference.MCP, checked);
await team.save();
toast.success(t("Settings saved"));
},
[team, t]
);
const handleGuidanceMCPChange = React.useCallback(
async (ev: React.ChangeEvent<HTMLTextAreaElement>) => {
team.guidanceMCP = ev.target.value || null;
},
[team]
);
const handleGuidanceMCPBlur = React.useCallback(async () => {
await team.save();
toast.success(t("Settings saved"));
}, [team, t]);
const handleCopied = React.useCallback(() => {
toast.success(t("Copied to clipboard"));
}, [t]);
const mcpEndpoint = window.location.origin + "/mcp";
return (
<Scene title={t("AI")} icon={<SparklesIcon />}>
<Heading>{t("AI")}</Heading>
<Text as="p" type="secondary">
<Trans>Manage AI and integration features for your workspace.</Trans>
</Text>
<SettingRow
name={TeamPreference.MCP}
label={t("MCP server")}
border={!team.getPreference(TeamPreference.MCP)}
description={
<>
<Text type="secondary" as="p">
{t(
"Allow members to connect to this workspace with MCP to read and write data."
)}
</Text>
{team.getPreference(TeamPreference.MCP) && (
<>
<Text
type="secondary"
as="p"
style={{ marginTop: 8, marginBottom: 4 }}
>
<Trans
defaults="Use the following endpoint to connect to the MCP server from your app. Find out more about setup in <a>the docs</a>."
components={{
a: (
<Text
as="a"
weight="bold"
href="https://docs.getoutline.com/s/guide/doc/mcp-6j9jtENNKL"
target="_blank"
rel="noopener noreferrer"
/>
),
}}
/>
</Text>
<Input readOnly value={mcpEndpoint}>
<Tooltip content={t("Copy URL")} placement="top">
<CopyToClipboard text={mcpEndpoint} onCopy={handleCopied}>
<NudeButton type="button" style={{ marginRight: 3 }}>
<CopyIcon color={theme.placeholder} size={18} />
</NudeButton>
</CopyToClipboard>
</Tooltip>
</Input>
</>
)}
</>
}
>
<Switch
id={TeamPreference.MCP}
name={TeamPreference.MCP}
checked={team.getPreference(TeamPreference.MCP)}
onChange={handleMCPChange}
/>
</SettingRow>
{team.getPreference(TeamPreference.MCP) && (
<SettingRow
name="guidanceMCP"
label={t("Additional guidance")}
description={
<>
<div style={{ marginBottom: 8 }}>
{t(
"You can use these optional instructions to tell MCP clients how to use your knowledge base."
)}
</div>
<Input
id="guidanceMCP"
type="textarea"
autoSize
minHeight="6lh"
maxHeight="20lh"
value={team.guidanceMCP ?? ""}
maxLength={TeamValidation.maxGuidanceMCPLength}
warningLimit={TeamValidation.warnGuidanceMCPLength}
onChange={handleGuidanceMCPChange}
onBlur={handleGuidanceMCPBlur}
/>
</>
}
/>
)}
<SettingRow
name="answers"
label={t("AI answers")}
description={t(
"Use AI to get direct answers to questions in search. This feature requires a paid license."
)}
border={false}
>
<Switch disabled />
</SettingRow>
</Scene>
);
}
export default observer(Features);