A discoverable MCP tool may have more privileges than a task requires.
The solutionKeep permission checks in the client or server dispatch boundary.
Define the boundary between agents and tools
The Model Context Protocol (MCP) standardizes access to external tools and context. It does not make every available tool safe for every caller. Tool descriptions and retrieved resources are not grants of authority.
Before connecting a tool, decide which identities can call it, which resources it can access, what destinations are allowed, and which operations are reversible. Keep credentials scoped to the user and job.
A safe tool-dispatch pipeline
- Normalize: parse the tool name and full structured argument object; reject unknown or malformed values.
- Authorize: enforce caller and tenant boundaries, exact permitted paths, and destination restrictions.
- Screen: evaluate the final action before executing it and hold suspicious calls for review.
- Approve: bind approvals to the exact validated arguments, not a generic tool name.
- Dispatch: use least-privilege credentials and idempotency protection for retried side effects; record minimal audit metadata.
Screen an MCP-compatible function action
Agent Action Guard supports structured action screening in Python and JavaScript. This Python example shows a checkpoint that your authorized MCP dispatcher can call:
from agent_action_guard import is_action_harmful
def screen_before_dispatch(tool_name, arguments):
action = {
"type": "function",
"function": {
"name": tool_name,
"arguments": arguments,
},
}
harmful, confidence = is_action_harmful(action)
if harmful:
raise PermissionError("Action blocked for review")
return confidence # Not a grant of permission
# Validate schema, caller, resource and destination first.
# Screen the final arguments, enforce approval, then dispatch.
See the JavaScript API, Python integrations, and native agent hooks. Hook adapters must normalize actual native payloads and respect each host’s project-level trust gates.
Failure and privacy are part of security
Make malformed requests and unavailable screening services fail closed. Bound input size, concurrency, and request timeouts. The project’s built-in classifier HTTP service has no authentication, TLS, or rate limiting; do not expose it directly to the internet. Use an authenticated TLS-terminating proxy and trusted-client access if remote access is required.
An external embedding provider may receive action text. Avoid logging credentials and tool arguments unnecessarily, and consult the runtime privacy notice and production guidance before deployment.