M365 Agents Toolkit: Connect MCP Server To Declarative Agent

M365 Agents Toolkit: Connect MCP Server To Declarative Agent

You can connect an MCP server to a declarative agent using the M365 Agents Toolkit. MCP servers expose tools that agents can use to perform actions or retrieve data from external systems. They can even access other services such as Microsoft Learn, Altassian/JIRA and Github as outlined in this article. And if that service requires a logged-in user to perform tasks the MCP server will require authentication.




MCP Server #1: The Microsoft Learn MCP Server (No Authentication)

The first declarative agent we will build using the Microsoft 365 Agents Toolkit will connect to the Microsoft Learn MCP Server. The Microsoft Learn MCP server gives agents access to real-time, trusted Microsoft documentation and code samples. No authentication is required to use this MCP server.



The Microsoft Learn MCP server endpoint is found at https://learn.microsoft.com/api/mcp. We will configure the declarative agent to use this URL.



MCP servers expose tools that our declarative agent can call to perform actions or get data from external systems. The Microsoft Learn MCP server includes the following tools.




Build The MS Learn MCP Declarative Agent Using M365 Agents Toolkit

To create the declarative agent connected to the Microsoft Learn MCP server download the Microsoft 365 Agents Toolkit VS Code extension. Then use the command Microsoft 365 Agents: Create New Agent/App.



Select the following options:

  • Declarative Agent
  • Add An Action
  • Start with a MCP server



Input the Microsoft Learn MCP server endpoint as the MCP server URL: https://learn.microsoft.com/api/mcp



Select the authentication type None.



Then name the agent MS Learn MCP Agent. When we press enter the M365 Agents Toolkit with generate all code needed for the new declarative agent project.




Test The MS Learn MCP Agent In M365 Copilot

That’s all it takes. Our declarative agent connected to the Microsoft Learn MCP server is now ready to be tested. Open the Microsoft 365 Agents Toolkit extension and select Provision from the Lifecycle section. Wait until provisioning successfully completes before going any further.



Open the M365 Copilot, go to the Agents menu, and select the agent named MS Learn MCP Agentdev. Type the command -developer on to enable agent debug info. Then ask the agent a question that can be answered by reading Microsoft Learn documentation.



The agent answers and provides Microsoft Learn as the source. At the bottom of the screen, the agent debug info card shows what MCP server tools were used to retrieve the information.




MCP Server #2: The Atlassian MCP Server (OAuth + Dynamic Registration)

The second declarative agent we will build connects to the Atlassian MCP Server. We will use the Atlassian MCP server to create a new task in JIRA which is a project management app. Only logged-in users can create tasks in JIRA so this MCP server will require OAuth authentication.



The Atlassian MCP server can be found at the endpoint https://mcp.atlassian.com/v2/mcp.



It has several tools that will let us read, write and search JIRA for information. And it contains over 100 tools total that interact with other JIRA products such as Confluence and BitBucket.




Sign Up For A Free Atlassian JIRA Site

To create a new task in JIRA, we will require a JIRA site to work in. Go to the get started with JIRA webpage and sign up for a free account.



After sign up is completed, navigate to the My Software Team space and open the Board. We will create a new task named “Task XYZ” on this board using a declarative agent.




Build The Atlassian Declarative Agent Using M365 Agents Toolkit

Now that we have a JIRA site available to use, we are ready to create our declarative agent. Open VS Code and run the command Microsoft 365 Agents: Create New Agent/App. Then choose the following options:

  • Declarative Agent
  • Add An Action
  • Start With An MCP server

Then input the Atlassian MCP server endpoint: https://mcp.atlassian.com/v2/mcp.



Select the authentication type OAuth (with dynamic registration).



And name the agent Atlassian MCP Agent. We we press enter the M365 Agents Toolkit will generate the declarative agent project code.




Connect The MCP Server To Altlassian With OAuth (Dynamic Registration)

To test the new declarative agent, open the M365 Agents Toolkit and select the Provision button.



Once provisioning has completed, open the M365 Copilot app, navigate to the Agents menu and choose the agent named Atlassian MCP Agentdev. Prompt the agent to “create a new task in space named My Software team. The task name is Task XYZ and the status is To Do.” When the agent selects the Atlassian MCP server to complete the task, it prompts the user to sign-in.



Login with the JIRA username and password provided when creating the free JIRA site. Then we can choose what permissions the agent should have for JIRA. Enable the user’s access to all tools including read, write and search. Then press the Accept button.




Review The Declarative Agent Created Task In JIRA

After accepting the request to access Atlassian the declarative agent will create the new task in JIRA.



Go to JIRA to confirm the task has actually been created.




MCP Server #3: The Github MCP Server (OAuth + Static Registration)

The third and final declarative agent we create will connect to the Github MCP Server. We will use the Github MCP server to read a Github repository. OAuth authentication is required to use this MCP server because many actions in Github require a logged-in user, including reading a private repo.



The Github MCP server can be found at https://api.githubcopilot.com/mcp.



In addition to providing the endpoint we will also need to define the scope of the OAuth app. The scope tells the Github MCP server what access it will have.




Register A New OAuth Application In Github Developer Settings

To create an agent connected to the Github MCP Server we will need to create an OAuth app in Github. Login to your Github account and go to the settings menu.



Go to Developer Settings in the left menu. Then open the OAuth Apps tab and create a new OAuth app.



Register the new OAuth app with the following settings:

  • Application Name: M365 Agents Toolkit
  • Homepage URL: (enter any URL)
  • Redirect URIs: https://teams.microsoft.com/api/platform/v1.0/oAuthRedirect

Press the Register Application button once all settings are filled-in.



The next screen will show the OAuth application’s client ID and secret values. Copy these values into notepad so they can be used to configure the declarative agent in the next step.




Build The Github Declarative Agent Using M365 Agents Toolkit

We’ve configured an OAuth application in Github so now we can build a declarative agent connected to the Github MCP server. Open VS code and run the command Microsoft 365 Agents: Create New Agent/App. Then choose the following options:

  • Declarative Agent
  • Add An Action
  • Start With An MCP server

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



Select the authentication type OAuth with static registration.



Input the client ID from the OAuth App registered in Github.



And also copy and paste the client secret from Github into VS Code.



Provide the OAuth scopes repo read:org read: user.



Then name the agent Github MCP Agent. When we press enter the Microsoft 365 Agents Toolkit will generate the declarative agent project code.




Test The Github MCP Agent In M365 Copilot

We can now test the declarative agent connected to the Github MCP server. Open the M365 Agents Toolkit extension and press the Provision button. Wait for provisioning to successfully complete before moving on.


Go to M365 Copilot and navigate to the Agents menu. Select the agent named Github MCP Agentdev. Then prompt the agent to “tell me which of my repositories have the most stars on Github.” Press the sign in to Github MCP Agent button when it appears.



Authorize the declarative agent to use the Github MCP server.



Then the agent comes back with the requested information about the repository.




Video: M365 Agents Toolkit Connect MCP Server To A Declarative Agent

Watch this video for a complete demonstration of the techniques described in the article.





Questions?

If you have any questions or feedback about M365 Agents Toolkit: Connect MCP Server To Declarative Agent please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

0 Comments
Oldest
Newest
Inline Feedbacks
View all comments