Edit

Share via


Build plugins from an MCP server for Microsoft 365 Copilot (preview)

This guide walks you through the process of integrating your service with Microsoft 365 Copilot by adding an MCP server to a declarative agent using the Microsoft 365 Agents Toolkit. By following these steps, you'll enable conversational, AI-powered access to your MCP-exposed services for business users.

Important

This feature is currently in public preview.

Prerequisites

Create the agent

  1. Open Visual Studio Code and Select the Microsoft 365 Agents Toolkit icon in the left-hand Activity Bar.

  2. Select Create a New Agent/App in the Agents Toolkit task pane.

    A screenshot of the Agents Toolkit interface

  3. Select Declarative Agent.

  4. Select Add an Action, then select Start with an MCP Server.

  5. Enter the GitHub MCP server URL https://api.githubcopilot.com/mcp/.

    A screenshot of the prompt to enter the MCP server URL

  6. Choose a location for the agent project.

  7. Enter a name for the agent.

Once you complete these steps, Agents Toolkit generates the required files for the agent and opens a new Visual Studio Code window with the agent project loaded.

Add tools from the MCP server

  1. Open the .vscode/mcp.json file. Select the Start button in the file editor.

  2. If prompted to authenticate, select Allow to authenticate.

  3. Select the ATK: Fetch action from MCP button in the file editor, then select ai-plugin.json.

    A screenshot of the 'ATK: Fetch action from MCP' and 'Start' buttons in mcp.json

  4. Select operations for the agent to use. For this exercise, choose search_repositories and search_users.

    A screenshot of the tool selection interface in VS Code

    Important

    Only tools from MCP servers are supported.

  5. Select OAuth (with static registration) as the authentication type.

    A screenshot of the prompt to choose the authentication type

Register an OAuth app with GitHub

  1. Go to https://github.com/settings/developers in your browser. Select OAuth Apps, then New OAuth App.

  2. Add a name and homepage URL for your app, and set https://teams.microsoft.com/api/platform/v1.0/oAuthRedirect as the Authorization callback URL. Select Register application.

  3. After the app is created, select Generate a new client secret. Copy the secret and the Client ID to use in the next section.

Package and sideload the agent

  1. Open the agent project in Visual Studio Code.

  2. Select the Microsoft 365 Agents Toolkit icon in the left-hand Activity Bar.

  3. In the Accounts pane, select Sign in to Microsoft 365. (If you're already signed in continue to the next step).

  4. Confirm that both Custom App Upload Enabled and Copilot Access Enabled display under your Microsoft 365 account. If they don't, check with your organization admin. See Requirements for Copilot extensibility options for details.

  5. In the Lifecycle pane, select Provision.

  6. When asked to Enter client id for OAuth registration..., enter your client ID.

  7. When asked to Enter client secret for OAuth registration..., enter your client secret.

  8. When asked for scopes, press Enter to continue.

  9. Read the message in the dialog and select Confirm to continue.

  10. Wait for the toolkit to report that is finished provisioning.

Important

While this feature is in public preview, manifest validation may fail for function parameters in the following cases.

  • Nested objects in the properties member
  • Properties in the properties member with the minimum, maximum, or default members present

If the teamsApp/validateAppPackage step fails during provisioning, remove the unsupported members and retry the provisioning step.

Use the agent

  1. In your browser, go to https://m365.cloud.microsoft/chat.

  2. In the Agents section of the sidebar, locate your agent. It is listed as the name you gave in the Create the agent section, with dev appended at the end. Select the agent.

  3. Ask the agent to find a repository or user. For example, can you find a repo for kiota?.

  4. When prompted, select Sign in to {agent-name}. In the pop-up window, login with your GitHub account and authorize the agent.

  5. When the pop-up window closes, the agent returns a response.

    A screenshot of the agent's response to a query for repositories