๐ค MCP Server for Copilot Studio Agents
LocalAbout ๐ค MCP Server for Copilot Studio Agents
An MCP server that connects Microsoft Copilot Studio agents to MCP-compatible clients through DirectLine. It keeps conversation state across queries and exposes agent responses through a query tool.
Key features
- 01DirectLine connection to Copilot Studio
- 02Context retained across queries
- 03Configurable agent definitions
- 04Structured success and error responses
Use cases
- 01Query a Copilot Studio agent from an MCP client
- 02Continue a conversation across multiple queries
MCP support
Exposes the `query_agent` tool to MCP clients for sending queries to configured Copilot Studio agents and receiving responses. Conversation IDs and watermarks maintain context.
Configuration
Local server config is the same for every client. Copy it into your clientโs MCP config file.
We havenโt collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project README๐ค MCP Server for Copilot Studio Agents
An MCP (Model Context Protocol) server implementation that connects to Microsoft Copilot Studio agents, allowing seamless integration of Copilot Studio agents with any MCP-compatible client.
https://github.com/user-attachments/assets/19fdd17b-2837-4797-8653-fe9439de355f
โจ Features
- ๐ Connect to Copilot Studio agents through DirectLine API
- ๐ง Maintain conversation context across multiple queries
- ๐ Easy integration with any MCP-compatible client
- ๐ฌ Stateful conversations with conversation ID and watermark tracking
- โ๏ธ Configurable agent definitions
๐ ๏ธ Tools
This MCP server exposes the following tools:
- ๐ฎ
query_agent: Send queries to a Copilot Studio agent and receive responses- ๐ Maintains conversation context across multiple queries using conversation IDs and watermarks
- ๐ Returns structured responses with success/error status
๐ง Configuration
Pre-requisites
- ๐ Ensure you have a Copilot Studio agent set up and configure direct line channel security.
- ๐ Update the
agent_definitionsin thesrc/main.pyfile to include your agent's details. - The
agent_definitionsshould include the following fields:- ๐
name: The name of the agent - ๐
description: A brief description of the agent for the MCP client to identify the responsibility of the agent.
- ๐
Environment Variables
The server requires the following environment variables:
- ๐
DIRECTLINE_ENDPOINT: The DirectLine API endpoint for your Copilot Studio agent - ๐
COPILOT_AGENT_SECRET: Bot key for authenticating with the Copilot Studio agent via the DirectLine API
You can set these variables in a .env file in the project root directory or configure them through your system's environment variables.
๐ฆ Installation
Prerequisites
- ๐ Python 3.12 or higher
- ๐
uvpackage manager (recommended) or pip
Python Setup
# Setup environment with uv
uv venv
.venv\Scripts\activate # On Windows
source .venv/bin/activate # On macOS/Linux
# Install dependencies
uv sync
If you prefer using pip:
# Create a virtual environment
python -m venv .venv
.venv\Scripts\activate # On Windows
source .venv/bin/activate # On macOS/Linux
# Install dependencies
pip install -e .
Testing with MCP Inspector
Once you activate your environment, you can run the MCP server locally using MCP Inspector.
- Run the MCP server using the following command:
mcp dev src/main.py
-
You will be prompted to install the
@modelcontextprotocol/inspectorpackage. Chooseyto install it.

-
Launch the MCP Inspector and connect to the MCP server.
-
Navigate to
Toolsand clickList Toolsto view all the available tools in the MCP server. -
Select the
query_agenttool to send queries to your Copilot Studio agent.

Usage with Claude Desktop
To use with Claude Desktop, add the following to your configuration file:
- Download Claude Desktop and install it, if you haven't already.
- Navigate to
File>Settings>Developer>Edit Config. - Open the
claude_desktop_config.jsonfile and add the following configurations to themcpServerssection. You can use eitheruv,python, ordockerto run the server.

- Save the configuration file and restart Claude Desktop.
- Once the MCP server is added to Claude Desktop, you can view it under the tools section.

MCP Server Configurations for Claude Desktop
Run via uv
{
"mcpServers": {
"agent-name": {
"command": "uv", // you might need to use the full path to uv if it's not in your PATH. use `which uv` to find the path.
"args": [
"--directory",
"<PATH_TO_THE_PARENT_FOLDER>",
"run",
"mcp",
"run",
"<PATH_TO_THE_PARENT_FOLDER>/src/main.py"
],
"env": {
"DIRECTLINE_ENDPOINT": "endpoint-url",
"COPILOT_AGENT_SECRET": "secret-key"
}
}
}
}
Run via python
Post setup of virtual environment and installing the necessary packages, you can run the server using the following command:
{
"mcpServers": {
"agent-name": {
"command": "<PATH_TO_VENV>/bin/python",
"args": [
"<PATH_TO_THE_PARENT_FOLDER>/src/main.py"
],
"env": {
"DIRECTLINE_ENDPOINT": "endpoint-url",
"COPILOT_AGENT_SECRET": "secret-key"
}
}
}
}
Alternatively you can install the server to Claude Desktop by running the following command (inside the virtual environment):
mcp install src/main.py -f .env
Run via docker
You can run the MCP server as a container using Docker. Ensure you have Docker installed and running on your machine.
Build the Docker image:
docker build -t mcp-server-copilot-agent .
Add the following to your Claude Desktop configuration file:
{
"mcpServers": {
"agent-name": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-p", "8000:8000",
"--env-file", "<PATH_TO_THE_PARENT_FOLDER>/.env",
"mcp-server-copilot-agent"
]
}
}
}
Once you have configured Claude Desktop with the
๐ Usage with Other MCP Clients
This server follows the MCP protocol specification and can be used with any MCP-compatible client. Refer to your client's documentation for specific instructions on how to connect to external MCP servers.
๐ฉโ๐ป Development
To contribute to this project, set up a development environment:
# Install development dependencies
uv sync -e dev
The project uses Ruff for linting:
# Run linter
ruff check .
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.