Skip to content

Commit 2f6a2d6

Browse files
Adding MCP Tool Trigger Template (#4651)
* Adding MCP Tool Trigger Template * Updating the Node Template * Addresing code review comments * Addressing Code Review * Fixing the Javascript Template --------- Co-authored-by: Lilian Kasem <likasem@microsoft.com>
1 parent ecf2b57 commit 2f6a2d6

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
#### Changes
99

1010
- Add updated Durable .NET templates (#4692)
11+
- Adding the MCP Tool Trigger Templates for the Node/Typescript (#4651)
1112
- Set `AzureWebJobsStorage` to use the storage emulator by default on all platforms (#4685)

src/Cli/func/Common/TemplatesManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using System.Reflection;
@@ -134,7 +134,7 @@ private static async Task<IEnumerable<Template>> GetNodeV4TemplatesJson()
134134

135135
public async Task Deploy(string name, string fileName, Template template)
136136
{
137-
if (template.Id.EndsWith("JavaScript-4.x") || template.Id.EndsWith("TypeScript-4.x"))
137+
if (template.Id.EndsWith("JavaScript-4.x", StringComparison.OrdinalIgnoreCase) || template.Id.EndsWith("TypeScript-4.x", StringComparison.OrdinalIgnoreCase))
138138
{
139139
await DeployNewNodeProgrammingModel(name, fileName, template);
140140
}

src/Cli/func/StaticResources/node-v4-templates.json

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[
1+
[
22
{
33
"id": "BlobTrigger-JavaScript-4.x",
44
"runtime": "2",
@@ -614,5 +614,47 @@
614614
"enabledInTryMode": false,
615615
"userPrompt": []
616616
}
617+
},
618+
{
619+
"id": "McpToolTrigger-Typescript-4.x",
620+
"runtime": "2",
621+
"files": {
622+
"%functionName%.ts": "import { app, InvocationContext, arg } from \"@azure/functions\";\n\nexport async function mcpToolHello(_toolArguments: any, context: InvocationContext): Promise<string> {\n const mcptoolargs = _toolArguments.arguments as {\n name?: string;\n };\n const name = mcptoolargs?.name;\n\n console.info(`Hello ${name}, I am MCP Tool!`);\n\n return `Hello ${name}, I am MCP Tool!`;\n}\n\napp.mcpTool('hello', {\n toolName: 'hello',\n description: 'Simple hello world MCP Tool that responses with a hello message.',\n toolProperties: {\n name: arg.string().describe('Name to greet'),\n },\n handler: mcpToolHello\n});"
623+
},
624+
"metadata": {
625+
"defaultFunctionName": "mcpToolTrigger",
626+
"description": "$McpToolTrigger_description",
627+
"name": "MCP Tool Trigger",
628+
"language": "TypeScript",
629+
"triggerType": "mcpToolTrigger",
630+
"category": [
631+
"$temp_category_core",
632+
"$temp_category_dataProcessing"
633+
],
634+
"categoryStyle": "other",
635+
"enabledInTryMode": false,
636+
"userPrompt": []
637+
}
638+
},
639+
{
640+
"id": "McpToolTrigger-Javascript-4.x",
641+
"runtime": "2",
642+
"files": {
643+
"%functionName%.js": "const { app, arg } = require('@azure/functions');\n\nfunction mcpToolHello(_toolArguments, context) {\n const mcptoolargs = context.triggerMetadata.mcptoolargs || {};\n const name = mcptoolargs.name;\n console.info(`Hello ${name}, I am MCP Tool!`);\n return `Hello ${name}, I am MCP Tool!`;\n}\n\napp.mcpTool('hello', {\n toolName: 'hello',\n description: 'Simple hello world MCP Tool that responses with a hello message.',\n toolProperties:{\n name: arg.string().describe('Name to greet'),\n },\n handler: mcpToolHello\n});"
644+
},
645+
"metadata": {
646+
"defaultFunctionName": "mcpToolTrigger",
647+
"description": "$McpToolTrigger_description",
648+
"name": "MCP Tool Trigger",
649+
"language": "JavaScript",
650+
"triggerType": "mcpToolTrigger",
651+
"category": [
652+
"$temp_category_core",
653+
"$temp_category_dataProcessing"
654+
],
655+
"categoryStyle": "other",
656+
"enabledInTryMode": false,
657+
"userPrompt": []
658+
}
617659
}
618660
]

0 commit comments

Comments
 (0)