calculator-sse
This project showcases a demo MCP Server implemented with Node.js and TypeScript. It features calculation tools like BMI and addition, providing real-time responses via Server-Sent Events. The project demonstrates integration with Microsoft Copilot Studio and GitHub Copilot Agent.
๐งฎ Step by step Implementation of MCP Server and Integration into Microsoft Copilot Studio and Github Copilot Agent
This is a demo Node.js + TypeScript MCP SDK using Model Context Protocol SDK. It exposes simple calculation tools like BMI and addition through MCP, and supports real-time responses via Server-Sent Events (SSE). Explore the MCP architecture and best practices using the MCP Architecture and SSE transport.
๐ Features
- โ SSE (Server-Sent Events) Support
- โ BMI Calculator Tool
- โ Addition Tool
- โ MCP Tool + Github Copilot Agent Integration
- โ MCP Tool + Microsoft Copilot Studio Integration
- โ Azure App Service Ready
๐ Project Structure
โ๏ธQuick Start
npm install # Install dependencies
npm run build # Compile TypeScript
npm run start # Start server (http://localhost:3001)
The app will run at http://localhost:3001 (unless configured otherwise).
๐งช MCP Tools
๐น calculate-bmi
Input:
{
"weightKg": 70,
"heightM": 1.75
}
Response:
{
"content": [{ "type": "text", "text": "22.86" }]
}
๐น calculate-sum
Input
{
"a": 5,
"b": 3
}
Response:
{
"content": [{ "type": "text", "text": "8" }]
}
๐ SSE Endpoint
The server supports Server-Sent Events (SSE) via:
GET /sse
๐ฅ๏ธ MCP Tool + Github Copilot Agent Integration (VSCode)
- Open the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
). - Type "Add MCP Server" and select it.
- Update
.vscode/mcp.json
with the following:
{
"servers": {
"my-mcp-server": {
"type": "sse",
"url": "http://localhost:3001/sse"
}
}
}
Result in Github Copilot Agent
๐ฅ๏ธ MCP Tool + Microsoft Copilot Studio Integration (Custom Connector)
For details on integrating Model Context Protocol (MCP) tools into Microsoft Copilot Studio using custom connectors, check out the official Microsoft documentation: ๐ Extend Copilot actions using MCP in Copilot Studio
MCP Custom connector Copilot Studio Integration
It shows how to set up the MCP Tools for actions to work with custom connectors in Copilot Studio.
Swagger Specification
swagger: '2.0'
info:
title: MCPCalculatorDemo
description: Calculate BMI and Calculate sum using MCP SSE server
version: '1.0'
host: calculatormcp-dummyurl.azurewebsites.net
basePath: /
schemes:
- https
definitions:
QueryResponse:
type: object
properties:
jsonrpc:
type: string
id:
type: string
method:
type: string
params:
type: object
result:
type: object
error:
type: object
paths:
/sse:
get:
summary: MCP Server Actions for calculating BMI and sum
parameters:
- in: query
name: sessionId
type: string
required: false
produces:
- application/json
responses:
'200':
description: Immediate Response
schema:
$ref: '#/definitions/QueryResponse'
'201':
description: Created and will follow callback
operationId: CalculatorDemo
tags:
- Agentic
- McpSse
securityDefinitions: {}
security: []
Using MCP Server Action in Copilot Studio
Steps to Access the MCP Server Action
-
Open Copilot Studio
Navigate to your Copilot Studio workspace. -
Go to Actions
Click on the Action menu in the left sidebar. -
Select "Custom connector"
Under the Action menu, choose Custom connector. -
Locate the MCP Server Action
The system will automatically display available tools. Select the MCP Server Action from the list. -
MCP Server Action Preview
You will be able to view the details of the selected MCP Server Action as shown below:
๐ Considerations
-
โ The
/sse
endpoint should return the full URI (including protocol and host) when initializing the MCP transport. This ensures compatibility when deploying across environments (e.g., localhost vs Azure). It establishes a live connection for streaming MCP interactions.Example:
const protocol = req.protocol; const host = req.get('host'); const fullUri = `${protocol}://${host}/mcp`;
๐ Return / Server-Sent Events (SSE) with Full URI
Ensure your custom connector supports SSE (Server-Sent Events) and returns the full URI as shown:
๐ท๏ธ Add Tags to Your Custom Connector
tags:
- Agentic
- McpSse
โ ๏ธ Naming Guidance
Do not use "InvokeMCP"
as your operationId
.
Choose a more specific and descriptive name to reflect the purpose of the action and avoid conflicts.
โ๏ธ Deploy to Azure (Optional)
Create an Azure App Service (Node.js 18+) Set the startup command (if needed):
npm run build && npm run start
SSE Deployment Update
The SSE deployment to Azure with the West US 2 region using the Basic plan was successful and tested without issues.
๐ ๏ธ Troubleshooting
โ How to Check if Your SSE Server is Running Properly
Follow these steps to verify that your SSE (Server-Sent Events) server is functioning correctly:
๐ Step 1: Browse the SSE Endpoint
-
Open your browser and navigate to:
http://localhost:3000/sse
(if running locally), or- Your deployed Azure URL.
-
Open Developer Tools โ Network tab.
-
Look for an EventStream connection.
-
Under the
Event
section, you should see:- Endpoint: SSE endpoint
- Data: Your Full URI endpoint
๐งช Step 2: Test SSE Endpoint via Postman
- Copy the Full URI (from the EventStream
data
). - Use Postman to send a
POST
request to that URI.
Example URL:
http://calculatormcp-dummyurl.azurewebsites.net/mcpfy/v1/calculatordemo?sessionId=620c84e1-81e2-484d-8737-a7fbc93165b1
Example Request Payload:
{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/call",
"params": {
"name": "calculate-bmi",
"arguments": {
"weightKg": 180,
"heightM": 1.8
}
}
}
If successful, you'll receive a response with a "message"
confirming that the server is working correctly.
๐ผ๏ธ Sample Screenshots
Browser Network Event Trace:
Postman Response:
Alternatively, you can use MCP Inspector to test, https://github.com/modelcontextprotocol/inspector
Disclaimer
This is an unsupported, experimental, and not an official Microsoft product. It is provided "as is", without support and without any warranties, whether express or implied. This includes, but is not limited to, warranties of merchantability, fitness for a particular purpose, and non-infringement.
In no event shall the authors or copyright holders be liable for any claims, damages, or other liabilities, whether in contract, tort, or otherwise, arising from, out of, or in connection with the Software or the use or other dealings in the Software.
โ ๏ธ Important Note:
This is a sample demo custom MCP server created for demonstration purposes. It is deployed into Microsoft Azure and intended solely for integration with Copilot Studio during prototyping or sample scenarios.
This component is not part of any official Microsoft product and is not available for production use.