Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 11, 2025

Overview

Implements Azure Function endpoints with Model Context Protocol (MCP) support to handle telemetry requests and action commands for the Pi Chat application. The functions integrate with Azure Service Bus topics to enable asynchronous message processing.

Changes

Azure Functions Implementation

Created two HTTP-triggered Azure Functions using Node.js/TypeScript:

GetTelemetry Endpoint (POST /api/getTelemetry)

  • Accepts telemetry requests with sensor key and date range
  • Validates required fields: sensorKey, startDate, endDate
  • Submits messages to the Service Bus "Telemetry" topic

SendAction Endpoint (POST /api/sendAction)

  • Accepts action commands with type and specification
  • Validates required fields: actionType, actionSpec (raw JSON string)
  • Submits messages to the Service Bus "Action" topic

MCP Integration

  • Added /api/mcp/info endpoint for server information
  • Added /api/mcp/tools endpoint for tool discovery
  • Both functions registered as MCP tools with proper schemas

Infrastructure Updates

Updated Azure Bicep templates to support the new architecture:

  • Migrated from Service Bus queues to topics ("Telemetry" and "Action")
  • Configured Function App with Node.js 18 runtime
  • Set up Service Bus connection string in function app settings

Testing

  • Added comprehensive unit test suite with Jest
  • 9 tests covering validation, success paths, and error scenarios
  • All tests passing with proper Service Bus client mocking

Example Usage

Request Telemetry Data

curl -X POST https://<function-app>.azurewebsites.net/api/getTelemetry \
  -H "Content-Type: application/json" \
  -d '{
    "sensorKey": "sensor-123",
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-01-31T23:59:59Z"
  }'

Send Action Command

curl -X POST https://<function-app>.azurewebsites.net/api/sendAction \
  -H "Content-Type: application/json" \
  -d '{
    "actionType": "turn-on-light",
    "actionSpec": "{\"brightness\": 100, \"color\": \"white\"}"
  }'

Deployment

The function app is ready for deployment via the existing Bicep templates. After infrastructure deployment, build and publish the functions:

cd functions
npm install
npm run build
func azure functionapp publish <function-app-name>

Closes #[issue-number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.functions.azure.com
    • Triggering command: node lib/install.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Enable Azure Function MCP endpoint</issue_title>
<issue_description>This azure function, should have an MCP trigger and enable the ability for the application to perform the following actions:

GetTelemetry - This endpoint should receive an object that called a TelemetryRequest which is a json based object. It should include the following:

SensorKey - string - The identify for the sensor
StartDate - The start date for the telemetry request
EndDate - The end date for the telemetry request

It should take this json object, and submit it as a message against the service bus topic "Telemetry".

Send Action - This endpoint should receive an object called "ActionRequest" which is a json based object. It should include the following:

ActionType - The action key to indicate what it is being told to do.
ActionSpec - A string object, which will hold raw json to be processed by the service

It should take this json object, and submit it as a message against the service bus topic "Action"</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #3


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits October 11, 2025 03:48
Co-authored-by: KevinDMack <7958118+KevinDMack@users.noreply.github.com>
Co-authored-by: KevinDMack <7958118+KevinDMack@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add Azure Function MCP endpoint with GetTelemetry and Send Action Enable Azure Function MCP endpoints for telemetry and action requests Oct 11, 2025
@Copilot Copilot AI requested a review from KevinDMack October 11, 2025 03:55
Copilot finished work on behalf of KevinDMack October 11, 2025 03:55
Copy link
Contributor

@KevinDMack KevinDMack left a comment

Choose a reason for hiding this comment

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

Can you rewrite the functions from typescript to python.

@KevinDMack KevinDMack requested a review from Copilot October 11, 2025 03:58
Copy link

@Copilot 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

This PR implements Azure Function endpoints with Model Context Protocol (MCP) support to handle telemetry requests and action commands for the Pi Chat application, migrating from Service Bus queues to topics for improved message distribution.

  • Implements two HTTP-triggered Azure Functions (getTelemetry and sendAction) that validate requests and submit messages to Service Bus topics
  • Adds MCP server endpoints for tool discovery and server information
  • Migrates infrastructure from Service Bus queues to topics ("Telemetry" and "Action") with updated Bicep templates

Reviewed Changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
infra/modules/serviceBus.bicep Migrates from queue to topics architecture, creating "Telemetry" and "Action" topics
infra/modules/functionApp.bicep Removes queue-specific configuration parameters
infra/main.bicep Updates module calls to remove queue name parameter
functions/src/getTelemetry.ts Implements telemetry request endpoint with validation and Service Bus integration
functions/src/sendAction.ts Implements action command endpoint with validation and Service Bus integration
functions/src/mcpServer.ts Provides MCP server info and tool discovery endpoints
functions/package.json Defines dependencies and scripts for the Functions app
functions/test/*.test.ts Comprehensive test suites for both function endpoints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@KevinDMack KevinDMack removed their assignment Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Azure Function MCP endpoint

2 participants