CrewAI Demo — Step-by-Step Setup Guide
This guide walks you through creating a simple CrewAI pipeline that generates personal data, anonymizes it using Cloak, and then restores it using Uncloak.
Step 1: Create a Pipeline in CrewAI Studio
-
Open CrewAI Studio.
-
Create a new Pipeline.
-
Add the following three tasks:
-
generate_personal_data -
anonymize_text -
de_anonymize_text
-
-
Configure each task using the YAML below.
generate_personal_data:
description: >
Generate a text string containing personal data such as name, age, and location.
Use locale en_US if specified.
expected_output: >
A single string with realistic personal data including name, age, location, etc.
agent: personal_data_generator
anonymize_text:
description: >
Anonymize the personal data found in the input text.
Replace names, ages, locations, and other identifiable details with placeholders.
expected_output: >
A JSON response from the Cloak tool containing the anonymized sentences with placeholders
and a unique id. Sentence structure must be preserved.
agent: data_anonymizer
context:
- generate_personal_data
de_anonymize_text:
description: >
Restore the original personal information using the id and text returned
from the anonymization step.
expected_output: >
The sentence fully restored with the original personal information.
agent: data_de_anonymizer
context:
- anonymize_text
Step 2: Define Agents for Each Task
-
Create three agents and attach them to the corresponding tasks:
-
personal_data_generator→generate_personal_data -
data_anonymizer→anonymize_text -
data_de_anonymizer→de_anonymize_text
-
-
Configure each agent:
personal_data_generator:
role: >
Personal Data Generator
goal: >
Generate realistic sentence containing personal information including names, ages, genders, locations
for testing anonymization systems
backstory: >
You are a data generation specialist with expertise in creating realistic personal information datasets for testing
privacy and security systems. You understand the importance of generating diverse, realistic examples that mirror
real-world data patterns while being completely synthetic. Your generated data helps organizations test their data
protection and anonymization processes effectively.
data_anonymizer:
role: >
Data Privacy and Anonymization Expert
goal: >
Accurately identify and anonymize personal data in text to protect privacy
backstory: >
With a strong focus on data privacy, you excel at detecting personal identifiers
within text and replacing them with generic placeholders. Your work ensures sensitive
information is securely anonymized while retaining the context of the original text.
data_de_anonymizer:
role: >
Deanonymizer Agent
goal: >
Restore Personally Identifiable Information (PII) by replacing placeholders in text with their original values,
ensuring data integrity and context accuracy.
backstory: >
The Deanonymizer Agent was created to support workflows where anonymized datasets need to be reverted
for legitimate use, such as testing, debugging, or data migration.
It understands patterns of placeholders and securely maps them back to the original data
without altering the underlying meaning of the content.
Step 3: Add Custom Tools
-
Open the CrewAI chat interface.
-
Register the Cloak tool and attach it to the
data_anonymizeragent. -
Register the Uncloak tool and attach it to the
data_de_anonymizeragent. -
Confirm that the tools are correctly connected by testing a sample text.
Step 4: Configure Environment Variables
-
Specify the environment variables for authentication:
MCP_SERVER_URL=your_server_url_here
MCP_AUTH_API_KEY=your_api_key_here -
Verify that both variables are accessible to all agents.
-
Confirm the pipeline can run end-to-end:
generate→anonymize→de-anonymize.