Skip to main content
Glama
cfdude

Mac Shell MCP Server

update_security_level

Modify the security classification of approved macOS terminal commands to control execution permissions and access restrictions.

Instructions

Update the security level of a whitelisted command

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe command to update
securityLevelYesNew security level for the command

Implementation Reference

  • Primary MCP tool handler: validates input with Zod schema, maps security level string to enum, delegates to CommandService.updateSecurityLevel, returns confirmation message.
    private async handleUpdateSecurityLevel(args: unknown) {
      const schema = z.object({
        command: z.string(),
        securityLevel: z.enum(['safe', 'requires_approval', 'forbidden']),
      });
    
      const { command, securityLevel } = schema.parse(args);
    
      // Map string security level to enum
      const securityLevelEnum =
        securityLevel === 'safe'
          ? CommandSecurityLevel.SAFE
          : securityLevel === 'requires_approval'
            ? CommandSecurityLevel.REQUIRES_APPROVAL
            : CommandSecurityLevel.FORBIDDEN;
    
      this.commandService.updateSecurityLevel(command, securityLevelEnum);
    
      return {
        content: [
          {
            type: 'text',
            text: `Security level for command '${command}' updated to '${securityLevel}'`,
          },
        ],
      };
    }
  • Core logic implementation: retrieves the whitelist entry for the command, updates its securityLevel, and stores it back in the whitelist Map.
    public updateSecurityLevel(command: string, securityLevel: CommandSecurityLevel): void {
      const entry = this.whitelist.get(command);
      if (entry) {
        entry.securityLevel = securityLevel;
        this.whitelist.set(command, entry);
      }
    }
  • src/index.ts:142-160 (registration)
    Tool registration in the ListTools response: defines name, description, and input schema for MCP protocol compliance.
    {
      name: 'update_security_level',
      description: 'Update the security level of a whitelisted command',
      inputSchema: {
        type: 'object',
        properties: {
          command: {
            type: 'string',
            description: 'The command to update',
          },
          securityLevel: {
            type: 'string',
            enum: ['safe', 'requires_approval', 'forbidden'],
            description: 'New security level for the command',
          },
        },
        required: ['command', 'securityLevel'],
      },
    },
  • Zod schema used in handler for runtime input validation, matching the declared inputSchema.
    const schema = z.object({
      command: z.string(),
      securityLevel: z.enum(['safe', 'requires_approval', 'forbidden']),
    });
  • Type definition enum for CommandSecurityLevel used throughout the implementation.
    export enum CommandSecurityLevel {
      /** Safe commands that can be executed without approval */
      SAFE = 'safe',
      /** Commands that require approval before execution */
      REQUIRES_APPROVAL = 'requires_approval',
      /** Commands that are explicitly forbidden */
      FORBIDDEN = 'forbidden',
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cfdude/mac-shell-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server