Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Bicep compiled files
*.json
infra/**/*.json
!functions/**/*.json

# Build artifacts
dist/
Expand Down
8 changes: 8 additions & 0 deletions functions/.funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js.map
*.ts
.git*
.vscode
local.settings.json
test
tsconfig.json
node_modules
65 changes: 65 additions & 0 deletions functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Pi Chat Azure Functions

This Azure Functions app provides MCP (Model Context Protocol) endpoints for the Pi Chat application.

## Endpoints

### GetTelemetry
**POST** `/api/getTelemetry`

Submits a telemetry request to the Service Bus "Telemetry" topic.

**Request Body:**
```json
{
"sensorKey": "string",
"startDate": "2024-01-01T00:00:00Z",
"endDate": "2024-01-31T23:59:59Z"
}
```

### SendAction
**POST** `/api/sendAction`

Submits an action request to the Service Bus "Action" topic.

**Request Body:**
```json
{
"actionType": "string",
"actionSpec": "{\"key\": \"value\"}"
}
```

### MCP Endpoints

- **GET** `/api/mcp/info` - Returns MCP server information
- **GET** `/api/mcp/tools` - Lists available MCP tools

## Development

### Prerequisites
- Node.js 18.x or higher
- Azure Functions Core Tools v4

### Install Dependencies
```bash
npm install
```

### Build
```bash
npm run build
```

### Run Locally
```bash
npm start
```

### Environment Variables
- `ServiceBusConnectionString` - Connection string for Azure Service Bus

## Deployment

The function app is deployed via Azure Bicep templates in the `infra` directory.
15 changes: 15 additions & 0 deletions functions/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"maxTelemetryItemsPerSecond": 20
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
10 changes: 10 additions & 0 deletions functions/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/test'],
testMatch: ['**/*.test.ts'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts'
]
};
8 changes: 8 additions & 0 deletions functions/local.settings.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "node",
"ServiceBusConnectionString": "Endpoint=sb://your-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=your-key"
}
}
Loading