Handle rate limiting, add runtime config and live tests for Functions toolset#2071
Handle rate limiting, add runtime config and live tests for Functions toolset#2071
Conversation
- Fetch templates manifest from Azure CDN with GitHub fallback - Add runtime version configuration to language metadata - Add FunctionsCacheDurations for 12-hour template caching - Add rate limit handling for GitHub template downloads - Remove deprecated GitHubContentEntry model - Add TemplateManifest model for CDN manifest structure - Refactor FunctionsService and LanguageMetadataProvider for CDN support - Update unit tests for new HTTP-based manifest fetching - Add live tests for language list and template get commands Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR enhances the Azure Functions toolset by sourcing runtime version metadata from the CDN manifest, switching template file retrieval to GitHub’s Tree API (with caching), and adding recorded live tests to validate end-to-end behavior.
Changes:
- Fetch runtime versions from
manifest.jsonand expose them viafunctions_language_list(and related metadata flows). - Refactor template file fetching to use GitHub Tree API + raw URLs, add caching, and improve error handling for rate limit/network cases.
- Add a new recorded live test project for Functions with tests covering language listing and template retrieval.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Functions/src/Services/FunctionsService.cs | Implements Tree API fetching, caching, and rate limit/network error handling; adds Tree API models and JSON context entries. |
| tools/Azure.Mcp.Tools.Functions/src/Services/LanguageMetadataProvider.cs | Splits static language metadata from runtime versions; builds runtime-version-driven template parameters. |
| tools/Azure.Mcp.Tools.Functions/src/Services/ILanguageMetadataProvider.cs | Extends API to accept optional manifest runtime versions for language info/validation. |
| tools/Azure.Mcp.Tools.Functions/src/Services/ManifestService.cs | Uses centralized cache duration for manifest caching. |
| tools/Azure.Mcp.Tools.Functions/src/Services/FunctionsCacheDurations.cs | Adds 12-hour cache duration constant used across Functions services. |
| tools/Azure.Mcp.Tools.Functions/src/Models/TemplateManifest.cs | Adds runtimeVersions to the manifest model. |
| tools/Azure.Mcp.Tools.Functions/src/Models/GitHubContentEntry.cs | Removes Contents API model (no longer used). |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.UnitTests/Services/FunctionsServiceTests.cs | Removes tests tied to deleted Contents API URL builder. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.UnitTests/Services/FunctionsServiceHttpTests.cs | Updates service construction for caching; adds Tree API error handling tests. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.UnitTests/Language/LanguageListCommandTests.cs | Updates deserialization validation to include manifest-provided runtime versions. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.LiveTests/Azure.Mcp.Tools.Functions.LiveTests.csproj | Adds new Functions live test project. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.LiveTests/assets.json | Adds recorded-test assets configuration. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.LiveTests/BaseFunctionsCommandLiveTests.cs | Adds recorded-test base class for Functions live tests. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.LiveTests/Language/LanguageListCommandLiveTests.cs | Adds live tests for language list + runtime versions + template parameters. |
| tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.LiveTests/Template/TemplateGetCommandLiveTests.cs | Adds live tests for listing templates and fetching template files (incl. runtime-version replacement). |
| servers/Azure.Mcp.Server/changelog-entries/1773697825677.yaml | Adds changelog entry for Functions toolset enhancements. |
- Add MaxTreeSizeBytes (5MB) size limit for Tree API response to prevent OOM - Add IsRateLimited() helper to check X-RateLimit-Remaining header for 403 - Handle truncated tree response with warning log - Move GitHubTreeResponse and GitHubTreeItem to separate model files - Refactor live tests for better recording coverage (20 recorded vs 1 skipped) - Add implicit cache verification test using test proxy recordings Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
- Add null checks for httpClientFactory and logger with _ prefix - Add using System.Net and use HttpStatusCode.TooManyRequests - Make FetchTemplateFilesAsync private (only used internally) - Add catch for InvalidOperationException in ManifestService - Change changelog section to Other Changes - Add comment documenting raw.githubusercontent.com rate limiting (~5000/hr) - Remove unused ConvertToRawGitHubUrl method - Consolidate FunctionTemplatesManifestJsonContext into FunctionsJsonContext - Remove redundant [JsonPropertyName] attributes from 11 model files - Fix tests to use FunctionsJsonContext for serialization - Create HttpClientHelper for User-Agent with real assembly version - Add doc comments explaining [LiveTestOnly] pattern in live tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
HttpClientFactoryConfigurator in core already sets User-Agent header:
azmcp/{version} azmcp-{transport}/{version} (framework; os)
Removed redundant HttpClientHelper and its tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run mcp - pullrequest - live |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@manvkaur, please run all the three mcp tools locally using MCP server to make sure that nothing has broken and there are no regressions. |
@anannya03 - Yes, I did test with random prompts as well, but here is the summary using E2E prompts you added in initial PR:
Test Summary:
|
|
Looks good. :) |
… toolset (microsoft#2071) * Refactor Functions toolset: CDN manifest, rate limiting, and live tests - Fetch templates manifest from Azure CDN with GitHub fallback - Add runtime version configuration to language metadata - Add FunctionsCacheDurations for 12-hour template caching - Add rate limit handling for GitHub template downloads - Remove deprecated GitHubContentEntry model - Add TemplateManifest model for CDN manifest structure - Refactor FunctionsService and LanguageMetadataProvider for CDN support - Update unit tests for new HTTP-based manifest fetching - Add live tests for language list and template get commands Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add changelog entry for Functions toolset improvements Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address Copilot code review feedback for Functions toolset - Add MaxTreeSizeBytes (5MB) size limit for Tree API response to prevent OOM - Add IsRateLimited() helper to check X-RateLimit-Remaining header for 403 - Handle truncated tree response with warning log - Move GitHubTreeResponse and GitHubTreeItem to separate model files - Refactor live tests for better recording coverage (20 recorded vs 1 skipped) - Add implicit cache verification test using test proxy recordings Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Mark cache-dependent Functions tests as LiveTestOnly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review feedback for Functions toolset - Add null checks for httpClientFactory and logger with _ prefix - Add using System.Net and use HttpStatusCode.TooManyRequests - Make FetchTemplateFilesAsync private (only used internally) - Add catch for InvalidOperationException in ManifestService - Change changelog section to Other Changes - Add comment documenting raw.githubusercontent.com rate limiting (~5000/hr) - Remove unused ConvertToRawGitHubUrl method - Consolidate FunctionTemplatesManifestJsonContext into FunctionsJsonContext - Remove redundant [JsonPropertyName] attributes from 11 model files - Fix tests to use FunctionsJsonContext for serialization - Create HttpClientHelper for User-Agent with real assembly version - Add doc comments explaining [LiveTestOnly] pattern in live tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove HttpClientHelper - factory already sets User-Agent HttpClientFactoryConfigurator in core already sets User-Agent header: azmcp/{version} azmcp-{transport}/{version} (framework; os) Removed redundant HttpClientHelper and its tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What does this PR do?
Handle GitHub API rate limiting, add runtime configuration, and live tests for Azure Functions toolset.
Key Fixes:
Rate Limiting Handling:
X-RateLimit-Remaining: 0header (distinguishes from 403 permission errors)Runtime Configuration:
runtimeVersionswith supported, preview, and default versions from CDN manifestTemplate Fetching (Tree API):
MaxTreeSizeBytes)Live Tests:
[LiveTestOnly]- run only in Live modeFiles Changed:
FunctionsService,ManifestService[JsonPropertyName]from 11 filesFunctionsJsonContextGitHub issue number?
Related #1781
Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.md.\eng\scripts\Update-AzCommandsMetadata.ps1