Merge pull request #7234 from continuedev/dallin/indexing-and-mcp-org-settings-CON-3282
feat: org policies for indexing and mcp
This commit is contained in:
commit
5fc3419d7c
8 changed files with 78 additions and 29 deletions
|
|
@ -202,6 +202,8 @@ export class ConfigHandler {
|
|||
message: `Error loading Continue Hub assistants${e instanceof Error ? ":\n" + e.message : ""}`,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
PolicySingleton.getInstance().policy = null;
|
||||
}
|
||||
// Load local org if not signed in or hub orgs fail
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import {
|
|||
} from "../util/paths";
|
||||
import { localPathToUri } from "../util/pathToUri";
|
||||
|
||||
import { PolicySingleton } from "../control-plane/PolicySingleton";
|
||||
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
|
||||
import { getBaseToolDefinitions } from "../tools";
|
||||
import { resolveRelativePathInDir } from "../util/ideUtils";
|
||||
|
|
@ -544,16 +545,21 @@ async function intermediateToFinalConfig({
|
|||
|
||||
// Trigger MCP server refreshes (Config is reloaded again once connected!)
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
mcpManager.setConnections(
|
||||
(config.experimental?.modelContextProtocolServers ?? []).map(
|
||||
(server, index) => ({
|
||||
id: `continue-mcp-server-${index + 1}`,
|
||||
name: `MCP Server`,
|
||||
...server,
|
||||
}),
|
||||
),
|
||||
false,
|
||||
);
|
||||
const orgPolicy = PolicySingleton.getInstance().policy;
|
||||
if (orgPolicy?.policy?.allowMcpServers === false) {
|
||||
await mcpManager.shutdown();
|
||||
} else {
|
||||
mcpManager.setConnections(
|
||||
(config.experimental?.modelContextProtocolServers ?? []).map(
|
||||
(server, index) => ({
|
||||
id: `continue-mcp-server-${index + 1}`,
|
||||
name: `MCP Server`,
|
||||
...server,
|
||||
}),
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
// Handle experimental modelRole config values for apply and edit
|
||||
const inlineEditModel = getModelByRole(continueConfig, "inlineEdit")?.title;
|
||||
|
|
|
|||
|
|
@ -332,12 +332,14 @@ export default async function doLoadConfig(options: {
|
|||
}
|
||||
}
|
||||
|
||||
if (
|
||||
PolicySingleton.getInstance().policy?.policy?.allowAnonymousTelemetry ===
|
||||
false
|
||||
) {
|
||||
// Org policies
|
||||
const policy = PolicySingleton.getInstance().policy?.policy;
|
||||
if (policy?.allowAnonymousTelemetry === false) {
|
||||
newConfig.allowAnonymousTelemetry = false;
|
||||
}
|
||||
if (policy?.allowCodebaseIndexing === false) {
|
||||
newConfig.disableIndexing = true;
|
||||
}
|
||||
|
||||
// Setup telemetry only after (and if) we know it is enabled
|
||||
await Telemetry.setup(
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
|
|||
import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand";
|
||||
import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand";
|
||||
import { getControlPlaneEnvSync } from "../../control-plane/env";
|
||||
import { PolicySingleton } from "../../control-plane/PolicySingleton";
|
||||
import { getBaseToolDefinitions } from "../../tools";
|
||||
import { getCleanUriPath } from "../../util/uri";
|
||||
import { loadConfigContextProviders } from "../loadContextProviders";
|
||||
|
|
@ -378,21 +379,26 @@ async function configYamlToContinueConfig(options: {
|
|||
|
||||
// Trigger MCP server refreshes (Config is reloaded again once connected!)
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
mcpManager.setConnections(
|
||||
(config.mcpServers ?? []).map((server) => ({
|
||||
id: server.name,
|
||||
name: server.name,
|
||||
sourceFile: server.sourceFile,
|
||||
transport: {
|
||||
type: "stdio",
|
||||
args: [],
|
||||
...(server as any), // TODO: fix the types on mcpServers in config-yaml
|
||||
},
|
||||
timeout: server.connectionTimeout,
|
||||
})),
|
||||
false,
|
||||
{ ide },
|
||||
);
|
||||
const orgPolicy = PolicySingleton.getInstance().policy;
|
||||
if (orgPolicy?.policy?.allowMcpServers === false) {
|
||||
await mcpManager.shutdown();
|
||||
} else {
|
||||
mcpManager.setConnections(
|
||||
(config.mcpServers ?? []).map((server) => ({
|
||||
id: server.name,
|
||||
name: server.name,
|
||||
sourceFile: server.sourceFile,
|
||||
transport: {
|
||||
type: "stdio",
|
||||
args: [],
|
||||
...(server as any), // TODO: fix the types on mcpServers in config-yaml
|
||||
},
|
||||
timeout: server.connectionTimeout,
|
||||
})),
|
||||
false,
|
||||
{ ide },
|
||||
);
|
||||
}
|
||||
|
||||
return { config: continueConfig, errors: localErrors };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,21 @@ export class MCPManagerSingleton {
|
|||
this.connections.delete(id);
|
||||
}
|
||||
|
||||
async shutdown() {
|
||||
if (this.connections.size > 0) {
|
||||
await Promise.allSettled(
|
||||
Array.from(this.connections.entries()).map(([id, connection]) => {
|
||||
try {
|
||||
connection.abortController.abort();
|
||||
void connection.client.close();
|
||||
} finally {
|
||||
this.connections.delete(id);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setConnections(
|
||||
servers: MCPOptions[],
|
||||
forceRefresh: boolean,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ 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 { fontSize } from "../../../../../util";
|
||||
import { ToolTip } from "../../../../gui/Tooltip";
|
||||
import { Button } from "../../../../ui";
|
||||
|
|
@ -235,10 +236,12 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
}
|
||||
|
||||
function MCPSection() {
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
const servers = useAppSelector(
|
||||
(store) => store.config.config.mcpServerStatuses,
|
||||
);
|
||||
const { selectedProfile } = useAuth();
|
||||
const disableMcp = currentOrg?.policy?.allowMcpServers === false;
|
||||
|
||||
const mergedBlocks = useMemo(() => {
|
||||
const parsed = selectedProfile?.rawYaml
|
||||
|
|
@ -250,6 +253,16 @@ function MCPSection() {
|
|||
}));
|
||||
}, [servers, selectedProfile]);
|
||||
|
||||
if (disableMcp) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center p-2">
|
||||
<span className="text-description">
|
||||
MCP servers are disabled in your organization
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex max-h-[170px] flex-col gap-1 overflow-y-auto overflow-x-hidden pr-2">
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ export function UserSettingsForm() {
|
|||
|
||||
const disableTelemetryToggle =
|
||||
currentOrg?.policy?.allowAnonymousTelemetry === false;
|
||||
const disableIndexingToggle =
|
||||
currentOrg?.policy?.allowCodebaseIndexing === false;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
|
|
@ -245,6 +247,7 @@ export function UserSettingsForm() {
|
|||
|
||||
<ToggleSwitch
|
||||
isToggled={!disableIndexing}
|
||||
disabled={disableIndexingToggle}
|
||||
onToggle={() =>
|
||||
handleUpdate({
|
||||
disableIndexing: !disableIndexing,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import * as z from "zod";
|
|||
export const policySchema = z.object({
|
||||
allowAnonymousTelemetry: z.boolean().optional(),
|
||||
allowOtherOrgs: z.boolean().optional(),
|
||||
allowCodebaseIndexing: z.boolean().optional(),
|
||||
allowMcpServers: z.boolean().optional(),
|
||||
// allowLocalConfigFile: z.boolean().optional(),
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue