Demand forecast synchronization fails between Power Apps and Supply Planning module using dynamic MCP server

We’re experiencing persistent timeout issues when syncing demand forecasts from our custom Power Apps form to D365 Supply Planning module. The integration worked fine initially with small datasets, but now fails consistently after processing about 200-300 forecast records.

The Power Apps flow calls the MCP server endpoint, but we’re getting HTTP 504 timeout errors. Looking at the logs, it seems related to batch processing limits, but I’m not sure about the proper OAuth2 scope configuration for Supply Planning operations.


Error: Gateway Timeout (504)
Endpoint: /api/data/v9.2/msdyn_demandforecasts
Batch size: 500 records
Timeout after: 120 seconds

We need guidance on configuring batch sizes, pagination in Power Apps flows, and proper timeout settings. The delays are impacting our weekly planning cycles significantly. Has anyone successfully configured MCP server for large-volume demand forecast synchronization?

Good catch on the OAuth token refresh delay. Let me provide a comprehensive solution addressing all the key areas:

1. MCP Server Batch Size Configuration: Set your batch size to 50-75 records maximum for demand forecast operations. Navigate to System Administration > MCP Server Configuration > Batch Processing and update:


mcp.batch.demandForecast.maxSize=75
mcp.batch.demandForecast.timeout=180

2. Power Apps Flow Pagination Logic: Implement proper chunking in your Power Apps flow. Use the ‘Apply to each’ control with a concurrent limit of 1, and add a 5-second delay between batches:

  • Split your forecast dataset into arrays of 75 records
  • Process each chunk sequentially
  • Include error handling with retry logic (max 3 attempts)
  • Use ‘Scope’ controls to manage transaction boundaries

3. OAuth2 Scope Configuration: Update your Azure AD app registration to include these specific scopes:

  • Dynamics.SupplyChain.ReadWrite (REQUIRED for Supply Planning)
  • Dynamics.SupplyChain.DemandForecast.All
  • offline_access (for token refresh)

In your Power Apps connection, refresh the authentication to pick up the new scopes. This should reduce token refresh time from 15-20 seconds to under 2 seconds.

4. Request Timeout Tuning: Increase the MCP server request timeout in web.config:


<httpRuntime executionTimeout="180" />
<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="2147483647"/>
    </webServices>
  </scripting>
</system.web.extensions>

Also configure your Power Apps HTTP action timeout to 180 seconds to match.

5. Diagnostic Logging: Enable these logging categories in System Administration > MCP Configuration > Diagnostics:

  • MCP.DemandForecast.Sync (Level: Verbose)
  • MCP.OAuth.TokenRefresh (Level: Info)
  • MCP.Batch.Processing (Level: Info)

Monitor the logs for 24-48 hours to establish baseline performance metrics. You should see batch processing complete in 30-45 seconds per chunk with proper configuration.

Additional Recommendations:

  • Schedule large forecast uploads during off-peak hours (early morning)
  • Implement a status tracking table to monitor which batches have been processed
  • Consider using the Data Import/Export Framework (DIXF) for initial bulk loads over 5,000 records
  • Set up Application Insights alerts for MCP timeout events

After implementing these changes, your 500-record dataset should process in approximately 8-10 minutes total (7 batches × 75 seconds average per batch) with much higher reliability. The key is matching batch sizes to your MCP server capacity while ensuring proper OAuth scope configuration to eliminate token refresh delays.

Enabled diagnostic logging and found the issue - OAuth token refresh was taking 15-20 seconds per batch! Combined with processing time, we were hitting the timeout threshold. The scope configuration was indeed incomplete as James mentioned.

Thanks Sara. I’ve tried reducing batch size to 100 records, but still getting timeouts intermittently. The MCP server seems to struggle even with smaller batches during peak hours. Should I be looking at request timeout configuration on the D365 side as well? Also uncertain if my OAuth2 scope includes all necessary Supply Planning permissions.