Blog
Connect GitHub to Microsoft 365 Copilot with MCP
Learn how we connected GitHub to Microsoft 365 Copilot with MCP, using a GitHub App, least-privilege permissions, and server-side tool controls.

Francisco Gaona
Founder and technical lead
We wanted to find out whether a Microsoft 365 Copilot agent could query GitHub through MCP and use that information to answer questions about our projects.
In plain English: we wanted to ask about an issue, a pull request, or repository documentation without opening GitHub and starting the usual tour through tabs, comments, and README files that nobody remembers writing.
The idea is great. Copilot stops relying only on the context it has inside Microsoft 365 and can call external tools published by an MCP server.
The difficult part was not getting it to answer.
The difficult part was making it work without handing it the keys to GitHub, the alarm system, and the insurance company’s phone number.
Microsoft’s documentation got us started
To set everything up, we started with Microsoft’s official documentation for MCP Apps in Microsoft 365 Copilot.
The guide explains how to add a plugin based on a remote MCP server to a declarative agent. It also covers the server requirements, authentication, loading the agent, and testing it from Copilot. Its main focus is MCP Apps that return interactive widgets inside the chat, but the process for creating the agent, connecting it to the MCP server, and configuring authentication is the same even if you do not use those visual components. 1
The requirements include Visual Studio Code, Microsoft 365 Agents Toolkit 6.12.0 or later, a remote MCP server, and a tool such as MCP Inspector for reviewing the server’s responses. Copilot supports OAuth 2.1 and Microsoft Entra SSO. For development, you can also select a connection without authentication, although Microsoft says authentication must be added before deploying the setup to production. 2
Following that foundation, we created the agent, connected it to the MCP server, and confirmed that Copilot could discover its tools.
So far, so good.
But the documentation explains how to connect the pieces. It cannot decide which repositories your agent should see, whether it needs write access, or which identity you are going to place between GitHub and Copilot.
And that is where things can go spectacularly wrong.
MCP is not access control
MCP, the Model Context Protocol, allows an application such as Copilot to discover and invoke tools exposed by a server.
In normal-people language: Copilot asks for something, the MCP server chooses a tool, GitHub returns information, and the agent prepares a response.
Something like this:
User
↓
Microsoft 365 Copilot agent
↓
MCP server
↓
GitHub
MCP does not magically fix GitHub security.
The server still needs an identity with specific permissions. You also have to decide which tools you expose, who can call the server, and which resources are within reach of the integration.
You can have a technically perfect MCP connection and a terrible security configuration. Both things can be true at the same time.
The quick solution was a personal token
The first temptation is obvious.
Generate a personal GitHub token, store it in an environment variable, start the server, and off you go. In a few minutes, you have a demo answering questions about repositories.
Everything that follows needs attention:
- The token belongs to one person.
- It may inherit or accumulate permissions it does not need.
- It may access more repositories than intended.
- Someone has to remember where it is stored.
- It has to be rotated without breaking the service.
- If its owner changes roles or loses access, the integration changes too.
- It can end up copied into a file, a chat, or a repository.
For a controlled local test, it can get you moving. As the architecture for a service that other people will use, we were not comfortable with it.
We solved it with a GitHub App
We decided to authenticate access to GitHub through a GitHub App.
Not because it looks better in an architecture diagram. We chose it because it lets us apply granular control in two places that matter:
- The repositories where it is installed.
- The permissions it receives on those repositories.
The app has its own identity and does not depend on the personal account of whoever set up the first test. Its installation can also be limited to the repositories used by the agent.
If Copilot needs to query three repositories, we install the app on those three. Not across the entire organisation “in case we need it someday”.
And if the use case is reading content, issues, and pull requests, we start with read access. Not write access “just in case”. That just in case is a close relative of we will fix it before production, and we all know how that story ends.
The GitHub App allowed us to separate technical access from personal accounts and reduce the actual scope of the connection.
That solved part of the problem, but not all of it.
Two layers of protection
We had to control two different layers:
- What the GitHub App can do.
- What the MCP server offers to Copilot.
They are not the same thing.
Imagine that the MCP server publishes tools to search issues, create issues, modify files, and merge pull requests. Even if the GitHub App has read-only permissions and blocks dangerous operations, it makes no sense to show the agent tools it should never use.
The reverse is also true. Removing a write tool from the catalogue is not a reason to grant the GitHub App write access.
Our decision was to apply least privilege at both layers:
- Access only to the repositories that are needed.
- GitHub permissions adjusted to the use case.
- MCP tools limited to the expected operations.
- No destructive or write actions without a specific need.
- No trusting the prompt to tell the model to behave itself.
An instruction such as “do not modify any issues” expresses an intention. A read-only permission prevents the issue from being modified.
If an operation must not happen, block it technically. Do not politely ask the model not to do it.
Be careful with dynamic discovery
Microsoft 365 Copilot uses dynamic tool discovery by default. This lets it query the MCP server at runtime to find out which tools it exposes, without declaring them manually one by one. It is also possible to fix a specific set of tools. 3
Dynamic discovery is convenient during development, especially when you are changing the server.
But it has a consequence: if you add a tool to the server and do not review the exposed catalogue, the agent may discover it.
That does not mean it will execute the tool automatically or bypass GitHub permissions. It means the tool inventory is part of the security surface and needs to be treated that way.
Review the agent’s code and also check:
- Which tools the server returns.
- Which parameters each tool accepts.
- Which credentials it uses when executing them.
- What information its results include.
- How it behaves when it receives unexpected input.
The MCP server is not a neutral pipe. It is an API for agents. It has to be governed like an API.
Asking a question does not prove it is finished
The guide suggests testing the agent from Microsoft 365 Copilot: select it, ask for something that invokes the MCP server, authorise the connection when prompted, and check the result. For an interactive MCP App, you also need to check that the widget renders correctly. 4
We did that check, but we did not stop at the happy path.
The negative tests mattered too:
- It can query an authorised repository.
- It cannot query a repository outside the installation.
- It can read the necessary issues.
- It cannot modify them.
- It discovers only the expected tools.
- Secrets do not appear in responses or logs.
- An invalid request fails without exposing the internals.
- Credentials can be revoked and rotated in a controlled way.
An integration is finished when it does what it should and fails where it should fail.
How to create a proper mess
There are several highly effective ways to turn a good test into a future incident:
Install the GitHub App on every repository.
It is more convenient than selecting them. It also increases the scope of any mistake and allows the agent to reach projects unrelated to its purpose.
Grant write access when you only need to read.
Reading a pull request does not require approving it. Summarising an issue does not require closing it. Searching documentation does not require modifying the repository.
Expose every available tool.
The fact that the server can do twenty things does not mean this agent needs all twenty.
Use personal credentials as infrastructure.
Paco’s token works perfectly until Paco changes projects, loses permissions, or cleans up old tokens on a Friday afternoon.
Leave the server unauthenticated because you are still testing.
The documentation allows this option for development, not for leaving a remote endpoint exposed and forgetting about it. 2
Assume Microsoft 365 permissions replace GitHub permissions.
They are different boundaries. Access to the agent, access to the MCP server, and final access to GitHub must be reviewed separately.
Put all your trust in the prompt.
Prompts guide behaviour. They are not an authorisation policy.
Is it worth it?
Yes, if you have a specific use case.
Checking the status of a feature, summarising pending pull requests, or finding documentation spread across repositories are examples where this connection can save a lot of work.
But the value is not being able to say that you connected GitHub to Copilot through MCP. That is only useful for giving your architecture diagram more boxes.
The value is providing convenient access to a well-defined part of the information, keeping a controlled identity, and making sure the agent cannot do more than necessary.
Microsoft’s documentation helped us get the agent running and understand the flow of an MCP App inside Copilot. Our part was adapting it to GitHub, replacing the quick solution based on personal credentials with a GitHub App, and applying least privilege both in GitHub and in the tools exposed by the server.
In the end, the lesson was fairly simple.
Connecting GitHub to Microsoft 365 Copilot is not the difficult part. The difficult part is connecting it without creating a mess six months later, when the demo has become infrastructure and nobody remembers why it had access to everything.
Connecting GitHub to Copilot?
If you are building an MCP integration and are not sure whether it can see or change more than it should, talk to us. We can review the permissions, narrow the exposed tools, and test the failure cases before your demo becomes production infrastructure.
If your integration also needs to authorize the agent and MCP server, read how we approach OAuth, scopes, and tokens.
References
Dealing with something similar?
Tell us what you want to build, fix, or decide. We will tell you what makes sense and what would be a waste of time.
Talk about your projectYou may also find useful
Artificial intelligence / Security and compliance / Software / Architecture
MCP connects AI to your app. Easy, right?
Read articleArtificial intelligence / Business and product / Security and compliance / Software
How to build a SaaS with AI without getting hacked
Read articleArtificial intelligence / Software / Architecture