Blog
Permissions and audit logs for AI agents that touch production
How platform teams scope MCP access, rotate credentials once, and keep an audit trail when agents query GitHub, Forge, and PostHog.
By Andreas Gade Hjarnø
Featured integrations
Agents need the same controls as humans
Giving an AI client a personal GitHub PAT, a Forge API key, and a PostHog project token works until security asks three questions:
- Which tools can this agent call?
- Who rotated the credential last, and which clients still hold a copy?
- Can we prove what the agent read during last night's incident?
Direct MCP connections answer none of those cleanly. Each vendor token lives in a different client config, scopes are all-or-nothing, and there is no shared audit log.
Centralize credentials, decentralize privilege
stackgate.ai's private gateway (/mcp/private) is the control plane between your agents and production systems:
- Connect once in the hub — OAuth or API keys stay in stackgate.ai; MCP clients never store upstream secrets.
- Issue scoped hub tokens — grant
mcp:private-gatewayplus only the integrations an agent needs (for example read-only GitHub + Forge, no deploy triggers). - Audit every call — each
tools/callrecords integration, tool name, and outcome for review after an incident.
Namespaced tools such as github__list-workflow-runs-tool, forge__list-deployments-tool, and PostHog query tools all share that trail.
What least privilege looks like in practice
| Concern | Gateway approach |
|---|---|
| On-call agent | Token limited to GitHub, Forge, and PostHog — no CRM or mail access |
| Deploy safety | Prefer read-only Forge scopes; require a human for trigger-deployment-tool |
| Credential rotation | Rotate the Forge or GitHub secret in My Integrations; every client keeps the same hub bearer |
| Post-incident review | Export audit logs for the incident window and attach them to the handoff |
Where to start
- Connect GitHub, Forge, and PostHog under My Integrations.
- Create an API token scoped to those three integrations.
- Point your MCP client at the private gateway URL with that bearer token.
- Run
list-services-tool, then a read-only call such as listing recent Forge deployments.
When you are ready for a full on-call flow — correlating PostHog spikes with deploys and CI — use the incident triage workflow playbook.
Try the related workflow
Correlate a production error spike with failing GitHub Actions runs and Forge deploy history.