Securing tools¶
A checklist for a server that others will call.
- Authenticate on HTTP. Configure a FastMCP auth provider (
OunceServer(..., auth=...)passes through to FastMCP) and setaudience=to the server's own resource URL, so tokens for other services are refused. - Put a policy on every write.
policy=writes_require(authenticated)on the server, andrequire_scopes(...)orrequire_tenant(...)on sensitive tools.ouncemcp checkwarns about destructive tools without one. - Use your own upstream credentials. Install
passthrough_guard()on your HTTP client so the caller's MCP token can never be forwarded: - Cache through
ctx.cache, never a module-level dict keyed by arguments alone. - Hand out handles and approvals with
ctx.issue_state, and accept them withctx.verify_state(..., consume=True)for approvals. - Ask before you act. Call
ctx.require_inputbefore any irreversible effect; mark the effect withctx.effect_applied(). - Set
OUNCEMCP_CURSOR_KEYSon every replica; cursors and state tokens are signed with it. - Run the security catalog in your tests (testing).