Securing a Hosted MCP Server
Plan for a hosted MCP server for the knowledge base that claude.ai on the web and on mobile can use, while nobody else can.
Reviewed by adrian
on
A hosted MCP server would let claude.ai on the web and on mobile read and fill the knowledge base. This plan collects what has to be in place so that nobody else can use it. Status: planned, not built; the hosting is not decided yet.
Not behind WireGuard
The approach of Hermes Agent on a VPS behind WireGuard does not carry over. With a connector in claude.ai, the connection to the MCP server comes from Anthropic's cloud, not from my device, and that cloud is not in the tunnel. The server has to be publicly reachable, and authentication does the protecting.
1. Authentication with OAuth
- claude.ai supports OAuth for custom connectors: I sign in once, and Claude gets a token that expires.
- Use a ready-made identity provider instead of a self-built login server, self-hosted on yaksha: for example Pocket ID, Authelia, Authentik or Keycloak. Pocket ID is the leanest for one person and signs in with a passkey.
- Allow only my account. If clients may register themselves (Dynamic Client Registration), any client can register, so the login is the real barrier: no sign-up and no further users in the identity provider.
- The MCP server checks every token: signature, expiry, issuer and audience, so a token issued for another service is not accepted.
- No static token in the URL such as
?key=…: it ends up in logs, and whoever knows the URL has access.
2. Least privilege
- Remotely, offer only reading and creating drafts.
mark_reviewedand anything that writes directly stays local, so my review remains a second safeguard. - Decide whether private nodes may be read remotely at all; they contain infrastructure details. One option: private nodes only locally.
- Prompt injection: content Claude reads from web pages or mails could try to write into the knowledge base through the tool. Allowing only drafts catches that.
3. Isolation
- A container of its own, not privileged, without the Docker socket, seeing only the knowledge base folder, read-only where possible, with a separate folder for drafts.
- The same
DOCKER-USERrule as for Hermes Agent against the tunnel network10.0.0.0/24, so the container cannot reach the Mac. - Set up the Git remote with a backup first, so every change can be rolled back.
4. Transport and operation
- HTTPS through Caddy, without
encodeon the MCP path, since streaming must not be buffered. - Rate limiting and an access log to see access attempts.
- Optionally allow only the IP ranges Anthropic publishes in its documentation, as an extra layer that does not replace authentication.
5. Tests before adding the connector
- A request without a token returns
401. - An expired or foreign token is rejected.
- Signing in with an account other than mine fails.
Based on
-
Securing a hosted MCP server for the knowledge base
(
raw/2026/2026-11-14/securing-a-hosted-mcp-server-for-the-knowledge-base.md) [chat] -
Explaining OpenAI's post on securing persistent agents
(
raw/2026/2026-11-15/explaining-openai-s-post-on-securing-persistent-agents.md) [chat-2026-11-15]
Topic
- Model Context Protocol Open protocol through which AI apps such as Claude Code and Claude Desktop connect to servers that offer them tools and data.
Mentioned
- Anthropic American AI company, a public benefit corporation in San Francisco, that develops the Claude language models.
See also
- Hermes Agent on a VPS Behind WireGuard Guide: Hermes Agent in Docker on the VPS yaksha, dashboard behind Caddy and reachable only through WireGuard, container cut off from the tunnel network.
- How an LLM Wiki Works How an LLM wiki works, shown on this knowledge base: Markdown in its own Git repository, a Python tool with MCP for agents, and a website that only displays it.
- Securing a Persistent AI Agent How to let an AI agent work on its own without handing it the keys: OpenAI's five safeguards explained, and how I apply them to my own agents.