Skip to content

Commit 3314888

Browse files
Fixing the Javascript MCP Tool Trigger (#4788)
1 parent a560d85 commit 3314888

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

resources/backupTemplates/nodejs-4.x/templates/templates.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@
619619
"id": "McpToolTrigger-JavaScript-4.x",
620620
"runtime": "2",
621621
"files": {
622-
"%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});"
622+
"%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});"
623623
},
624624
"metadata": {
625625
"defaultFunctionName": "mcpToolTrigger",

0 commit comments

Comments
 (0)