mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 01:07:08 +08:00
refactor: rename MCP oauth-only setting to enforceMcpOauth
This commit is contained in:
@@ -708,9 +708,9 @@
|
|||||||
"MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
"MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.": "MCP is only available in the Docmost enterprise edition. Contact sales@docmost.com.",
|
||||||
"MCP Server URL": "MCP Server URL",
|
"MCP Server URL": "MCP Server URL",
|
||||||
"Connect AI assistants with your Docmost account via OAuth.": "Connect AI assistants with your Docmost account via OAuth.",
|
"Connect AI assistants with your Docmost account via OAuth.": "Connect AI assistants with your Docmost account via OAuth.",
|
||||||
"Require OAuth": "Require OAuth",
|
"Enforce OAuth": "Enforce OAuth",
|
||||||
"AI assistants must connect with a Docmost account via OAuth. API keys cannot be used with the MCP server.": "AI assistants must connect with a Docmost account via OAuth. API keys cannot be used with the MCP server.",
|
"AI assistants must connect with a Docmost account via OAuth. API keys cannot be used with the MCP server.": "AI assistants must connect with a Docmost account via OAuth. API keys cannot be used with the MCP server.",
|
||||||
"Toggle require OAuth for MCP": "Toggle require OAuth for MCP",
|
"Toggle enforce OAuth for MCP": "Toggle enforce OAuth for MCP",
|
||||||
"Supported tools": "Supported tools",
|
"Supported tools": "Supported tools",
|
||||||
"MCP server URL:": "MCP server URL:",
|
"MCP server URL:": "MCP server URL:",
|
||||||
"Learn more": "Learn more",
|
"Learn more": "Learn more",
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export default function McpSettings() {
|
|||||||
{t("Connect AI assistants with your Docmost account via OAuth.")}
|
{t("Connect AI assistants with your Docmost account via OAuth.")}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<McpOauthOnlySetting />
|
<McpEnforceOauthSetting />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Text size="sm" fw={500} mt="md" mb={4}>
|
<Text size="sm" fw={500} mt="md" mb={4}>
|
||||||
@@ -156,17 +156,17 @@ export default function McpSettings() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function McpOauthOnlySetting() {
|
function McpEnforceOauthSetting() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||||
const [checked, setChecked] = useState(workspace?.settings?.ai?.mcpOauthOnly);
|
const [checked, setChecked] = useState(workspace?.settings?.ai?.enforceMcpOauth);
|
||||||
const hasAccess = useHasFeature(Feature.MCP_CONTROLS);
|
const hasAccess = useHasFeature(Feature.MCP_CONTROLS);
|
||||||
const upgradeLabel = useUpgradeLabel();
|
const upgradeLabel = useUpgradeLabel();
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = event.currentTarget.checked;
|
const value = event.currentTarget.checked;
|
||||||
try {
|
try {
|
||||||
const updatedWorkspace = await updateWorkspace({ mcpOauthOnly: value });
|
const updatedWorkspace = await updateWorkspace({ enforceMcpOauth: value });
|
||||||
setChecked(value);
|
setChecked(value);
|
||||||
setWorkspace(updatedWorkspace);
|
setWorkspace(updatedWorkspace);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -182,7 +182,7 @@ function McpOauthOnlySetting() {
|
|||||||
<div>
|
<div>
|
||||||
<Group gap="xs" align="center">
|
<Group gap="xs" align="center">
|
||||||
<Text size="sm" fw={500}>
|
<Text size="sm" fw={500}>
|
||||||
{t("Require OAuth")}
|
{t("Enforce OAuth")}
|
||||||
</Text>
|
</Text>
|
||||||
{!hasAccess && (
|
{!hasAccess && (
|
||||||
<Badge variant="light" size="sm" radius="sm">
|
<Badge variant="light" size="sm" radius="sm">
|
||||||
@@ -202,7 +202,7 @@ function McpOauthOnlySetting() {
|
|||||||
defaultChecked={checked}
|
defaultChecked={checked}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
disabled={!hasAccess}
|
disabled={!hasAccess}
|
||||||
aria-label={t("Toggle require OAuth for MCP")}
|
aria-label={t("Toggle enforce OAuth for MCP")}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export interface IWorkspace {
|
|||||||
mcpEnabled?: boolean;
|
mcpEnabled?: boolean;
|
||||||
aiChatReadOnly?: boolean;
|
aiChatReadOnly?: boolean;
|
||||||
aiChatWorkspaceKnowledgeOnly?: boolean;
|
aiChatWorkspaceKnowledgeOnly?: boolean;
|
||||||
mcpOauthOnly?: boolean;
|
enforceMcpOauth?: boolean;
|
||||||
trashRetentionDays?: number;
|
trashRetentionDays?: number;
|
||||||
restrictApiToAdmins?: boolean;
|
restrictApiToAdmins?: boolean;
|
||||||
allowMemberTemplates?: boolean;
|
allowMemberTemplates?: boolean;
|
||||||
@@ -53,7 +53,7 @@ export interface IWorkspaceAiSettings {
|
|||||||
search?: boolean;
|
search?: boolean;
|
||||||
generative?: boolean;
|
generative?: boolean;
|
||||||
mcp?: boolean;
|
mcp?: boolean;
|
||||||
mcpOauthOnly?: boolean;
|
enforceMcpOauth?: boolean;
|
||||||
chat?: boolean;
|
chat?: boolean;
|
||||||
chatReadOnly?: boolean;
|
chatReadOnly?: boolean;
|
||||||
chatWorkspaceKnowledgeOnly?: boolean;
|
chatWorkspaceKnowledgeOnly?: boolean;
|
||||||
|
|||||||
@@ -79,5 +79,5 @@ export class UpdateWorkspaceDto extends PartialType(CreateWorkspaceDto) {
|
|||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
mcpOauthOnly: boolean;
|
enforceMcpOauth: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ export class WorkspaceService {
|
|||||||
typeof updateWorkspaceDto.allowPersonalSpaces !== 'undefined' ||
|
typeof updateWorkspaceDto.allowPersonalSpaces !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.aiChatReadOnly !== 'undefined' ||
|
typeof updateWorkspaceDto.aiChatReadOnly !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly !== 'undefined' ||
|
typeof updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly !== 'undefined' ||
|
||||||
typeof updateWorkspaceDto.mcpOauthOnly !== 'undefined'
|
typeof updateWorkspaceDto.enforceMcpOauth !== 'undefined'
|
||||||
) {
|
) {
|
||||||
const ws = await this.db
|
const ws = await this.db
|
||||||
.selectFrom('workspaces')
|
.selectFrom('workspaces')
|
||||||
@@ -392,7 +392,7 @@ export class WorkspaceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof updateWorkspaceDto.mcpOauthOnly !== 'undefined') {
|
if (typeof updateWorkspaceDto.enforceMcpOauth !== 'undefined') {
|
||||||
if (
|
if (
|
||||||
!this.licenseCheckService.hasFeature(
|
!this.licenseCheckService.hasFeature(
|
||||||
ws.licenseKey,
|
ws.licenseKey,
|
||||||
@@ -574,16 +574,16 @@ export class WorkspaceService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof updateWorkspaceDto.mcpOauthOnly !== 'undefined') {
|
if (typeof updateWorkspaceDto.enforceMcpOauth !== 'undefined') {
|
||||||
const prev = settingsBefore?.ai?.mcpOauthOnly ?? false;
|
const prev = settingsBefore?.ai?.enforceMcpOauth ?? false;
|
||||||
if (prev !== updateWorkspaceDto.mcpOauthOnly) {
|
if (prev !== updateWorkspaceDto.enforceMcpOauth) {
|
||||||
before.mcpOauthOnly = prev;
|
before.enforceMcpOauth = prev;
|
||||||
after.mcpOauthOnly = updateWorkspaceDto.mcpOauthOnly;
|
after.enforceMcpOauth = updateWorkspaceDto.enforceMcpOauth;
|
||||||
}
|
}
|
||||||
await this.workspaceRepo.updateAiSettings(
|
await this.workspaceRepo.updateAiSettings(
|
||||||
workspaceId,
|
workspaceId,
|
||||||
'mcpOauthOnly',
|
'enforceMcpOauth',
|
||||||
updateWorkspaceDto.mcpOauthOnly,
|
updateWorkspaceDto.enforceMcpOauth,
|
||||||
trx,
|
trx,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -627,7 +627,7 @@ export class WorkspaceService {
|
|||||||
delete updateWorkspaceDto.defaultPageEditMode;
|
delete updateWorkspaceDto.defaultPageEditMode;
|
||||||
delete updateWorkspaceDto.aiChatReadOnly;
|
delete updateWorkspaceDto.aiChatReadOnly;
|
||||||
delete updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly;
|
delete updateWorkspaceDto.aiChatWorkspaceKnowledgeOnly;
|
||||||
delete updateWorkspaceDto.mcpOauthOnly;
|
delete updateWorkspaceDto.enforceMcpOauth;
|
||||||
|
|
||||||
await this.workspaceRepo.updateWorkspace(
|
await this.workspaceRepo.updateWorkspace(
|
||||||
updateWorkspaceDto,
|
updateWorkspaceDto,
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: ae1bfe5b5c...844f2003cd
Reference in New Issue
Block a user