m365-sse
v1.0.0
Published
M365 MCP with SSE
Readme
Azure AI Foundry MCP Server
This MCP Server implementation allows you to use Azure AI Foundry Agents as tools to other AI Agents or MCP clients.
[!CAUTION] This implementation is an example implementation and is NOT production ready.
Repository Overview
This repository contains the implementation of the Azure AI Foundry MCP Server. The server includes the following endpoints:
- list_ai_foundry_agents: Handles the request for listing all agents available in your AI Project.
- query_ai_foundry_agent: Handles the request for a specific agent, using the agent id.
Project Structure
The repository is organized as follows:
- src/: Contains the main source code for the MCP Server.
auth.ts: Handles authentication mechanisms.index.ts: Entry point for the server.mcp_tools.ts: Implements tools for MCP operations.tool_definitions.ts: Defines the tools available in the server.utils.ts: Utility functions used across the project.
- azureaimcp.yaml: Configuration file to use for creation of the Power Automate Customer Connector for the MCP Server.
- package.json: Node.js project metadata and dependencies.
- tsconfig.json: TypeScript configuration file.
Getting Started
Prerequisites
- Node.js (version 14 or higher)
- Azure account with necessary permissions
- Azure Foundry Project and Agents
- Azure Web App to deploy MCP Server [Can be done directly from Visual Studio Code using the Azure Tools add-in]
- To authenticate the MCP Server Web App against the AI Foundry Services you have to setup a managed identity that has acces to the AI Project and can execute the AI Agents.
- Optional: A Copilot Studio Agent
Installation
- Clone the repository:
git clone https://github.com/evanuum/ai-foundry-dynamic-agents-mcp.git - Navigate to the project directory:
cd ai-foundry-dynamic-agents-mcp - Install dependencies:
npm install
Run locally
- Create an .env file in your workspace for the environment variables:
PROJECT_CONNECTION_STRING=<Your AI Foundry Project Connection> MCP_API_KEY=<Your API Key to be used by the client to authenticate> [Currently disabled in the code] - Build the project:
npm run build - Start the MCP Server:
npm start - The MCP endpoint will be:
http://localhost:3001/sse
Run on Azure
- Deploy the MCP server to your Azure Web App. Set the environment variables on your App Server.
PROJECT_CONNECTION_STRING=<Your AI Foundry Project Connection> MCP_API_KEY=<Your API Key to be used by the client to authenticate> [Currently disabled in the code] - The MCP endpoint will be:
https://<your endpoint>.azurewebsites.net/sse
MCP Server Usage
Use the provided endpoints or integrate the server with your MCP clients:
- You can use GitHub Copilot in VSCode for testing.
- Add a file 'mcp.json' in the .vscode directory of your workspace and add the following content for testing.
{ "servers": { "aifoundry-mcp-server": { "type": "sse", "url": "<MCP endpoint as mentioned above>", "headers" : { "x-api-key": "<Your Api Key, if enabled>" } }, } } - Use the endpoint of your deployed server and your Api Key [only if enabled in your code].
Optional: Use the provided endpoints in a Microsoft Copilot Studio Agent:
- Create an agent in Copilot Studio with the following instructions
You are a dynamic orchestration agent. When resolving a question do this in this sequence: 1. List the available agents. 2. Determine which agent is most suitable to answer the question, based on its description. 3. Query the agent using its id from the list. Query an agent only once. 4. Provide the answer and indicate which agent you used to resolve the question. 5. If you can't find an agent to answer the question, answer with "Sorry, I can't assist with that." - Disable the 'Allow the AI to use its own general knowledge.' options for your Copilot Agent
- Create a Costum Connector in your Power Platform environment using the provide Yaml in 'azureaimcp.yaml'. Ensure you use your MCP Server endpoint in the yaml file. E.g. ******.azurewebsites.net.
- Make sure it points to your MCP Server [Web App] endpoint.
- Use the Custom Connector as a [MCP] tool in your Copilot Agent.
- Create an agent in Copilot Studio with the following instructions
License
This project is licensed under the terms of the LICENSE file.
