git clone https://github.com/mulesoft/pdk-custom-policy-examples.git
ssh
Custom Policy Examples
Flex Gateway Policy Development Kit (PDK) provides example policy projects to help you start configuring your Rust source code.
You can find all example policies and their documentation in the PDK Custom Policy GitHub Repository.
API Policy Examples
PDK includes the following API example policies:
-
Block Policy Example
: Use the Block Policy as an example of how to block IP ranges by implementing periodic functions and HTTP calls.
-
Certification Policy Example
: Use the Certification Policy as an example of how to obtain data concerning connection certificates.
-
CORS Validation Policy Example
: Use the CORS Validation Policy as an example of how to use functions of the CORS Library in your custom policy.
-
Crypto Policy Example
: Use the Crypto Policy as an example of how to use third-party libraries that provide cryptography capabilities in your custom policy.
-
Data Caching Policy Example
: Use the Data Caching Policy as an example of how to implement data caching in your custom policy.
-
JWT Validation Policy Example
: Use the JWT Validation Policy as an example of how to use functions of the JWT Library in your custom policy.
-
Metrics Policy Example
: Use the Metrics Policy as an example of how to periodically send data to a metric ingestion service by implementing periodic functions and HTTP calls.
-
Query Policy Example
: Use the Query Policy as an example of how to handle DataWeave expressions in your custom policy.
-
Simple OAuth 2.0 Validation Policy Example
: Use the Simple OAuth 2.0 Validation Policy as an example of how to implement HTTP calls in your custom policy.
-
Spike Policy Example
: Use the Spike Policy as an example of how to configure worker spike control by implementing periodic functions.
-
TLS Calls Policy Example
: Use the TLS Calls Policy as an example of how to make HTTPS calls in your policy without installing certificates on the operating system running Flex Gateway.
A2A and MCP Server Policy Examples
PDK includes the following A2A and MCP example policies:
-
A2A Support Policy Example
: Demonstrates how to add A2A support.
-
MCP Support Policy Example
: Shows how to add MCP support.
-
A2A PII Detector Policy Example
: Demonstrates how to log or block sensitive information in A2A agent interactions.
-
A2A Prompt Decorator Policy Example
: Shows how to modify prompts sent to an A2A agent.
Set Up an Example Policy Project
To use an example policy project:
-
Make sure you have installed all PDK prerequisites.
-
Clone the PDK Custom Policy GitHub Repository
using the following command or your preferred GitHub interface:
-
Navigate to the newly cloned directory, then copy and paste the directory of your desired policy into a new location.
-
In the
cargo.toml
file of the copied policy example, replace thegroup-id
with your group ID, for example:group_id = "<your-group-id>"
toml -
Run the
make setup
command:make setup
ssh -
Navigate to the
README.md
file in the example policy to read more about the policy and how to test it.