
Supercharge AI Agents: Securely Connect to GitHub & ServiceNow with MCP and Azure API Management
Want to unlock the true power of AI agents like GitHub Copilot? Integrating them with your existing tools and data is key. The Model Context Protocol (MCP) makes this possible, but security is paramount. Learn how to use Azure API Management with MCP to securely connect agents to your backend APIs, like GitHub and ServiceNow, and automate workflows like issue triage.
What is MCP and Why Should You Care?
- MCP simplifies AI integration: It's an open standard protocol that allows AI models (like those powering GitHub Copilot) to seamlessly interact with APIs, databases, and other services.
- No more custom connectors: MCP eliminates the need for complex, custom integrations, saving you time and resources.
- Real-time data access: Give your AI agents access to real-time and proprietary data, making them more valuable and effective.
Essentially, MCP is like a universal adapter for connecting your AI agents to the world.
MCP Architecture Explained
MCP follows a simple client-host-server architecture, using JSON-RPC 2.0 for communication. It supports two primary transport layers:
- stdio: Ideal for local communication – when the client and server are on the same machine.
- HTTP with Server-Sent Events (SSE): Enables secure communication over networks, including remote servers.
Why Azure API Management for MCP Servers is a Game Changer
Think of Azure API Management (APIM) as the gatekeeper for your MCP servers. It lets you:
- Secure your backend resources: Protect your APIs from unauthorized access.
- Ensure reliability: Guarantee that your services are always available.
- Monitor and troubleshoot effectively: Track requests and context flow to identify and resolve issues quickly.
By treating your MCP server endpoints as backend APIs and hosting MCP server behind Azure API Management, you gain centralized control and visibility.
Practical Example: Automate Issue Triage with GitHub Copilot, MCP, and Azure APIM
Imagine automating your issue triage process, freeing up your engineering team for more important tasks. Here's how it works:
- Engineers log bugs/feature requests as GitHub issues.
- GitHub Copilot, powered by MCP and secured by Azure APIM, analyzes the issue.
- A corresponding incident ticket is automatically generated in ServiceNow.
This automation, driven by secure MCP integrations, eliminates manual handoffs, reduces errors, and boosts efficiency.
Build and Deploy Your MCP Servers with Azure Container Apps
To make this a reality, you'll need two key MCP servers:
- GitHub Issues MCP Server: Authenticates with GitHub, retrieves user information, and lists issues.
- ServiceNow Incidents MCP Server: Authenticates with ServiceNow, lists existing incidents, and creates new incidents.
These servers are built using Azure Container Apps and are secured by Azure API Management. Azure API Management's credential manager centralizes secure credential storage.
Secure Client Authentication with Azure API Management and JWT
Protecting your sse
and /messages
endpoints is critical. Azure API Management lets you:
- Generate API Management subscription keys: Control who can access your APIs.
- Apply the
validate-jwt
policy: Ensure only clients with a valid JSON Web Token (JWT) can access protected endpoints.
See AI-Gateway/labs/model-context-protocol/src/github/apim-api/auth-client-policy.xml
for more information.
Connect Your MCP Server to VS Code and Unleash Copilot's Potential
Visual Studio Code now supports MCP, making it seamless to connect to your servers:
- Open the Command Palette and type "MCP: Add Server..."
- Select "HTTP (HTTP or Server-Sent Events)" as the server type.
- Paste in the Server URL and provide a Server ID.
GitHub Copilot can now access the defined tools, enabling agentic workflows like issue triage and automation and securely manage tokens for backend calls to GitHub and ServiceNow.
Deep Dive: Authentication and Authorization with Credential Manager
When a user initiates an authentication via the authorize_github
tool, GitHub Copilot triggers the MCP server to generate an authorization request/login URL. This is where Azure API Management's credential manager shines:
- Secure OAuth flow: APIM acts as a secure intermediary, managing the OAuth flow and token storage.
- User consent: Users are redirected to a consent page to authorize the connection.
- Token exchange and storage: APIM securely stores access and refresh tokens from GitHub.
Streamlining Tool Calling with APIs Behind API Management
Utilize the list_issues
tool to retrieve issues seamlessly:
- The MCP Client requests issues from the MCP server.
- The MCP Server attaches the authorization_id as a header and forwards the request to APIM.
- The list of issues is returned to the agent.
Beyond Triage: The Possibilities are Endless
Once you've connected GitHub and ServiceNow, the possibilities are endless. Consider defining additional tools like:
suggest_assignee
assign_engineer
update_incident_status
notify_engineer
request_feedback
These tools can build a truly closed-loop, automated engineering workflow.
Key Takeaway: Secure, Scalable AI Integrations with MCP and Azure APIM
Azure API Management empowers enterprise customers to securely integrate AI models with external tools using MCP. By leveraging credential manager, OAuth flows, and token management, you can:
- Streamline workflows
- Enhance security
- Govern your APIs effectively
Resources to Get Started
- Credential Manager: Learn how to manage OAuth 2.0 tokens to backend services.
- Client Auth for remote MCP servers:
- AZD up: https://aka.ms/mcp-remote-apim-auth
- AI lab Client Auth: AI-Gateway/labs/mcp-client-authorization/mcp-client-authorization.ipynb
Ready to transform your AI integrations with MCP and Azure API Management? Connect with Julia Kasper and Julia Muiruri to learn more.