Skip to content

Azure Functions template tools#1929

Open
anannya03 wants to merge 2 commits intomicrosoft:mainfrom
anannya03:azure-functions-get-lang-tool
Open

Azure Functions template tools#1929
anannya03 wants to merge 2 commits intomicrosoft:mainfrom
anannya03:azure-functions-get-lang-tool

Conversation

@anannya03
Copy link
Contributor

What does this PR do?

Adds a new Azure.Mcp.Tools.FunctionsTemplate toolset that enables AI agents to discover Azure Functions languages, scaffold new projects, and generate function code from templates.

functiontemplates_language_list - Lists supported programming languages (Python, TypeScript, Java, C#) with runtime versions, prerequisites, and init commands
functiontemplates_project_get - Returns project scaffold files (host.json, local.settings.json, package.json/requirements.txt) for a specified language
functiontemplates_template_get- Lists available triggers, input bindings, and output bindings; returns complete function code for a specific template

GitHub issue number?

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes using script at eng/scripts/Process-PackageReadMe.ps1. See Package README
    • Updated command list in /servers/Azure.Mcp.Server/docs/azmcp-commands.md and/or /docs/fabric-commands.md
    • Run .\eng\scripts\Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated test prompts in /servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

@anannya03 anannya03 requested review from a team as code owners March 4, 2026 10:24
@github-project-automation github-project-automation bot moved this to Untriaged in Azure MCP Server Mar 4, 2026
Copilot AI review requested due to automatic review settings March 4, 2026 10:24
@anannya03 anannya03 self-assigned this Mar 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Azure Functions template tool area (functiontemplates) to Azure MCP Server so agents can discover supported languages/runtime versions, scaffold a new Functions project, and fetch concrete function templates (source files) from a manifest + GitHub.

Changes:

  • Introduces Azure.Mcp.Tools.FunctionsTemplate with commands for language listing, project scaffolding, and template retrieval.
  • Implements FunctionTemplatesService to return static language metadata and fetch templates/files via CDN manifest + GitHub Contents API.
  • Wires the new area into Azure MCP Server and updates docs, consolidated tool mapping, and unit tests.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Services/IFunctionTemplatesService.cs Adds service contract for language/project/template retrieval.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Services/FunctionTemplatesService.cs Implements manifest fetching, GitHub file discovery, runtime-version placeholder replacement, and caching.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Options/FunctionTemplatesOptionDefinitions.cs Defines command-line options for language/template/runtimeVersion.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Options/ProjectGetOptions.cs Adds parsed options model for project get.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Options/TemplateGetOptions.cs Adds parsed options model for template get.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/LanguageListResult.cs Adds response model for supported languages.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/LanguageDetails.cs Adds per-language details model.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/LanguageInfo.cs Adds language metadata model (prereqs/commands/etc.).
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/RuntimeVersionInfo.cs Adds runtime version model (supported/preview/default/etc.).
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/ProjectTemplateResult.cs Adds response model for project scaffolding files + instructions.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/ProjectTemplateFile.cs Adds model for template file name/content payloads.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/TemplateManifest.cs Adds CDN manifest model.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/TemplateManifestEntry.cs Adds manifest entry model (repo URL, folder path, metadata).
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/TemplateListResult.cs Adds model for grouped template listing (triggers/inputs/outputs).
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/TemplateSummary.cs Adds summarized template listing model.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/FunctionTemplateResult.cs Adds model for full template payload (function files + project files + merge guidance).
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/TemplateParameter.cs Adds model for parameterized template placeholders.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Models/GitHubContentEntry.cs Adds model for GitHub Contents API responses.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Commands/FunctionTemplatesJsonContext.cs Adds STJ source-gen context for command responses.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Commands/Language/LanguageListCommand.cs Implements functiontemplates language list.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Commands/Project/ProjectGetCommand.cs Implements functiontemplates project get.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Commands/Template/TemplateGetCommand.cs Implements functiontemplates template get (list mode vs get mode).
tools/Azure.Mcp.Tools.FunctionsTemplate/src/FunctionTemplatesSetup.cs Registers DI + command groups for the new area.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/GlobalUsings.cs Adds global using for System.CommandLine.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/AssemblyInfo.cs Exposes internals to unit/live tests.
tools/Azure.Mcp.Tools.FunctionsTemplate/src/Azure.Mcp.Tools.FunctionsTemplate.csproj Adds the new tool project (AOT compatible).
tools/Azure.Mcp.Tools.FunctionsTemplate/tests/Azure.Mcp.Tools.FunctionsTemplate.UnitTests/Azure.Mcp.Tools.FunctionsTemplate.UnitTests.csproj Adds a new unit test project for the toolset.
tools/Azure.Mcp.Tools.FunctionsTemplate/tests/Azure.Mcp.Tools.FunctionsTemplate.UnitTests/Language/LanguageListCommandTests.cs Adds unit tests for language list command behavior + serialization shape.
tools/Azure.Mcp.Tools.FunctionsTemplate/tests/Azure.Mcp.Tools.FunctionsTemplate.UnitTests/Project/ProjectGetCommandTests.cs Adds unit tests for project scaffold retrieval behavior + errors.
tools/Azure.Mcp.Tools.FunctionsTemplate/tests/Azure.Mcp.Tools.FunctionsTemplate.UnitTests/Template/TemplateGetCommandTests.cs Adds unit tests for template list/get modes, error handling, and option binding.
servers/Azure.Mcp.Server/src/Program.cs Registers the new FunctionsTemplate area in the server.
servers/Azure.Mcp.Server/src/Resources/consolidated-tools.json Adds a consolidated tool mapping for the new toolset.
servers/Azure.Mcp.Server/docs/e2eTestPrompts.md Adds e2e prompts for the new tools.
servers/Azure.Mcp.Server/docs/azmcp-commands.md Documents the new CLI commands and options.
servers/Azure.Mcp.Server/changelog-entries/1772614565846.yaml Adds changelog entry for the new toolset.
servers/Azure.Mcp.Server/README.md Adds the new tool area to the server README list.
Microsoft.Mcp.slnx Includes the new tool + unit test projects in the solution.
.github/CODEOWNERS Adds ownership rules/labels for the new tool directory.

Comment on lines 1074 to +1076
- ⚡ **Azure Functions** - Function App management
- 🔑 **Azure Key Vault** - Secrets, keys, and certificates
- � **Azure Functions Templates** - Function project templates, language support, and template source code
- �🔑 **Azure Key Vault** - Secrets, keys, and certificates
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new list entries contain replacement characters ("�"), which indicates an encoding/copy/paste issue and will render incorrectly in the README. Replace them with the intended icons/text (or remove the icons) and keep the bullet formatting consistent with the surrounding list.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +26
public const string LanguageName = "language";
public const string RuntimeVersionName = "runtimeVersion";
public const string TemplateName = "template";

public static readonly Option<string> Language = new($"--{LanguageName}")
{
Description = "Programming language for the Azure Functions project. " +
"Valid values: python, typescript, java, csharp.",
Required = true
};

public static readonly Option<string> RuntimeVersion = new($"--{RuntimeVersionName}")
{
Description = "Optional runtime version for the project. " +
"For Java: JDK version (8, 11, 17, 21, 25). " +
"For TypeScript: Node.js version (20, 22, 24). " +
"When provided, template placeholders like {{javaVersion}} or {{nodeVersion}} are replaced automatically.",
Required = false
};
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeVersionName is defined as "runtimeVersion" which makes the actual option token --runtimeVersion, but the rest of the repo’s CLI options use kebab-case (e.g., --resource-group) and the updated docs use --runtime-version. This mismatch will make the documented CLI invocation fail. Rename the option name constant (and the option alias) to runtime-version (and consider adding --runtimeVersion as an alias for backwards-compat), then update parsing/tests/docs to match.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +26
private const string ManifestUrl = "https://cdn-test.functions.azure.com/public/templates/manifest.json";
private const string FunctionsRuntimeVersion = "4.x";
private const string ExtensionBundleVersion = "[4.*, 5.0.0)";
private const string DefaultBranch = "main";
private const long MaxFileSizeBytes = 1_048_576; // 1 MB
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ManifestUrl points at https://cdn-test.functions.azure.com/..., which appears to be a test/staging endpoint. Shipping this in the production server could cause reliability issues or unexpected data changes. Consider switching to the production CDN endpoint (or making the manifest base URL configurable via settings/env with a safe default).

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +10
/// Represents the CDN manifest containing all available Azure Functions templates.
/// Fetched from the CDN endpoint (e.g., https://cdn-test.functions.azure.com/public/templates/manifest.json).
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment/doc here references https://cdn-test.functions.azure.com/... as the CDN endpoint. If the service is intended to use a production manifest URL, this documentation will be misleading and should be updated alongside the actual ManifestUrl constant.

Suggested change
/// Represents the CDN manifest containing all available Azure Functions templates.
/// Fetched from the CDN endpoint (e.g., https://cdn-test.functions.azure.com/public/templates/manifest.json).
/// Represents the CDN manifest containing all available Azure Functions templates,
/// fetched from a configured CDN endpoint that serves the templates manifest.

Copilot uses AI. Check for mistakes.
Comment on lines +1428 to +1434
[--runtime-version <runtime-version>]

# List all available function templates for a language or get the complete source code for a specific template
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp functiontemplates template get --language <language> \
[--template <template-name>] \
[--runtime-version <runtime-version>]
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation uses --runtime-version, but the tool option is currently defined as --runtimeVersion in FunctionTemplatesOptionDefinitions. Align the docs with the actual option name (preferably kebab-case to match other azmcp commands).

Suggested change
[--runtime-version <runtime-version>]
# List all available function templates for a language or get the complete source code for a specific template
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp functiontemplates template get --language <language> \
[--template <template-name>] \
[--runtime-version <runtime-version>]
[--runtimeVersion <runtime-version>]
# List all available function templates for a language or get the complete source code for a specific template
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp functiontemplates template get --language <language> \
[--template <template-name>] \
[--runtimeVersion <runtime-version>]

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants