Skip to main content
Glama
aj47
by aj47
index.ts4.16 kB
/** * Permission Management Tools * Tools for checking and managing macOS system permissions */ import { z } from 'zod'; import { permissionsManager } from '../../lib/permissions.js'; import type { ToolResult } from '../../types/index.js'; /** * Check permission status */ export const checkPermission = { name: 'check_permission', description: 'Check the status of a specific macOS system permission.', inputSchema: z.object({ permission: z .enum(['accessibility', 'screen-capture', 'input-monitoring', 'camera', 'microphone']) .describe('The permission type to check'), }), handler: async (args: { permission: string }): Promise<ToolResult> => { try { const info = permissionsManager.getPermissionInfo(args.permission as any); return { content: [ { type: 'text', text: JSON.stringify(info, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } }, }; /** * Check all permissions */ export const checkAllPermissions = { name: 'check_all_permissions', description: 'Check the status of all required macOS system permissions.', inputSchema: z.object({}), handler: async (): Promise<ToolResult> => { try { const required = [ 'accessibility', 'screen-capture', 'input-monitoring', ] as const; const results = permissionsManager.checkAllPermissions([...required]); const output: any = {}; for (const [type, info] of results) { output[type] = info; } return { content: [ { type: 'text', text: JSON.stringify(output, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } }, }; /** * Get permission instructions */ export const getPermissionInstructions = { name: 'get_permission_instructions', description: 'Get instructions for granting a specific macOS system permission.', inputSchema: z.object({ permission: z .enum(['accessibility', 'screen-capture', 'input-monitoring', 'camera', 'microphone']) .describe('The permission type'), }), handler: async (args: { permission: string }): Promise<ToolResult> => { try { const instructions = permissionsManager.getPermissionInstructions(args.permission as any); return { content: [ { type: 'text', text: instructions, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } }, }; /** * Request permission */ export const requestPermission = { name: 'request_permission', description: 'Request a specific macOS system permission. ' + 'This will show a system dialog if the permission has not been determined yet.', inputSchema: z.object({ permission: z .enum(['accessibility', 'screen-capture', 'input-monitoring', 'camera', 'microphone']) .describe('The permission type to request'), }), handler: async (args: { permission: string }): Promise<ToolResult> => { try { const status = await permissionsManager.requestPermission(args.permission as any); return { content: [ { type: 'text', text: `Permission request result: ${status}`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } }, }; // Export all permission tools export const permissionTools = [ checkPermission, checkAllPermissions, getPermissionInstructions, requestPermission, ];

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/aj47/electron-native-mcp'

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