Skip to main content
Glama
bradcstevens

Copilot Studio Agent Direct Line MCP Server

by bradcstevens

⭐ Copilot Studio Agent Direct Line MCP Server

Easily install the Copilot Studio Agent Direct Line MCP Server for VS Code or VS Code Insiders:

Install with NPX in VS Code Install with NPX in VS Code Insiders

This TypeScript project provides a local MCP server for Microsoft Copilot Studio Agents, enabling you to interact with your Copilot Studio Agents directly from your code editor via the Direct Line 3.0 API.

πŸ“„ Table of Contents

Related MCP server: MCP Server for VS Code

πŸ“Ί Overview

The Copilot Studio Agent Direct Line MCP Server brings Microsoft Copilot Studio Agent context to your development environment. Try prompts like:

  • "Start a conversation with my Copilot Studio Agent"

  • "Ask my agent about product sizing"

  • "Send a message to the agent: What are your capabilities?"

  • "Get the conversation history"

  • "End the current conversation"

πŸ† Expectations

The Copilot Studio Agent Direct Line MCP Server is built with tools that are concise, simple, focused, and easy to useβ€”each designed for a specific scenario. We intentionally avoid complex tools that try to do too much. The goal is to provide a thin abstraction layer over the Direct Line 3.0 API, making agent interaction straightforward and letting the language model handle complex reasoning.

βš™οΈ Features

  • βœ… Direct Line 3.0 Integration - Full support for Microsoft Bot Framework Direct Line API

  • βœ… Token Management - Automatic token caching and proactive refresh

  • βœ… Conversation State - Manages conversation lifecycle with 30-minute idle timeout

  • βœ… MCP Tools - Four tools for agent interaction: send_message, start_conversation, end_conversation, get_conversation_history

  • βœ… Comprehensive Error Handling - 11 specialized error types, OAuth-specific retry strategies, MCP error transformation

  • βœ… Circuit Breaker Pattern - Intelligent failure classification, excludes user errors from circuit state

  • βœ… Retry Logic - Exponential backoff with jitter, OAuth-aware retry strategies

  • βœ… Input Validation - Zod schemas for type-safe validation

  • βœ… Security - Secret masking in logs, secure environment configuration, no disk persistence

  • βœ… HTTP Transport Mode - Optional HTTP server with Azure Entra ID OAuth authentication

  • βœ… Testing Suite - 45+ tests with 80%+ coverage on critical components

  • βœ… Production Ready - Deployment templates for Azure Container Apps, Docker, Kubernetes

βš’οΈ Supported Tools

Interact with your Copilot Studio Agent using these tools:

  • send_message: Send a message to the Copilot Studio Agent and receive a response.

  • start_conversation: Start a new conversation with the Agent, optionally with an initial message.

  • end_conversation: End a conversation and clean up resources.

  • get_conversation_history: Retrieve message history for a conversation.

πŸ”Œ Installation & Getting Started

For the best experience, use Visual Studio Code and GitHub Copilot. See the getting started documentation to use our MCP Server with other tools such as Claude Code and Cursor.

Prerequisites

  1. Install VS Code or VS Code Insiders

  2. Install Node.js 18+

  3. Microsoft Copilot Studio Agent with Direct Line 3.0 enabled

  4. Direct Line secret key from your Copilot Studio Agent

Installation

Install with NPX in VS Code Install with NPX in VS Code Insiders

After installation, select GitHub Copilot Agent Mode and refresh the tools list. Learn more about Agent Mode in the VS Code Documentation.

🧨 Manual Install with NPX

This installation method is the easiest for all users of Visual Studio Code.

In your project, add a .vscode/mcp.json file with the following content:

{
  "inputs": [
    {
      "id": "direct_line_secret",
      "type": "promptString",
      "description": "Direct Line secret key from your Copilot Studio Agent"
    }
  ],
  "servers": {
    "copilot-studio-agent-direct-line-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "copilot-studio-agent-direct-line-mcp"],
      "env": {
        "DIRECT_LINE_SECRET": "${input:direct_line_secret}"
      }
    }
  }
}

Save the file, then click 'Start' in the MCP Server panel.

In chat, switch to Agent Mode.

Click "Select Tools" and choose the available tools.

Open GitHub Copilot Chat and try a prompt like Start a conversation with my Copilot Studio Agent. The first time a tool is executed, you will be prompted for your Direct Line secret.

πŸ’₯ We strongly recommend creating a .github/copilot-instructions.md in your project. This will enhance your experience using the Copilot Studio MCP Server with GitHub Copilot Chat. To start, just include "This project uses Microsoft Copilot Studio Agents. Always check to see if the Copilot Studio MCP server has a tool relevant to the user's request" in your copilot instructions file.

See the getting started documentation for additional installation methods, including local development setup.

πŸ“ Troubleshooting

See the Troubleshooting guide for help with common issues and logging.

🎩 Examples & Best Practices

Explore example prompts and usage patterns in our Examples documentation.

For detailed tool reference and usage guides, refer to the Usage Guide.

πŸ™‹β€β™€οΈ Frequently Asked Questions

For answers to common questions about the Copilot Studio Agent Direct Line MCP Server, see the Frequently Asked Questions.

πŸ“Œ Contributing

We welcome contributions! During preview, please file issues for bugs, enhancements, or documentation improvements.

See our Contributions Guide for:

  • πŸ› οΈ Development setup

  • ✨ Adding new features

  • πŸ“ Code style & testing

  • πŸ”„ Pull request process

🀝 Code of Conduct

This project follows standard open-source community guidelines. We expect all contributors to be respectful and constructive in their interactions.

License

Licensed under the MIT License.


Disclaimer: This is a personal project by Brad Stevens.
It is not affiliated with or endorsed by Microsoft Corporation.

Available Tools

4 tools
end_conversationB

End an existing conversation and clean up resources

ParametersJSON Schema
NameRequiredDescriptionDefault
conversationIdYesConversation ID to terminate

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. 'End an existing conversation' implies mutation, and 'clean up resources' hints at side effects, but it does not disclose irreversibility, impact on history, or any other behavioral nuances. The description is vague about what cleanup entails.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence, front-loaded with the action verb 'End'. Every word earns its place, including the useful addition of 'clean up resources' which hints at side effects without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with one parameter, 100% schema coverage, and no output schema. The description is minimally viable, but it lacks usage guidance and behavioral details about consequences, making it less complete than ideal for a terminating action.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%: the parameter 'conversationId' is described as 'Conversation ID to terminate'. The description adds no additional semantic meaning beyond the schema, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'End' with the resource 'conversation', clearly indicating the action. It distinguishes from siblings like 'send_message' and 'start_conversation' by being the terminating action, though it does not explicitly contrast with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It does not mention conditions for ending a conversation or exclusions, relying on the agent to infer usage from the verb 'End' and sibling context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_conversation_historyB

Retrieve message history for a conversation

ParametersJSON Schema
NameRequiredDescriptionDefault
conversationIdYesConversation ID
limitNoMaximum number of messages to return

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only says 'Retrieve message history' and does not explicitly confirm read-only behavior, mention pagination, ordering, error handling, or authentication requirements. The verb 'retrieve' implies a read operation, but this is not stated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-formed sentence that conveys the core purpose without any superfluous words. It is front-loaded and every word contributes meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple (two parameters, no output schema, no annotations), and the schema covers parameters adequately. However, the description lacks context about response format, message ordering, or usage scenarios, making it minimally viable but not comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already documents both parameters with clear descriptions ('Conversation ID' and 'Maximum number of messages to return'), achieving 100% schema coverage. The tool description adds no further parameter semantics, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb 'Retrieve' and clearly identifies the resource as 'message history for a conversation.' This distinguishes it from sibling tools like send_message, start_conversation, and end_conversation, which perform different actions on conversations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It simply states the action without mentioning context or exclusions, and sibling tools are not referenced, leaving the agent to infer usage solely from the name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

send_messageC

Send a message to the Copilot Studio Agent

ParametersJSON Schema
NameRequiredDescriptionDefault
messageYesThe message text to send
conversationIdNoOptional conversation ID to continue existing conversation

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It only states the basic action and omits important behaviors such as whether the tool can start a conversation without a conversationId, how it handles invalid conversation IDs, or any side effects. This is a significant gap for a messaging tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that directly states the tool's purpose with no superfluous words. It is compact and front-loaded, making the core function immediately clear.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite the tool's technical simplicity, the description lacks critical context about the conversation lifecycle. The existence of sibling tools (start_conversation, end_conversation) implies a workflow, but the description does not clarify whether send_message requires an existing conversation or can initiate one. This ambiguity affects correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides full descriptions for both parameters (message and conversationId). The tool description adds no additional semantics beyond the schema, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Send') and the object/resource ('a message to the Copilot Studio Agent'). It is distinguishable from siblings like start_conversation and get_conversation_history, though it could be more explicit about whether it sends within an existing conversation or starts a new one.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus the siblings. There is no mention of prerequisites (e.g., needing an active conversation) or alternatives, leaving the agent to infer the intended workflow.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

start_conversationB

Start a new conversation with the Copilot Studio Agent

ParametersJSON Schema
NameRequiredDescriptionDefault
initialMessageNoOptional first message to send

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden for transparency. It fails to disclose behavioral traits such as whether it resets prior context, returns a conversation ID, affects an existing conversation, or requires any prerequisites. The state-changing nature is implied but not explained.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no redundancy or filler. It fully serves its immediate purpose in minimal words, earning a high score for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite the simple one-parameter schema, the description omits critical context such as the return value, how it interacts with sibling tools, or whether it terminates an existing conversation. With no output schema or annotations, this lack of information leaves the agent uncertain about the tool's full behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already provides full coverage for the single optional parameter 'initialMessage' with a clear description. The tool description adds no additional semantic context about the parameter, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly specifies the action 'Start' and the resource 'a new conversation' with the target 'Copilot Studio Agent.' It distinguishes itself from sibling tools like send_message and end_conversation by explicitly indicating a new conversational session.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description only implies usage through the verb 'Start,' giving no explicit guidance on when to use this tool versus siblings, nor any exclusions or prerequisites. The context of the sibling names suggests lifecycle phases but is not articulated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updates
    • First observedend_conversation
    • First observedget_conversation_history
    • First observedsend_message
    • First observedstart_conversation

TDQS

A3.6/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct purpose with no overlap: start_conversation initiates, send_message communicates, get_conversation_history retrieves, and end_conversation terminates. The four tools cover the complete conversation lifecycle without any ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., start_conversation, send_message) using snake_case throughout. The naming is predictable and readable, with no deviations in style or convention.

Tool Count5/5

Four tools are well-scoped for a conversation management server, covering initiation, messaging, history retrieval, and termination. Each tool earns its place without being excessive or insufficient for the domain.

Completeness5/5

The tool set provides complete CRUD/lifecycle coverage for conversation management: start (create), send (update/communicate), get (read), and end (delete). There are no obvious gaps, and agents can handle the full workflow without dead ends.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to debug code inside VS Code by setting breakpoints, stepping through execution, inspecting variables, and evaluating expressions across multiple languages.
    507
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables interaction with Microsoft Copilot Studio Agents through the Direct Line 3.0 API, allowing users to start conversations, send messages, retrieve history, and end conversations directly from their code editor.
    4
    13 npm
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables VS Code agent mode to search and retrieve context from your LLMemory vault of AI conversations (ChatGPT, Claude, etc.) without copying and pasting.
    6 npm
    MIT