Implementation:CrewAIInc CrewAI S3 Reader Tool
| Knowledge Sources | |
|---|---|
| Domains | Cloud_Integration, AWS_S3, File_IO |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Concrete tool for reading file content from Amazon S3 buckets provided by CrewAI.
Description
The S3ReaderTool class extends BaseTool and uses the boto3 S3 client to fetch and return file content from Amazon S3. It parses S3 paths in the standard s3://bucket-name/object-key format to extract the bucket name and object key. The tool connects to AWS using credentials from environment variables (CREW_AWS_REGION, CREW_AWS_ACCESS_KEY_ID, CREW_AWS_SEC_ACCESS_KEY) with a default region of us-east-1. File content is retrieved using get_object() and decoded as UTF-8 text. Errors from the AWS SDK are caught and returned as descriptive error strings rather than raised exceptions.
Usage
Import and use S3ReaderTool when CrewAI agents need to read text-based files (configuration files, datasets, documents, logs) stored in Amazon S3. It abstracts away the complexity of S3 API interactions and AWS authentication.
Code Reference
Source Location
- Repository: CrewAI
- File: lib/crewai-tools/src/crewai_tools/aws/s3/reader_tool.py
- Lines: 1-49
Signature
class S3ReaderTool(BaseTool):
name: str = "S3 Reader Tool"
description: str = "Reads a file from Amazon S3 given an S3 file path"
args_schema: type[BaseModel] = S3ReaderToolInput
package_dependencies: list[str] = Field(default_factory=lambda: ["boto3"])
Import
from crewai_tools.aws.s3 import S3ReaderTool
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| file_path | str | Yes | S3 file path in format "s3://bucket-name/object-key" |
Outputs
| Name | Type | Description |
|---|---|---|
| return | str | UTF-8 decoded file content on success, or an error message string on failure |
Usage Examples
Basic Usage
from crewai_tools.aws.s3 import S3ReaderTool
# Initialize the tool
reader = S3ReaderTool()
# Read a file from S3
content = reader._run(file_path="s3://my-bucket/data/report.txt")
print(content)
With CrewAI Agent
import os
from crewai_tools.aws.s3 import S3ReaderTool
# Configure AWS credentials
os.environ["CREW_AWS_REGION"] = "us-west-2"
os.environ["CREW_AWS_ACCESS_KEY_ID"] = "your-key-id"
os.environ["CREW_AWS_SEC_ACCESS_KEY"] = "your-secret-key"
reader = S3ReaderTool()
agent = Agent(
role="data_analyst",
tools=[reader],
)