Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

manage_powerpages_webapi_config

Configure PowerPages WebAPI access and table permissions to control data exposure and security settings for portal users.

Instructions

Manage PowerPages WebAPI configurations and table permissions. Add/remove WebAPI access for tables, configure table permissions, and check configuration status for PowerPages portals.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTypeNoAccess type for the permissionGlobal
fieldsNoFields to expose via WebAPI (default: '*' for all fields)*
operationYesType of configuration operation to perform
permissionNameNoName for the table permission
privilegesNoPrivileges to grant
projectPathNoPath to PowerPages project (defaults to current directory)
tableNameNoLogical name of the table (e.g., 'cr7ae_creditcardses', 'contacts')
webRoleNameNoWeb role name (default: 'Authenticated Users')Authenticated Users

Implementation Reference

  • Registration of the 'manage_powerpages_webapi_config' tool using server.registerTool, including schema and handler.
    server.registerTool( "manage_powerpages_webapi_config", { title: "Manage PowerPages WebAPI Configuration", description: "Manage PowerPages WebAPI configurations and table permissions. Add/remove WebAPI access for tables, configure table permissions, and check configuration status for PowerPages portals.", inputSchema: { operation: z.enum([ "add_webapi_config", "remove_webapi_config", "list_webapi_configs", "add_table_permission", "remove_table_permission", "list_table_permissions", "check_config_status" ]).describe("Type of configuration operation to perform"), // WebAPI configuration parameters tableName: z.string().optional().describe("Logical name of the table (e.g., 'cr7ae_creditcardses', 'contacts')"), fields: z.string().default("*").describe("Fields to expose via WebAPI (default: '*' for all fields)"), // Table permission parameters permissionName: z.string().optional().describe("Name for the table permission"), webRoleName: z.string().default("Authenticated Users").describe("Web role name (default: 'Authenticated Users')"), accessType: z.enum(["Global", "Contact", "Account", "Parent"]).default("Global").describe("Access type for the permission"), privileges: z.array(z.enum(["Create", "Read", "Write", "Delete", "Append", "AppendTo"])).default(["Read"]).describe("Privileges to grant"), // General parameters projectPath: z.string().optional().describe("Path to PowerPages project (defaults to current directory)") } }, async (params: any) => { try { const projectPath = params.projectPath || process.cwd(); const siteDir = path.join(projectPath, '.powerpages-site'); if (!fs.existsSync(siteDir)) { throw new Error(`.powerpages-site directory not found at ${siteDir}. This tool should be run from a PowerPages Code Site project root.`); } const siteSettingsPath = path.join(siteDir, 'sitesetting.yml'); const webRolesPath = path.join(siteDir, 'webrole.yml'); const tablePermissionsDir = path.join(siteDir, 'table-permissions'); let result = ''; switch (params.operation) { case 'add_webapi_config': if (!params.tableName) { throw new Error('tableName is required for add_webapi_config operation'); } result = await addWebAPIConfig(siteSettingsPath, params.tableName, params.fields); break; case 'remove_webapi_config': if (!params.tableName) { throw new Error('tableName is required for remove_webapi_config operation'); } result = await removeWebAPIConfig(siteSettingsPath, params.tableName); break; case 'list_webapi_configs': result = await listWebAPIConfigs(siteSettingsPath); break; case 'add_table_permission': if (!params.tableName || !params.permissionName) { throw new Error('tableName and permissionName are required for add_table_permission operation'); } result = await addTablePermission( tablePermissionsDir, webRolesPath, params.tableName, params.permissionName, params.webRoleName, params.accessType, params.privileges ); break; case 'remove_table_permission': if (!params.permissionName) { throw new Error('permissionName is required for remove_table_permission operation'); } result = await removeTablePermission(tablePermissionsDir, params.permissionName); break; case 'list_table_permissions': result = await listTablePermissions(tablePermissionsDir); break; case 'check_config_status': if (!params.tableName) { throw new Error('tableName is required for check_config_status operation'); } result = await checkConfigStatus(siteSettingsPath, tablePermissionsDir, params.tableName); break; default: throw new Error(`Unsupported operation: ${params.operation}`); } return { content: [ { type: "text", text: result } ] }; } catch (error) { return { content: [ { type: "text", text: `Error managing PowerPages configuration: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } ); }
  • The core handler function that switches on the 'operation' param to perform actions like adding/removing WebAPI configs and table permissions by reading/writing YAML files in the PowerPages site directory.
    async (params: any) => { try { const projectPath = params.projectPath || process.cwd(); const siteDir = path.join(projectPath, '.powerpages-site'); if (!fs.existsSync(siteDir)) { throw new Error(`.powerpages-site directory not found at ${siteDir}. This tool should be run from a PowerPages Code Site project root.`); } const siteSettingsPath = path.join(siteDir, 'sitesetting.yml'); const webRolesPath = path.join(siteDir, 'webrole.yml'); const tablePermissionsDir = path.join(siteDir, 'table-permissions'); let result = ''; switch (params.operation) { case 'add_webapi_config': if (!params.tableName) { throw new Error('tableName is required for add_webapi_config operation'); } result = await addWebAPIConfig(siteSettingsPath, params.tableName, params.fields); break; case 'remove_webapi_config': if (!params.tableName) { throw new Error('tableName is required for remove_webapi_config operation'); } result = await removeWebAPIConfig(siteSettingsPath, params.tableName); break; case 'list_webapi_configs': result = await listWebAPIConfigs(siteSettingsPath); break; case 'add_table_permission': if (!params.tableName || !params.permissionName) { throw new Error('tableName and permissionName are required for add_table_permission operation'); } result = await addTablePermission( tablePermissionsDir, webRolesPath, params.tableName, params.permissionName, params.webRoleName, params.accessType, params.privileges ); break; case 'remove_table_permission': if (!params.permissionName) { throw new Error('permissionName is required for remove_table_permission operation'); } result = await removeTablePermission(tablePermissionsDir, params.permissionName); break; case 'list_table_permissions': result = await listTablePermissions(tablePermissionsDir); break; case 'check_config_status': if (!params.tableName) { throw new Error('tableName is required for check_config_status operation'); } result = await checkConfigStatus(siteSettingsPath, tablePermissionsDir, params.tableName); break; default: throw new Error(`Unsupported operation: ${params.operation}`); } return { content: [ { type: "text", text: result } ] }; } catch (error) { return { content: [ { type: "text", text: `Error managing PowerPages configuration: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } } );
  • Input schema using Zod defining parameters for all supported operations.
    operation: z.enum([ "add_webapi_config", "remove_webapi_config", "list_webapi_configs", "add_table_permission", "remove_table_permission", "list_table_permissions", "check_config_status" ]).describe("Type of configuration operation to perform"), // WebAPI configuration parameters tableName: z.string().optional().describe("Logical name of the table (e.g., 'cr7ae_creditcardses', 'contacts')"), fields: z.string().default("*").describe("Fields to expose via WebAPI (default: '*' for all fields)"), // Table permission parameters permissionName: z.string().optional().describe("Name for the table permission"), webRoleName: z.string().default("Authenticated Users").describe("Web role name (default: 'Authenticated Users')"), accessType: z.enum(["Global", "Contact", "Account", "Parent"]).default("Global").describe("Access type for the permission"), privileges: z.array(z.enum(["Create", "Read", "Write", "Delete", "Append", "AppendTo"])).default(["Read"]).describe("Privileges to grant"), // General parameters projectPath: z.string().optional().describe("Path to PowerPages project (defaults to current directory)") } },
  • Helper function to add WebAPI configuration (enabled and fields) to the site settings YAML file.
    async function addWebAPIConfig(siteSettingsPath: string, tableName: string, fields: string): Promise<string> { const siteSettings = readYamlFile(siteSettingsPath); // Check if WebAPI settings already exist const enabledSetting = siteSettings.find(s => s.adx_name === `Webapi/${tableName}/enabled`); const fieldsSetting = siteSettings.find(s => s.adx_name === `Webapi/${tableName}/fields`); let addedSettings: string[] = []; if (!enabledSetting) { siteSettings.push({ adx_name: `Webapi/${tableName}/enabled`, adx_sitesettingid: generateGuid(), adx_source: 0, adx_value: true }); addedSettings.push(`Webapi/${tableName}/enabled`); } if (!fieldsSetting) { siteSettings.push({ adx_name: `Webapi/${tableName}/fields`, adx_sitesettingid: generateGuid(), adx_source: 0, adx_value: fields }); addedSettings.push(`Webapi/${tableName}/fields`); } if (addedSettings.length > 0) { writeYamlFile(siteSettingsPath, siteSettings); return `Successfully added WebAPI configuration for table '${tableName}':\n- ${addedSettings.join('\n- ')}\n\nNext steps:\n1. Add table permissions for this table\n2. Deploy the configuration using 'pac pages upload-code-site'`; } else { return `WebAPI configuration for table '${tableName}' already exists.`; } }
  • src/index.ts:237-237 (registration)
    Call to register the tool during server initialization.
    managePowerPagesWebAPIConfigTool(server, dataverseClient);

Other Tools

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/mwhesse/mcp-dataverse'

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