Skip to main content
Glama
mwhesse

Dataverse MCP Server

by mwhesse

Manage PowerPages WebAPI Configuration

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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it lists operations like 'add/remove' and 'configure', it doesn't describe what these operations actually do behaviorally - whether they make permanent changes, require specific permissions, have side effects, or return specific output formats. For a tool with 8 parameters and multiple mutation operations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in a single sentence that front-loads the main purpose. It lists key operations without unnecessary elaboration. However, it could be slightly more concise by avoiding the repetition of 'PowerPages' and 'configuration'.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 8 parameters, multiple operation types (including mutations), and no output schema, the description is insufficient. It doesn't explain what the tool returns, how different operations interact, or what happens when configurations are modified. Without annotations to provide behavioral context, the description should do more to compensate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description mentions 'add/remove WebAPI access for tables' and 'configure table permissions' which loosely maps to some parameters but doesn't add meaningful semantic context beyond what's in the schema. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('manage', 'add/remove', 'configure', 'check') and resources ('PowerPages WebAPI configurations and table permissions'). It distinguishes itself from siblings by focusing on PowerPages-specific WebAPI configuration rather than general Dataverse operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for PowerPages portal configuration but doesn't provide explicit guidance on when to use this tool versus alternatives. No sibling tools are mentioned, and there's no discussion of prerequisites or exclusions for specific operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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