MCP integrations
AI Foundry Hub can connect an approved Model Context Protocol (MCP) provider and expose its tools through a controlled backend API. The Hub handles the provider connection, OAuth flow, tool discovery, user consent, argument validation, and idempotent tool invocation.
MCP integration endpoints are server-to-server only. Never expose the Hub API key or accept X-Integration-Subject directly from browser input. Your backend must derive the subject from its authenticated user session.
Before you start
Section titled “Before you start”Your application must be registered by an AI Foundry Hub operator for the MCP providers it may use. A normal Hub API key is not enough on its own. Every request except the OAuth callback requires:
Authorization: Bearer <registered-server-api-key>X-Integration-Subject: <opaque-authenticated-user-id>The subject must be stable for the signed-in user and opaque to the provider. MCP availability and the provider catalogue depend on the Hub environment configuration. When MCP is disabled, GET /v1/integrations returns an empty integrations array.
Connection lifecycle
Section titled “Connection lifecycle”| Step | Method and path | Result |
|---|---|---|
| List providers | GET /v1/integrations | Catalogue with status, auth mode, and allowed actions |
| Start connection | POST /v1/integrations/{provider}/connection | next_action is authorize or review |
| Start OAuth | POST /v1/integrations/{provider}/authorization | Provider authorization_url |
| Review tools | GET /v1/integrations/{provider}/review | Tool snapshot, revision, and snapshot hash |
| Approve tools | POST /v1/integrations/{provider}/consent | Activates the reviewed snapshot |
| List active tools | GET /v1/integrations/{provider}/tools | Consented tools and current snapshot hash |
| Call a tool | POST /v1/integrations/{provider}/calls | MCP tool result |
| Revoke | DELETE /v1/integrations/{provider}/connection | Removes credentials and invalidates pending authorization |
Start by listing the catalogue:
curl "https://api.aifoundryhub.com/v1/integrations" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "X-Integration-Subject: $PRODUCT_USER_ID"Each integration includes status, auth_mode, and an actions array such as connect, review, or revoke. Use only the actions returned by the API.
Connect and authorize
Section titled “Connect and authorize”curl -X POST "https://api.aifoundryhub.com/v1/integrations/atlassian/connection" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "X-Integration-Subject: $PRODUCT_USER_ID"If the response is {"next_action":"authorize"}, request an authorization URL from /authorization and redirect the user to the returned HTTPS URL. The provider redirects back to the Hub callback; the Hub then redirects to your application’s pre-registered return URL. Do not construct callback or return URLs from request data.
Review and consent
Section titled “Review and consent”After authorization, retrieve the exact tool snapshot:
curl "https://api.aifoundryhub.com/v1/integrations/atlassian/review" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "X-Integration-Subject: $PRODUCT_USER_ID"Show the tools to the user, then send the unchanged revision and snapshot_hash back to the consent endpoint:
curl -X POST "https://api.aifoundryhub.com/v1/integrations/atlassian/consent" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "X-Integration-Subject: $PRODUCT_USER_ID" \ -H "Content-Type: application/json" \ -d '{"revision":"<revision>","snapshot_hash":"<snapshot-hash>"}'A 409 conflict means the connection or tool snapshot changed. Fetch /review again and ask the user to approve the new snapshot.
Call an MCP tool
Section titled “Call an MCP tool”First call GET /v1/integrations/{provider}/tools. Tool names are namespaced by the Hub, and the response includes the snapshot_hash required for invocation.
curl -X POST "https://api.aifoundryhub.com/v1/integrations/atlassian/calls" \ -H "Authorization: Bearer $AI_FOUNDRY_HUB_API_KEY" \ -H "X-Integration-Subject: $PRODUCT_USER_ID" \ -H "Content-Type: application/json" \ -d '{ "invocation_id": "01JD3EXAMPLESTABLEID", "snapshot_hash": "<snapshot-hash>", "tool": "<namespaced-tool-name>", "arguments": {"query": "project = HUB"}, "expires_at": "<RFC3339 timestamp within five minutes>" }'invocation_id must be stable for one product-level attempt, and expires_at must be no more than five minutes in the future. Arguments are validated against the approved tool schema. Do not automatically retry an uncertain provider_unavailable result with a new invocation ID: first make a product-level decision with the user.
Errors
Section titled “Errors”| HTTP status | Error | Meaning |
|---|---|---|
400 | invalid_request | Missing/invalid headers, payload, provider, tool, or expired invocation |
401 | unauthorized_client | API key is not registered, is expired/revoked, or does not match the registered owner |
403 | needs_setup | MCP is not configured for this environment |
409 | conflict | Connection state or tool snapshot changed |
503 | provider_unavailable | Provider, storage, OAuth, or MCP operation is temporarily unavailable |
The Hub never forwards your Hub API key to an MCP provider. Provider credentials and approved tool snapshots are stored per registered application, subject, and provider.