From 181484476b9ce1770c39de0bf8092615fe24609d Mon Sep 17 00:00:00 2001 From: Swapnil Nagar Date: Fri, 31 Oct 2025 15:02:31 -0700 Subject: [PATCH 1/2] Mcp Tool Trigger Template --- .../nodejs-4.x/templates/templates.json | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/resources/backupTemplates/nodejs-4.x/templates/templates.json b/resources/backupTemplates/nodejs-4.x/templates/templates.json index 0f911466d..42cc511c6 100644 --- a/resources/backupTemplates/nodejs-4.x/templates/templates.json +++ b/resources/backupTemplates/nodejs-4.x/templates/templates.json @@ -614,5 +614,47 @@ "enabledInTryMode": false, "userPrompt": [] } + }, + { + "id": "McpToolTrigger-JavaScript-4.x", + "runtime": "2", + "files": { + "%functionName%.js": "import { app } from \"@azure/functions\";\n\nconst PROPERTY_TYPE = \"string\";\n\n// Hello function - responds with hello message\nexport async function mcpToolHello(_toolArguments, context) {\n // Get name from the tool arguments\n const mcptoolargs = context.triggerMetadata.mcptoolargs || {};\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\n// Register the hello tool\napp.mcpTool('hello', {\n toolName: 'hello',\n description: 'Simple hello world MCP Tool that responses with a hello message.',\n toolProperties: [\n {\n propertyName: \"name\",\n propertyType: PROPERTY_TYPE,\n description: \"Required property to identify the caller.\",\n isRequired: true,\n }\n ],\n handler: mcpToolHello\n});" + }, + "metadata": { + "defaultFunctionName": "mcpToolTrigger", + "description": "$McpToolTrigger_description", + "name": "Mcp Tool trigger", + "language": "JavaScript", + "triggerType": "mcpToolTrigger", + "category": [ + "$temp_category_core", + "$temp_category_api" + ], + "categoryStyle": "mcpTool", + "enabledInTryMode": true, + "userPrompt": [] + } + }, + { + "id": "HttpTrigger-TypeScript-4.x", + "runtime": "2", + "files": { + "%functionName%.ts": "import { app, InvocationContext, output } from \"@azure/functions\";\n\nconst PROPERTY_TYPE = \"string\";\n\n// Hello function - responds with hello message\nexport async function mcpToolHello(_toolArguments:unknown, context: InvocationContext): Promise {\n // Get name from the tool arguments\n const mcptoolargs = context.triggerMetadata.mcptoolargs 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\n// Register the hello tool\napp.mcpTool('hello', {\n toolName: 'hello',\n description: 'Simple hello world MCP Tool that responses with a hello message.',\n toolProperties:[\n {\n propertyName: \"name\",\n propertyType: PROPERTY_TYPE,\n description: \"Required property to identify the caller.\",\n isRequired: true,\n }],\n handler: mcpToolHello\n});" + }, + "metadata": { + "defaultFunctionName": "mcpToolTrigger", + "description": "$McpToolTrigger_description", + "name": "Mcp Tool trigger", + "language": "TypeScript", + "triggerType": "mcpToolTrigger", + "category": [ + "$temp_category_core", + "$temp_category_api" + ], + "categoryStyle": "mcpTool", + "enabledInTryMode": true, + "userPrompt": [] + } } ] From a66fb7fd548d781fb0b48c699cb6310b9d1ffd3f Mon Sep 17 00:00:00 2001 From: Swapnil Nagar Date: Wed, 5 Nov 2025 23:50:32 -0800 Subject: [PATCH 2/2] Updating the template --- .../backupTemplates/nodejs-4.x/templates/templates.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/backupTemplates/nodejs-4.x/templates/templates.json b/resources/backupTemplates/nodejs-4.x/templates/templates.json index 42cc511c6..cd1e9b1f8 100644 --- a/resources/backupTemplates/nodejs-4.x/templates/templates.json +++ b/resources/backupTemplates/nodejs-4.x/templates/templates.json @@ -619,7 +619,7 @@ "id": "McpToolTrigger-JavaScript-4.x", "runtime": "2", "files": { - "%functionName%.js": "import { app } from \"@azure/functions\";\n\nconst PROPERTY_TYPE = \"string\";\n\n// Hello function - responds with hello message\nexport async function mcpToolHello(_toolArguments, context) {\n // Get name from the tool arguments\n const mcptoolargs = context.triggerMetadata.mcptoolargs || {};\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\n// Register the hello tool\napp.mcpTool('hello', {\n toolName: 'hello',\n description: 'Simple hello world MCP Tool that responses with a hello message.',\n toolProperties: [\n {\n propertyName: \"name\",\n propertyType: PROPERTY_TYPE,\n description: \"Required property to identify the caller.\",\n isRequired: true,\n }\n ],\n handler: mcpToolHello\n});" + "%functionName%.js": "const { app, output, trigger } = require('@azure\/functions');\r\n\r\n\/**\r\n * Sample Dapr Service Invocation Trigger\r\n * See https:\/\/aka.ms\/azure-functions-dapr for more information about using this binding\r\n *\r\n * These tasks should be completed prior to running :\r\n * 1. Install Dapr\r\n * Run the app with below steps\r\n * 1. Start function app with Dapr: dapr run --app-id functionapp --app-port 3001 --dapr-http-port 3501 -- func host start\r\n * 2. Invoke function app: dapr publish --pubsub pubsub --publish-app-id functionapp --topic A --data '{\"value\": { \"orderId\": \"42\" } }'\r\n *\/\r\nconst daprStateOuput = output.generic({\r\n type: \"daprState\",\r\n stateStore: \"statestore\",\r\n direction: \"out\",\r\n key: \"product\"\r\n});\r\n\r\napp.generic('%functionName%', {\r\n trigger: trigger.generic({\r\n type: \"daprTopicTrigger\",\r\n pubsubname: \"pubsub\",\r\n topic: \"A\",\r\n name: \"subEvent\"\r\n }),\r\n return: daprStateOuput,\r\n handler: async (request, context) => {\r\n context.log(\"JavaScript DaprTopic trigger with DaprState output binding function processed a request.\");\r\n context.log(context.triggerMetadata.subEvent.data);\r\n\r\n return context.triggerMetadata.subEvent.data;\r\n }\r\n});" }, "metadata": { "defaultFunctionName": "mcpToolTrigger", @@ -637,10 +637,10 @@ } }, { - "id": "HttpTrigger-TypeScript-4.x", + "id": "McpToolTrigger-TypeScript-4.x", "runtime": "2", "files": { - "%functionName%.ts": "import { app, InvocationContext, output } from \"@azure/functions\";\n\nconst PROPERTY_TYPE = \"string\";\n\n// Hello function - responds with hello message\nexport async function mcpToolHello(_toolArguments:unknown, context: InvocationContext): Promise {\n // Get name from the tool arguments\n const mcptoolargs = context.triggerMetadata.mcptoolargs 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\n// Register the hello tool\napp.mcpTool('hello', {\n toolName: 'hello',\n description: 'Simple hello world MCP Tool that responses with a hello message.',\n toolProperties:[\n {\n propertyName: \"name\",\n propertyType: PROPERTY_TYPE,\n description: \"Required property to identify the caller.\",\n isRequired: true,\n }],\n handler: mcpToolHello\n});" + "%functionName%.ts": "import { app, InvocationContext, arg } from \"@azure/functions\";\n\nexport async function mcpToolHello(_toolArguments: any, context: InvocationContext): Promise {\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});" }, "metadata": { "defaultFunctionName": "mcpToolTrigger",