Understanding MCP Policies
Overview
BlueRock Secure MCP Server enforces runtime security controls through configurable MCP Protection Policies.
Policies are evaluated at runtime for both MCP client requests and MCP server responses. They operate as an enforcement layer and do not require infrastructure redeployment.
When remediation is enabled (remediate: true), the MCP client or server program execution is terminated upon a policy violation. When remediation is disabled (remediate: false), BlueRock Secure MCP Server operates in observe mode and logs policy violations while allowing execution to continue.
MCP policies can be applied to MCP servers implemented in:
• Python MCP servers • JavaScript / TypeScript MCP servers
Policies regulate:
MCP client-server connections
Transport protocols (HTTP, SSE, stdio)
Authentication requirements
Tool execution behavior
Resource access controls
Prompt invocation restrictions
Pattern-based detection in arguments and responses
Policy Categories
MCP policies are logically grouped based on the type of control they enforce.
1. Connection Control Policies
Control how MCP clients connect to MCP servers.
Capabilities include:
Restricting stdio, HTTP, or SSE transports
Enforcing authentication for HTTP/SSE connections
Configuring exception lists for specific MCP server programs or URLs
2. Tool Execution Policies
Control how MCP clients invoke tools exposed by MCP servers.
Capabilities include:
Restricting execution of specific tools
Detecting forbidden patterns in tool arguments
Inspecting tool responses for unsafe content
3. Resource Access Policies
Control access to MCP-exposed resources.
Capabilities include:
Denying specific resource URIs
Applying server-specific resource rules
4. Prompt Execution Policies
Control prompt execution behavior within MCP interactions.
Capabilities include:
Denying specific prompts from specific MCP server
Detecting unsafe prompt arguments
Inspecting prompt responses for restricted patterns
5. Built-in MCP request/response message audit policies
Provide predefined detection for common risky patterns such as:
Dangerous shell commands
Privilege escalation attempts
Sensitive file paths
Suspicious network commands
Potential data exfiltration behavior
These apply across tool calls, prompt execution, and resource interactions.
MCP Protection Policies – Use Cases
This section demonstrates runtime enforcement behavior for MCP client-server interactions in 26.08.0 Release.
Prerequisites:
This section assumes the following setup is completed:
• Create an MCP project directory • Create a Python virtual environment • Create FastMCP client and FastMCP server programs • Install the fastmcp package • Install the bluepython package • Load the bluepython package before executing the client or server program
MCP Connection Control
Deny Client Connection to stdio Server
Policy Configuration
Running MCP Client with MCP stdio Server
Expected Behavior
remediate: false
Connection allowed, violation logged (WARN)
remediate: true
Connection blocked, violation logged as ERROR, program terminated
OTEL Violation (Observe)
OTEL Violation (Enforce)
Deny stdio with Exception
Policy Configuration
Running MCP Client with MCP stdio Server
Expected Behavior
Matching command in exception list is allowed. No policy violation event is generated. A source event for the stdio connection is emitted.
Source Event
Deny Client Connection to HTTP Server
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Connection succeeds, WARN logged
remediate: true
Connection blocked
OTEL Violation (Observe)
OTEL Violation (Enforce)
Deny HTTP Server with Exception
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
HTTP connections blocked by default. URL in exception list is allowed. No violation event generated.
Example Source Event
Deny any mcp server connection without authentication
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Unauthenticated connection allowed, WARN logged
remediate: true
Unauthenticated connection blocked
OTEL Violation (Observe)
OTEL Violation (Enforce)
MCP Tool Execution Control
Tool Overwrite - Denied tools are excluded from the tool/list
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Tool is listed and violation logged
remediate: true
Tool is excluded from the list of tools.
OTEL Violation (Observe)
OTEL Violation (Enforce)
Deny Specific Tool from Specific MCP Server
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Tool executes, violation logged
remediate: true
Tool call blocked
OTEL Violation (Observe)
OTEL Violation (Enforce)
Tool Argument Pattern Detection
Policy Configuration
Running MCP Client with MCP HTTP Server
If the tool argument contains commands matching the built-in forbidden patterns (for example cat, rm, grep, etc.), the request triggers the built-in MCP audit policy.
Expected Behavior
remediate: false
Tool executes, WARN logged
remediate: true
Tool blocked
OTEL Violation (Observe)
OTEL Violation (Enforce)
Tool Response Pattern Detection
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
If tool output contains forbidden patterns:
remediate: false
Response allowed, violation logged
remediate: true
Response blocked
OTEL Violation (Observe)
OTEL Violation (Enforce)
MCP Resource Access Control
Deny Specific Resource
Policy Configuration
Running MCP Client with MCP HTTP Server
Run the MCP client with a resource URI that matches the deny_list.
Expected Behavior
remediate: false
Resource allowed, violation logged
remediate: true
Resource access denied
OTEL Violation (Observe)
OTEL Violation (Enforce)
MCP Prompt Execution Control
Deny Specific Prompt
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Prompt execution proceeds, but a violation event is generated.
remediate: true
Prompt invocation is blocked and the MCP client execution is terminated.
OTEL Violation (Observe)
OTEL Violation (Enforce)
Prompt Argument Pattern Detection
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Prompt execution proceeds, but a violation event is generated.
remediate: true
Prompt invocation is blocked and the MCP client execution is terminated.
OTEL Violation (Observe)
OTEL Violation (Enforce)
Prompt Response Pattern Detection
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
If response contains nc, curl, etc:
remediate: false
Response allowed, violation logged
remediate: true
Response blocked
OTEL Violation (Observe)
OTEL Violation (Enforce)
Message Size Violation
Policy Configuration
Running MCP Client with MCP HTTP Server
Expected Behavior
remediate: false
Request proceeds; violation logged (WARN)
remediate: true
Request proceeds; violation logged (WARN)
OTEL Violation (Observe)
Summary
remediate: false
Observe mode – Action allowed, WARN logged
remediate: true
Enforce mode – Action blocked, ERROR logged
All violations are emitted as OTEL events and sent to external collector such as AWS CloudWatch based on the configurations.
event_name: mcp_policy_violationseverity_text: WARN or ERRORtype:"log" (observe events)"remediation" (enforce events)
remediation_kind: "block" (enforce mode only)
Last updated