Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

misc: added permission checks for MCP endpoints

Sheen Capadngan53b39967fb64
diff --git a/backend/src/db/schemas/models.ts b/backend/src/db/schemas/models.ts
index a243e80826..380fc488d3 100644
--- a/backend/src/db/schemas/models.ts
+++ b/backend/src/db/schemas/models.ts
@@ -347,6 +347,7 @@ export enum ActionProjectType {
SSH = ProjectType.SSH,
SecretScanning = ProjectType.SecretScanning,
PAM = ProjectType.PAM,
+ AI = ProjectType.AI,
// project operations that happen on all types
Any = "any"
}
diff --git a/backend/src/ee/routes/v1/ai-mcp-endpoint-router.ts b/backend/src/ee/routes/v1/ai-mcp-endpoint-router.ts
index 969193b7ad..e45091373e 100644
--- a/backend/src/ee/routes/v1/ai-mcp-endpoint-router.ts
+++ b/backend/src/ee/routes/v1/ai-mcp-endpoint-router.ts
@@ -73,7 +73,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
const { server: mcpServer, transport } = await server.services.aiMcpEndpoint.interactWithMcp({
endpointId: req.params.endpointId,
- userId: req.permission.id
+ userId: req.permission.id,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
// Close transport when client disconnects
@@ -141,7 +145,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
projectId: req.body.projectId,
name: req.body.name,
description: req.body.description,
- serverIds: req.body.serverIds
+ serverIds: req.body.serverIds,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { endpoint };
@@ -174,7 +182,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const endpoints = await server.services.aiMcpEndpoint.listMcpEndpoints({
- projectId: req.query.projectId
+ projectId: req.query.projectId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return {
@@ -208,7 +220,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const endpoint = await server.services.aiMcpEndpoint.getMcpEndpointById({
- endpointId: req.params.endpointId
+ endpointId: req.params.endpointId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { endpoint };
@@ -241,7 +257,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
handler: async (req) => {
const endpoint = await server.services.aiMcpEndpoint.updateMcpEndpoint({
endpointId: req.params.endpointId,
- ...req.body
+ ...req.body,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { endpoint };
@@ -267,7 +287,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const endpoint = await server.services.aiMcpEndpoint.deleteMcpEndpoint({
- endpointId: req.params.endpointId
+ endpointId: req.params.endpointId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { endpoint };
@@ -293,7 +317,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
const tools = await server.services.aiMcpEndpoint.listEndpointTools({
- endpointId: req.params.endpointId
+ endpointId: req.params.endpointId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { tools };
@@ -321,7 +349,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
handler: async (req) => {
const tool = await server.services.aiMcpEndpoint.enableEndpointTool({
endpointId: req.params.endpointId,
- serverToolId: req.params.serverToolId
+ serverToolId: req.params.serverToolId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { tool };
@@ -349,7 +381,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
handler: async (req) => {
await server.services.aiMcpEndpoint.disableEndpointTool({
endpointId: req.params.endpointId,
- serverToolId: req.params.serverToolId
+ serverToolId: req.params.serverToolId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { message: "Tool disabled" };
@@ -384,7 +420,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
handler: async (req) => {
const tools = await server.services.aiMcpEndpoint.bulkUpdateEndpointTools({
endpointId: req.params.endpointId,
- tools: req.body.tools
+ tools: req.body.tools,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { tools };
@@ -505,7 +545,6 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
redirectUri: req.body.redirect_uri,
resource: req.body.resource,
responseType: req.body.response_type,
- projectId: "",
tokenId: req.auth.authMode === AuthMode.JWT ? req.auth.tokenVersionId : "",
userInfo,
expiry: req.body.expireIn,
@@ -581,7 +620,10 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
handler: async (req) => {
const servers = await server.services.aiMcpEndpoint.getServersRequiringAuth({
endpointId: req.params.endpointId,
- userId: req.permission.id
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return { servers };
@@ -614,7 +656,7 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
serverId: req.params.serverId,
actorId: req.permission.id,
actor: req.permission.type,
- actorAuthMethod: req.permission.authMethod as string,
+ actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId
});
@@ -651,8 +693,11 @@ export const registerAiMcpEndpointRouter = async (server: FastifyZodProvider) =>
const result = await server.services.aiMcpEndpoint.saveUserServerCredential({
endpointId: req.params.endpointId,
serverId: req.params.serverId,
- userId: req.permission.id,
- ...req.body
+ ...req.body,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
});
return result;
diff --git a/backend/src/ee/routes/v1/ai-mcp-server-router.ts b/backend/src/ee/routes/v1/ai-mcp-server-router.ts
index 0d655b96a4..6f43beed47 100644
--- a/backend/src/ee/routes/v1/ai-mcp-server-router.ts
+++ b/backend/src/ee/routes/v1/ai-mcp-server-router.ts
@@ -71,10 +71,7 @@ export const registerAiMcpServerRouter = async (server: FastifyZodProvider) => {
url: req.body.url,
clientId: req.body.clientId,
clientSecret: req.body.clientSecret,
- actorId: req.permission.id,
- actor: req.permission.type,
- actorAuthMethod: req.permission.authMethod!,
- actorOrgId: req.permission.orgId
+ actorId: req.permission.id
});
return result;
diff --git a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-enum.ts b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-enum.ts
new file mode 100644
index 0000000000..ff487a0ba0
--- /dev/null
+++ b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-enum.ts
@@ -0,0 +1,4 @@
+export enum AiMcpEndpointStatus {
+ ACTIVE = "active",
+ DISABLED = "disabled"
+}
diff --git a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts
index fb51bb7ceb..f3ec841620 100644
--- a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts
+++ b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-service.ts
@@ -1,5 +1,6 @@
import crypto from "node:crypto";
+import { ForbiddenError } from "@casl/ability";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { Server as RawMcpServer } from "@modelcontextprotocol/sdk/server/index.js";
@@ -7,13 +8,14 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
+import { ActionProjectType } from "@app/db/schemas";
import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";
import { getConfig } from "@app/lib/config/env";
import { crypto as cryptoModule } from "@app/lib/crypto";
import { BadRequestError, NotFoundError, UnauthorizedError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { ms } from "@app/lib/ms";
-import { AuthTokenType } from "@app/services/auth/auth-type";
+import { ActorType, AuthMethod, AuthTokenType } from "@app/services/auth/auth-type";
import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-service";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
@@ -25,7 +27,10 @@ import { AiMcpServerCredentialMode } from "../ai-mcp-server/ai-mcp-server-enum";
import { TAiMcpServerServiceFactory } from "../ai-mcp-server/ai-mcp-server-service";
import { TAiMcpServerToolDALFactory } from "../ai-mcp-server/ai-mcp-server-tool-dal";
import { TAiMcpServerUserCredentialDALFactory } from "../ai-mcp-server/ai-mcp-server-user-credential-dal";
+import { TPermissionServiceFactory } from "../permission/permission-service-types";
+import { ProjectPermissionMcpEndpointActions, ProjectPermissionSub } from "../permission/project-permission";
import { TAiMcpEndpointDALFactory } from "./ai-mcp-endpoint-dal";
+import { AiMcpEndpointStatus } from "./ai-mcp-endpoint-enum";
import { TAiMcpEndpointServerDALFactory } from "./ai-mcp-endpoint-server-dal";
import { TAiMcpEndpointServerToolDALFactory } from "./ai-mcp-endpoint-server-tool-dal";
import {
@@ -66,6 +71,7 @@ type TAiMcpEndpointServiceFactoryDep = {
keyStore: Pick<TKeyStoreFactory, "setItemWithExpiry" | "getItem" | "deleteItem">;
authTokenService: Pick<TAuthTokenServiceFactory, "getUserTokenSessionById">;
userDAL: TUserDALFactory;
+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
};
// OAuth schemas for parsing cached data
@@ -122,7 +128,8 @@ export const aiMcpEndpointServiceFactory = ({
kmsService,
keyStore,
authTokenService,
- userDAL
+ userDAL,
+ permissionService
}: TAiMcpEndpointServiceFactoryDep) => {
// PII filtering utility - redacts sensitive information
const applyPiiFiltering = (data: unknown): unknown => {
@@ -173,15 +180,35 @@ export const aiMcpEndpointServiceFactory = ({
return data;
};
- const interactWithMcp = async ({ endpointId, userId }: TInteractWithMcpDTO) => {
+ const interactWithMcp = async ({
+ endpointId,
+ userId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TInteractWithMcpDTO) => {
const appCfg = getConfig();
- // Get the endpoint
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Connect,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const user = await userDAL.findById(userId);
if (!user) {
throw new NotFoundError({ message: `User with ID '${userId}' not found` });
@@ -323,7 +350,7 @@ export const aiMcpEndpointServiceFactory = ({
try {
// Apply PII filtering to arguments if enabled
- const filteredArgs = endpoint.piiFiltering ? applyPiiFiltering(args) : args;
+ const filteredArgs = (endpoint.piiFiltering ? applyPiiFiltering(args) : args) as Record<string, unknown>;
const result = await selectedMcpClient.client.callTool({
name,
@@ -365,12 +392,51 @@ export const aiMcpEndpointServiceFactory = ({
return { server, transport };
};
- const createMcpEndpoint = async ({ projectId, name, description, serverIds }: TCreateAiMcpEndpointDTO) => {
+ const createMcpEndpoint = async ({
+ projectId,
+ name,
+ description,
+ serverIds,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TCreateAiMcpEndpointDTO) => {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Create,
+ ProjectPermissionSub.McpEndpoints
+ );
+
+ // Validate that all serverIds belong to the same project
+ if (serverIds && serverIds.length > 0) {
+ const servers = await aiMcpServerDAL.find({ $in: { id: serverIds } });
+
+ if (servers.length !== serverIds.length) {
+ throw new NotFoundError({ message: "One or more MCP servers not found" });
+ }
+
+ const invalidServers = servers.filter((server) => server.projectId !== projectId);
+ if (invalidServers.length > 0) {
+ throw new BadRequestError({
+ message: "All MCP servers must belong to the same project as the endpoint"
+ });
+ }
+ }
+
const endpoint = await aiMcpEndpointDAL.create({
projectId,
name,
description,
- status: "active"
+ status: AiMcpEndpointStatus.ACTIVE
});
// Connect servers if provided
@@ -386,7 +452,27 @@ export const aiMcpEndpointServiceFactory = ({
return endpoint;
};
- const listMcpEndpoints = async ({ projectId }: TListAiMcpEndpointsDTO): Promise<TAiMcpEndpointWithServers[]> => {
+ const listMcpEndpoints = async ({
+ projectId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TListAiMcpEndpointsDTO): Promise<TAiMcpEndpointWithServers[]> => {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Read,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const endpoints = await aiMcpEndpointDAL.find({ projectId });
// Get connected servers count and tools count for each endpoint
@@ -406,12 +492,32 @@ export const aiMcpEndpointServiceFactory = ({
return endpointsWithStats;
};
- const getMcpEndpointById = async ({ endpointId }: TGetAiMcpEndpointDTO) => {
+ const getMcpEndpointById = async ({
+ endpointId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TGetAiMcpEndpointDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Read,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const connectedServers = await aiMcpEndpointServerDAL.find({ aiMcpEndpointId: endpointId });
const tools = await aiMcpEndpointServerToolDAL.find({ aiMcpEndpointId: endpointId });
@@ -428,13 +534,31 @@ export const aiMcpEndpointServiceFactory = ({
name,
description,
serverIds,
- piiFiltering
+ piiFiltering,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
}: TUpdateAiMcpEndpointDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Edit,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const updateData: { name?: string; description?: string; piiFiltering?: boolean } = {};
if (name !== undefined) updateData.name = name;
if (description !== undefined) updateData.description = description;
@@ -447,6 +571,22 @@ export const aiMcpEndpointServiceFactory = ({
// Update server connections if provided
if (serverIds !== undefined) {
+ // Validate that all serverIds belong to the same project
+ if (serverIds.length > 0) {
+ const servers = await aiMcpServerDAL.find({ $in: { id: serverIds } });
+
+ if (servers.length !== serverIds.length) {
+ throw new NotFoundError({ message: "One or more MCP servers not found" });
+ }
+
+ const invalidServers = servers.filter((server) => server.projectId !== endpoint.projectId);
+ if (invalidServers.length > 0) {
+ throw new BadRequestError({
+ message: "All MCP servers must belong to the same project as the endpoint"
+ });
+ }
+ }
+
// Delete existing connections
await aiMcpEndpointServerDAL.delete({ aiMcpEndpointId: endpointId });
@@ -464,34 +604,94 @@ export const aiMcpEndpointServiceFactory = ({
return updatedEndpoint;
};
- const deleteMcpEndpoint = async ({ endpointId }: TDeleteAiMcpEndpointDTO) => {
+ const deleteMcpEndpoint = async ({
+ endpointId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TDeleteAiMcpEndpointDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
- // Delete endpoint
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Delete,
+ ProjectPermissionSub.McpEndpoints
+ );
+
await aiMcpEndpointDAL.deleteById(endpointId);
return endpoint;
};
- const listEndpointTools = async ({ endpointId }: TListEndpointToolsDTO) => {
+ const listEndpointTools = async ({
+ endpointId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TListEndpointToolsDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Read,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const toolConfigs = await aiMcpEndpointServerToolDAL.find({ aiMcpEndpointId: endpointId });
return toolConfigs;
};
- const enableEndpointTool = async ({ endpointId, serverToolId }: TEnableEndpointToolDTO) => {
+ const enableEndpointTool = async ({
+ endpointId,
+ serverToolId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TEnableEndpointToolDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Edit,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const existingConfig = await aiMcpEndpointServerToolDAL.findOne({
aiMcpEndpointId: endpointId,
aiMcpServerToolId: serverToolId
@@ -508,12 +708,33 @@ export const aiMcpEndpointServiceFactory = ({
});
};
- const disableEndpointTool = async ({ endpointId, serverToolId }: TDisableEndpointToolDTO) => {
+ const disableEndpointTool = async ({
+ endpointId,
+ serverToolId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TDisableEndpointToolDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Edit,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const existingConfig = await aiMcpEndpointServerToolDAL.findOne({
aiMcpEndpointId: endpointId,
aiMcpServerToolId: serverToolId
@@ -524,12 +745,33 @@ export const aiMcpEndpointServiceFactory = ({
}
};
- const bulkUpdateEndpointTools = async ({ endpointId, tools }: TBulkUpdateEndpointToolsDTO) => {
+ const bulkUpdateEndpointTools = async ({
+ endpointId,
+ tools,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: TBulkUpdateEndpointToolsDTO) => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Edit,
+ ProjectPermissionSub.McpEndpoints
+ );
+
// Separate tools to enable and disable
const toEnable = tools.filter((t) => t.isEnabled);
const toDisable = tools.filter((t) => !t.isEnabled);
@@ -571,6 +813,7 @@ export const aiMcpEndpointServiceFactory = ({
};
// OAuth 2.0 Methods
+ // Called by MCP client during Dynamic Client Registration (DCR) - no auth required
const oauthRegisterClient = async ({
endpointId,
client_name,
@@ -645,12 +888,26 @@ export const aiMcpEndpointServiceFactory = ({
const isValidRedirectUri = oauthClient.redirect_uris.some((el) => new URL(el).toString() === redirectUri);
if (!isValidRedirectUri) throw new BadRequestError({ message: "Redirect URI mismatch" });
- // Verify endpoint exists
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ // Check Connect permission at authorization time
+ const { permission: projectPermission } = await permissionService.getProjectPermission({
+ actor: permission.type as ActorType,
+ actorId: permission.id,
+ projectId: endpoint.projectId,
+ actorAuthMethod: permission.authMethod as AuthMethod,
+ actorOrgId: permission.orgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(projectPermission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Connect,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const code = crypto.randomBytes(32).toString("hex");
await keyStore.setItemWithExpiry(
KeyStorePrefixes.AiMcpEndpointOAuthCode(clientId, code),
@@ -748,13 +1005,30 @@ export const aiMcpEndpointServiceFactory = ({
// Get servers that require personal authentication for an endpoint
const getServersRequiringAuth = async ({
endpointId,
- userId
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
}: TGetServersRequiringAuthDTO): Promise<TServerAuthStatus[]> => {
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Read,
+ ProjectPermissionSub.McpEndpoints
+ );
+
// Get connected servers
const connectedServerLinks = await aiMcpEndpointServerDAL.find({ aiMcpEndpointId: endpointId });
const serverIds = connectedServerLinks.map((link) => link.aiMcpServerId);
@@ -777,7 +1051,7 @@ export const aiMcpEndpointServiceFactory = ({
// Check which servers the user already has credentials for
const serversWithAuthStatus = await Promise.all(
personalServers.map(async (server) => {
- const existingCredential = await aiMcpServerUserCredentialDAL.findByUserAndServer(userId, server.id);
+ const existingCredential = await aiMcpServerUserCredentialDAL.findByUserAndServer(actorId, server.id);
return {
id: server.id,
@@ -800,17 +1074,40 @@ export const aiMcpEndpointServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TInitiateServerOAuthDTO) => {
- // Verify endpoint exists and server is connected
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Connect,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const server = await aiMcpServerDAL.findById(serverId);
if (!server) {
throw new NotFoundError({ message: `MCP server with ID '${serverId}' not found` });
}
+ // Check that the server is linked to this endpoint
+ const serverLink = await aiMcpEndpointServerDAL.findOne({
+ aiMcpEndpointId: endpointId,
+ aiMcpServerId: serverId
+ });
+
+ if (!serverLink) {
+ throw new BadRequestError({ message: "This MCP server is not linked to the specified endpoint" });
+ }
+
if (server.credentialMode !== AiMcpServerCredentialMode.PERSONAL) {
throw new BadRequestError({ message: "This server does not use personal credentials" });
}
@@ -823,9 +1120,6 @@ export const aiMcpEndpointServiceFactory = ({
projectId: endpoint.projectId,
url: server.url,
actorId,
- actor,
- actorAuthMethod,
- actorOrgId,
clientId: oauthConfig?.clientId,
clientSecret: oauthConfig?.clientSecret
});
@@ -835,23 +1129,49 @@ export const aiMcpEndpointServiceFactory = ({
const saveUserServerCredential = async ({
endpointId,
serverId,
- userId,
accessToken,
refreshToken,
expiresAt,
- tokenType
+ tokenType,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
}: TSaveUserServerCredentialDTO) => {
- // Verify endpoint and server exist
const endpoint = await aiMcpEndpointDAL.findById(endpointId);
if (!endpoint) {
throw new NotFoundError({ message: `MCP endpoint with ID '${endpointId}' not found` });
}
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: endpoint.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.AI
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionMcpEndpointActions.Connect,
+ ProjectPermissionSub.McpEndpoints
+ );
+
const server = await aiMcpServerDAL.findById(serverId);
if (!server) {
throw new NotFoundError({ message: `MCP server with ID '${serverId}' not found` });
}
+ // Check that the server is linked to this endpoint
+ const serverLink = await aiMcpEndpointServerDAL.findOne({
+ aiMcpEndpointId: endpointId,
+ aiMcpServerId: serverId
+ });
+
+ if (!serverLink) {
+ throw new BadRequestError({ message: "This MCP server is not linked to the specified endpoint" });
+ }
+
// Encrypt the credentials
const credentials = {
accessToken,
@@ -871,7 +1191,7 @@ export const aiMcpEndpointServiceFactory = ({
// Upsert the credential
await aiMcpServerUserCredentialDAL.upsertCredential({
- userId,
+ userId: actorId,
aiMcpServerId: serverId,
encryptedCredentials
});
diff --git a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-types.ts b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-types.ts
index c97e3adb44..ae7a092d79 100644
--- a/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-types.ts
+++ b/backend/src/ee/services/ai-mcp-endpoint/ai-mcp-endpoint-types.ts
@@ -1,9 +1,10 @@
+import { TProjectPermission } from "@app/lib/types";
+
export type TCreateAiMcpEndpointDTO = {
- projectId: string;
name: string;
description?: string;
serverIds?: string[];
-};
+} & TProjectPermission;
export type TUpdateAiMcpEndpointDTO = {
endpointId: string;
@@ -11,24 +12,22 @@ export type TUpdateAiMcpEndpointDTO = {
description?: string;
serverIds?: string[];
piiFiltering?: boolean;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TDeleteAiMcpEndpointDTO = {
endpointId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TGetAiMcpEndpointDTO = {
endpointId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TInteractWithMcpDTO = {
endpointId: string;
userId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
-export type TListAiMcpEndpointsDTO = {
- projectId: string;
-};
+export type TListAiMcpEndpointsDTO = TProjectPermission;
export type TAiMcpEndpointWithServers = {
id: string;
@@ -45,17 +44,17 @@ export type TAiMcpEndpointWithServers = {
export type TListEndpointToolsDTO = {
endpointId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TEnableEndpointToolDTO = {
endpointId: string;
serverToolId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TDisableEndpointToolDTO = {
endpointId: string;
serverToolId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TBulkUpdateEndpointToolsDTO = {
endpointId: string;
@@ -63,7 +62,7 @@ export type TBulkUpdateEndpointToolsDTO = {
serverToolId: string;
isEnabled: boolean;
}>;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TEndpointToolConfig = {
id: string;
@@ -96,7 +95,6 @@ export type TOAuthFinalizeDTO = {
redirectUri: string;
resource: string;
responseType: string;
- projectId: string;
path?: string;
expiry: string;
tokenId: string;
@@ -128,8 +126,7 @@ export type TOAuthTokenExchangeDTO = {
// Personal credentials types
export type TGetServersRequiringAuthDTO = {
endpointId: string;
- userId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TServerAuthStatus = {
id: string;
@@ -143,18 +140,13 @@ export type TServerAuthStatus = {
export type TInitiateServerOAuthDTO = {
endpointId: string;
serverId: string;
- actorId: string;
- actor: string;
- actorAuthMethod: string;
- actorOrgId: string;
-};
+} & Omit<TProjectPermission, "projectId">;
export type TSaveUserServerCredentialDTO = {
endpointId: string;
serverId: string;
- userId: string;
accessToken: string;
refreshToken?: string;
expiresAt?: number;
tokenType?: string;
-};
+} & Omit<TProjectPermission, "projectId">;
diff --git a/backend/src/ee/services/ai-mcp-server/ai-mcp-server-types.ts b/backend/src/ee/services/ai-mcp-server/ai-mcp-server-types.ts
index 97e5da0cba..38a107001f 100644
--- a/backend/src/ee/services/ai-mcp-server/ai-mcp-server-types.ts
+++ b/backend/src/ee/services/ai-mcp-server/ai-mcp-server-types.ts
@@ -85,9 +85,6 @@ export type TInitiateOAuthDTO = {
projectId: string;
url: string;
actorId: string;
- actor: string;
- actorAuthMethod: string;
- actorOrgId: string;
clientId?: string;
clientSecret?: string;
};
diff --git a/backend/src/ee/services/permission/default-roles.ts b/backend/src/ee/services/permission/default-roles.ts
index 561cb3bb55..e4dade13bd 100644
--- a/backend/src/ee/services/permission/default-roles.ts
+++ b/backend/src/ee/services/permission/default-roles.ts
@@ -28,6 +28,7 @@ import {
ProjectPermissionSecretScanningDataSourceActions,
ProjectPermissionSecretScanningFindingActions,
ProjectPermissionSecretSyncActions,
+ ProjectPermissionMcpEndpointActions,
ProjectPermissionSet,
ProjectPermissionSshHostActions,
ProjectPermissionSub
@@ -55,7 +56,9 @@ const buildAdminPermissionRules = () => {
ProjectPermissionSub.SshCertificateTemplates,
ProjectPermissionSub.SshHostGroups,
ProjectPermissionSub.PamFolders,
- ProjectPermissionSub.PamResources
+ ProjectPermissionSub.PamResources,
+ ProjectPermissionSub.McpServers,
+ ProjectPermissionSub.McpActivityLogs
].forEach((el) => {
can(
[
@@ -341,6 +344,17 @@ const buildAdminPermissionRules = () => {
can([ProjectPermissionPamSessionActions.Read], ProjectPermissionSub.PamSessions);
+ can(
+ [
+ ProjectPermissionMcpEndpointActions.Read,
+ ProjectPermissionMcpEndpointActions.Connect,
+ ProjectPermissionMcpEndpointActions.Create,
+ ProjectPermissionMcpEndpointActions.Edit,
+ ProjectPermissionMcpEndpointActions.Delete
+ ],
+ ProjectPermissionSub.McpEndpoints
+ );
+
can(
[ProjectPermissionApprovalRequestActions.Read, ProjectPermissionApprovalRequestActions.Create],
ProjectPermissionSub.ApprovalRequests
@@ -598,6 +612,10 @@ const buildMemberPermissionRules = () => {
ProjectPermissionSub.PamAccounts
);
+ can([ProjectPermissionMcpEndpointActions.Read], ProjectPermissionSub.McpEndpoints);
+ can([ProjectPermissionActions.Read], ProjectPermissionSub.McpServers);
+ can([ProjectPermissionActions.Read], ProjectPermissionSub.McpActivityLogs);
+
can([ProjectPermissionApprovalRequestActions.Create], ProjectPermissionSub.ApprovalRequests);
return rules;
@@ -667,6 +685,10 @@ const buildViewerPermissionRules = () => {
can([ProjectPermissionPamAccountActions.Read], ProjectPermissionSub.PamAccounts);
+ can([ProjectPermissionMcpEndpointActions.Read], ProjectPermissionSub.McpEndpoints);
+ can([ProjectPermissionActions.Read], ProjectPermissionSub.McpServers);
+ can([ProjectPermissionActions.Read], ProjectPermissionSub.McpActivityLogs);
+
return rules;
};
diff --git a/backend/src/ee/services/permission/project-permission.ts b/backend/src/ee/services/permission/project-permission.ts
index 85efd19aaa..e7f75f6589 100644
--- a/backend/src/ee/services/permission/project-permission.ts
+++ b/backend/src/ee/services/permission/project-permission.ts
@@ -224,6 +224,14 @@ export enum ProjectPermissionPamSessionActions {
// Terminate = "terminate"
}
+export enum ProjectPermissionMcpEndpointActions {
+ Read = "read",
+ Create = "create",
+ Edit = "edit",
+ Delete = "delete",
+ Connect = "connect"
+}
+
export enum ProjectPermissionApprovalRequestActions {
Read = "read",
Create = "create"
@@ -286,7 +294,10 @@ export enum ProjectPermissionSub {
PamSessions = "pam-sessions",
CertificateProfiles = "certificate-profiles",
ApprovalRequests = "approval-requests",
- ApprovalRequestGrants = "approval-request-grants"
+ ApprovalRequestGrants = "approval-request-grants",
+ McpEndpoints = "mcp-endpoints",
+ McpServers = "mcp-servers",
+ McpActivityLogs = "mcp-activity-logs"
}
export type SecretSubjectFields = {
@@ -506,6 +517,9 @@ export type ProjectPermissionSet =
ProjectPermissionSub.PamAccounts | (ForcedSubject<ProjectPermissionSub.PamAccounts> & PamAccountSubjectFields)
]
| [ProjectPermissionPamSessionActions, ProjectPermissionSub.PamSessions]
+ | [ProjectPermissionMcpEndpointActions, ProjectPermissionSub.McpEndpoints]
+ | [ProjectPermissionActions, ProjectPermissionSub.McpServers]
+ | [ProjectPermissionActions, ProjectPermissionSub.McpActivityLogs]
| [
ProjectPermissionCertificateProfileActions,
(
@@ -1120,6 +1134,24 @@ const GeneralPermissionSchema = [
"Describe what action an entity can take."
)
}),
+ z.object({
+ subject: z.literal(ProjectPermissionSub.McpEndpoints).describe("The entity this permission pertains to."),
+ action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionMcpEndpointActions).describe(
+ "Describe what action an entity can take."
+ )
+ }),
+ z.object({
+ subject: z.literal(ProjectPermissionSub.McpServers).describe("The entity this permission pertains to."),
+ action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
+ "Describe what action an entity can take."
+ )
+ }),
+ z.object({
+ subject: z.literal(ProjectPermissionSub.McpActivityLogs).describe("The entity this permission pertains to."),
+ action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionActions).describe(
+ "Describe what action an entity can take."
+ )
+ }),
z.object({
subject: z.literal(ProjectPermissionSub.ApprovalRequests).describe("The entity this permission pertains to."),
action: CASL_ACTION_SCHEMA_NATIVE_ENUM(ProjectPermissionApprovalRequestActions).describe(
diff --git a/backend/src/server/plugins/auth/inject-identity.ts b/backend/src/server/plugins/auth/inject-identity.ts
index 1230f9bcb2..d327462627 100644
--- a/backend/src/server/plugins/auth/inject-identity.ts
+++ b/backend/src/server/plugins/auth/inject-identity.ts
@@ -188,7 +188,7 @@ export const injectIdentity = fp(
}
case AuthMode.MCP_JWT: {
const { user, tokenVersionId, orgId, orgName, rootOrgId, parentOrgId } =
- await server.services.authToken.fnValidateJwtIdentity(token, subOrganizationSelector);
+ await server.services.authToken.fnValidateJwtIdentity(token);
requestContext.set("orgId", orgId);
requestContext.set("orgName", orgName);
requestContext.set("userAuthInfo", { userId: user.id, email: user.email || "" });
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 61daf6a24c..6966043fc3 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2517,7 +2517,8 @@ export const registerRoutes = async (
keyStore,
authTokenService: tokenService,
aiMcpActivityLogService,
- userDAL
+ userDAL,
+ permissionService
});
const migrationService = externalMigrationServiceFactory({
diff --git a/frontend/src/context/ProjectPermissionContext/types.ts b/frontend/src/context/ProjectPermissionContext/types.ts
index 0838b0c36c..025aff0656 100644
--- a/frontend/src/context/ProjectPermissionContext/types.ts
+++ b/frontend/src/context/ProjectPermissionContext/types.ts
@@ -228,6 +228,14 @@ export enum ProjectPermissionPamSessionActions {
// Terminate = "terminate"
}
+export enum ProjectPermissionMcpEndpointActions {
+ Read = "read",
+ Create = "create",
+ Edit = "edit",
+ Delete = "delete",
+ Connect = "connect"
+}
+
export enum ProjectPermissionApprovalRequestActions {
Read = "read",
Create = "create"
@@ -350,6 +358,9 @@ export enum ProjectPermissionSub {
PamResources = "pam-resources",
PamAccounts = "pam-accounts",
PamSessions = "pam-sessions",
+ McpEndpoints = "mcp-endpoints",
+ McpServers = "mcp-servers",
+ McpActivityLogs = "mcp-activity-logs",
ApprovalRequests = "approval-requests",
ApprovalRequestGrants = "approval-request-grants"
}
@@ -591,6 +602,9 @@ export type ProjectPermissionSet =
]
| [ProjectPermissionPamSessionActions, ProjectPermissionSub.PamSessions]
| [ProjectPermissionApprovalRequestActions, ProjectPermissionSub.ApprovalRequests]
- | [ProjectPermissionApprovalRequestGrantActions, ProjectPermissionSub.ApprovalRequestGrants];
+ | [ProjectPermissionApprovalRequestGrantActions, ProjectPermissionSub.ApprovalRequestGrants]
+ | [ProjectPermissionMcpEndpointActions, ProjectPermissionSub.McpEndpoints]
+ | [ProjectPermissionActions, ProjectPermissionSub.McpServers]
+ | [ProjectPermissionActions, ProjectPermissionSub.McpActivityLogs];
export type TProjectPermission = MongoAbility<ProjectPermissionSet>;
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
index 931d07cd62..2099ccb744 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
@@ -23,6 +23,7 @@ import {
ProjectPermissionGroupActions,
ProjectPermissionIdentityActions,
ProjectPermissionKmipActions,
+ ProjectPermissionMcpEndpointActions,
ProjectPermissionMemberActions,
ProjectPermissionPamAccountActions,
ProjectPermissionPamSessionActions,
@@ -260,6 +261,25 @@ const PamSessionPolicyActionSchema = z.object({
[ProjectPermissionPamSessionActions.Read]: z.boolean().optional()
});
+const McpEndpointPolicyActionSchema = z.object({
+ [ProjectPermissionMcpEndpointActions.Read]: z.boolean().optional(),
+ [ProjectPermissionMcpEndpointActions.Create]: z.boolean().optional(),
+ [ProjectPermissionMcpEndpointActions.Edit]: z.boolean().optional(),
+ [ProjectPermissionMcpEndpointActions.Delete]: z.boolean().optional(),
+ [ProjectPermissionMcpEndpointActions.Connect]: z.boolean().optional()
+});
+
+const McpServerPolicyActionSchema = z.object({
+ [ProjectPermissionActions.Read]: z.boolean().optional(),
+ [ProjectPermissionActions.Create]: z.boolean().optional(),
+ [ProjectPermissionActions.Edit]: z.boolean().optional(),
+ [ProjectPermissionActions.Delete]: z.boolean().optional()
+});
+
+const McpActivityLogPolicyActionSchema = z.object({
+ [ProjectPermissionActions.Read]: z.boolean().optional()
+});
+
const ApprovalRequestPolicyActionSchema = z.object({
[ProjectPermissionApprovalRequestActions.Read]: z.boolean().optional(),
[ProjectPermissionApprovalRequestActions.Create]: z.boolean().optional()
@@ -481,6 +501,9 @@ export const projectRoleFormSchema = z.object({
.array()
.default([]),
[ProjectPermissionSub.PamSessions]: PamSessionPolicyActionSchema.array().default([]),
+ [ProjectPermissionSub.McpEndpoints]: McpEndpointPolicyActionSchema.array().default([]),
+ [ProjectPermissionSub.McpServers]: McpServerPolicyActionSchema.array().default([]),
+ [ProjectPermissionSub.McpActivityLogs]: McpActivityLogPolicyActionSchema.array().default([]),
[ProjectPermissionSub.ApprovalRequests]: ApprovalRequestPolicyActionSchema.array().default(
[]
),
@@ -643,7 +666,10 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
ProjectPermissionSub.SecretEvents,
ProjectPermissionSub.AppConnections,
ProjectPermissionSub.PamFolders,
- ProjectPermissionSub.PamResources
+ ProjectPermissionSub.PamResources,
+ ProjectPermissionSub.McpEndpoints,
+ ProjectPermissionSub.McpServers,
+ ProjectPermissionSub.McpActivityLogs
].includes(subject)
) {
// from above statement we are sure it won't be undefined
@@ -1307,6 +1333,44 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
if (canRead) formVal[subject]![0][ProjectPermissionPamAccountActions.Read] = true;
}
+ if (subject === ProjectPermissionSub.McpEndpoints) {
+ const canRead = action.includes(ProjectPermissionMcpEndpointActions.Read);
+ const canCreate = action.includes(ProjectPermissionMcpEndpointActions.Create);
+ const canEdit = action.includes(ProjectPermissionMcpEndpointActions.Edit);
+ const canDelete = action.includes(ProjectPermissionMcpEndpointActions.Delete);
+ const canConnect = action.includes(ProjectPermissionMcpEndpointActions.Connect);
+
+ if (!formVal[subject]) formVal[subject] = [{}];
+
+ if (canRead) formVal[subject]![0][ProjectPermissionMcpEndpointActions.Read] = true;
+ if (canCreate) formVal[subject]![0][ProjectPermissionMcpEndpointActions.Create] = true;
+ if (canEdit) formVal[subject]![0][ProjectPermissionMcpEndpointActions.Edit] = true;
+ if (canDelete) formVal[subject]![0][ProjectPermissionMcpEndpointActions.Delete] = true;
+ if (canConnect) formVal[subject]![0][ProjectPermissionMcpEndpointActions.Connect] = true;
+ }
+
+ if (subject === ProjectPermissionSub.McpServers) {
+ const canRead = action.includes(ProjectPermissionActions.Read);
+ const canCreate = action.includes(ProjectPermissionActions.Create);
+ const canEdit = action.includes(ProjectPermissionActions.Edit);
+ const canDelete = action.includes(ProjectPermissionActions.Delete);
+
+ if (!formVal[subject]) formVal[subject] = [{}];
+
+ if (canRead) formVal[subject]![0][ProjectPermissionActions.Read] = true;
+ if (canCreate) formVal[subject]![0][ProjectPermissionActions.Create] = true;
+ if (canEdit) formVal[subject]![0][ProjectPermissionActions.Edit] = true;
+ if (canDelete) formVal[subject]![0][ProjectPermissionActions.Delete] = true;
+ }
+
+ if (subject === ProjectPermissionSub.McpActivityLogs) {
+ const canRead = action.includes(ProjectPermissionActions.Read);
+
+ if (!formVal[subject]) formVal[subject] = [{}];
+
+ if (canRead) formVal[subject]![0][ProjectPermissionActions.Read] = true;
+ }
+
if (subject === ProjectPermissionSub.ApprovalRequests) {
const canRead = action.includes(ProjectPermissionApprovalRequestActions.Read);
const canCreate = action.includes(ProjectPermissionApprovalRequestActions.Create);
@@ -2010,6 +2074,29 @@ export const PROJECT_PERMISSION_OBJECT: TProjectPermissionObject = {
{ label: "Read", value: ProjectPermissionApprovalRequestGrantActions.Read },
{ label: "Revoke", value: ProjectPermissionApprovalRequestGrantActions.Revoke }
]
+ },
+ [ProjectPermissionSub.McpEndpoints]: {
+ title: "MCP Endpoints",
+ actions: [
+ { label: "Read", value: ProjectPermissionMcpEndpointActions.Read },
+ { label: "Create", value: ProjectPermissionMcpEndpointActions.Create },
+ { label: "Modify", value: ProjectPermissionMcpEndpointActions.Edit },
+ { label: "Remove", value: ProjectPermissionMcpEndpointActions.Delete },
+ { label: "Connect", value: ProjectPermissionMcpEndpointActions.Connect }
+ ]
+ },
+ [ProjectPermissionSub.McpServers]: {
+ title: "MCP Servers",
+ actions: [
+ { label: "Read", value: ProjectPermissionActions.Read },
+ { label: "Create", value: ProjectPermissionActions.Create },
+ { label: "Modify", value: ProjectPermissionActions.Edit },
+ { label: "Remove", value: ProjectPermissionActions.Delete }
+ ]
+ },
+ [ProjectPermissionSub.McpActivityLogs]: {
+ title: "MCP Activity Logs",
+ actions: [{ label: "Read", value: ProjectPermissionActions.Read }]
}
};
@@ -2082,6 +2169,12 @@ const PamPermissionSubjects = (enabled = false) => ({
[ProjectPermissionSub.PamSessions]: enabled
});
+const AiPermissionSubjects = (enabled = false) => ({
+ [ProjectPermissionSub.McpEndpoints]: enabled,
+ [ProjectPermissionSub.McpServers]: enabled,
+ [ProjectPermissionSub.McpActivityLogs]: enabled
+});
+
// scott: this structure ensures we don't forget to add project permissions to their relevant project type
export const ProjectTypePermissionSubjects: Record<
ProjectType,
@@ -2095,6 +2188,7 @@ export const ProjectTypePermissionSubjects: Record<
...SshPermissionSubjects(),
...SecretScanningSubject(),
...PamPermissionSubjects(),
+ ...AiPermissionSubjects(),
[ProjectPermissionSub.AppConnections]: true
},
[ProjectType.KMS]: {
@@ -2105,6 +2199,7 @@ export const ProjectTypePermissionSubjects: Record<
...SshPermissionSubjects(),
...SecretScanningSubject(),
...PamPermissionSubjects(),
+ ...AiPermissionSubjects(),
[ProjectPermissionSub.AppConnections]: false
},
[ProjectType.CertificateManager]: {
@@ -2115,6 +2210,7 @@ export const ProjectTypePermissionSubjects: Record<
...SshPermissionSubjects(),
...SecretScanningSubject(),
...PamPermissionSubjects(),
+ ...AiPermissionSubjects(),
[ProjectPermissionSub.AppConnections]: true
},
[ProjectType.SSH]: {
@@ -2125,6 +2221,7 @@ export const ProjectTypePermissionSubjects: Record<
...SecretsManagerPermissionSubjects(),
...SecretScanningSubject(),
...PamPermissionSubjects(),
+ ...AiPermissionSubjects(),
[ProjectPermissionSub.AppConnections]: false
},
[ProjectType.SecretScanning]: {
@@ -2135,6 +2232,7 @@ export const ProjectTypePermissionSubjects: Record<
...KmsPermissionSubjects(),
...SecretsManagerPermissionSubjects(),
...PamPermissionSubjects(),
+ ...AiPermissionSubjects(),
[ProjectPermissionSub.AppConnections]: true
},
[ProjectType.PAM]: {
@@ -2145,6 +2243,7 @@ export const ProjectTypePermissionSubjects: Record<
...KmsPermissionSubjects(),
...SecretsManagerPermissionSubjects(),
...PamPermissionSubjects(true),
+ ...AiPermissionSubjects(),
[ProjectPermissionSub.AppConnections]: false
},
[ProjectType.AI]: {
@@ -2155,6 +2254,7 @@ export const ProjectTypePermissionSubjects: Record<
...SshPermissionSubjects(),
...SecretScanningSubject(),
...PamPermissionSubjects(),
+ ...AiPermissionSubjects(true),
[ProjectPermissionSub.AppConnections]: false
}
};
@@ -2628,7 +2728,5 @@ export const RoleTemplates: Record<ProjectType, RoleTemplate[]> = {
},
projectManagerTemplate()
],
- [ProjectType.AI]: [
- projectManagerTemplate()
- ]
+ [ProjectType.AI]: [projectManagerTemplate()]
};