DEV Community

Harish Gaggar
Harish Gaggar

Posted on

Building an OAuth-Secured MCP Gateway for Enterprise Agents

Reference stack for teams standing up an MCP gateway and MCP servers from scratch, especially useful behind air-gapped/restricted networks where typical SaaS patterns don't apply.

It includes a working gateway, example MCP servers (Artifactory, GitHub, Google Drive), and a governed LangGraph agent, all runnable locally via Docker. The design leans on a few principles: per-call OAuth, continuous audit logging, PII/secret scrubbing before anything reaches the LLM, eval/tracking per query, persistent memory across restarts, and context trimming to control token spend.

It's meant to be forked and adapted rather than used as a hosted product. Would love feedback from anyone building similar internal agent infrastructure, especially on the OAuth flow and the safety-kit approach to PII stripping.

Repo: https://github.com/harish-gaggar/mcp-server-gateway

If you find it useful, a star on the repo helps others discover it too. Much appreciated!

Top comments (0)