Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI Enterprise Adapter

From Leeroopedia
Knowledge Sources
Domains Enterprise, Tools, Integration
Last Updated 2026-02-11 00:00 GMT

Overview

Adapter that connects CrewAI agents to the CrewAI Plus/Enterprise platform, dynamically creating tools from enterprise actions available through the API.

Description

This module implements two main classes that bridge CrewAI's open-source framework with enterprise features:

EnterpriseActionTool is a BaseTool subclass that executes specific enterprise actions. It dynamically generates Pydantic args_schema models from JSON Schema definitions using create_model(). Key features include:

  • JSON Schema to Pydantic conversion: Handles anyOf, oneOf, allOf, enum, arrays, and nested objects
  • Nested model creation: Recursively builds Pydantic models for complex object parameters with a model registry to avoid duplicates
  • Nullable field handling: Properly manages required nullable fields in API requests
  • HTTP execution: Sends validated parameters via POST to the enterprise API with Bearer token authentication
  • Name sanitization: Converts action names to valid Python class names

EnterpriseActionKitToolAdapter is a factory class that:

  • Fetches available actions from the enterprise API (/actions endpoint)
  • Parses action schemas from categorized action lists
  • Creates EnterpriseActionTool instances with detailed parameter descriptions
  • Supports legacy tokens with deprecation warnings
  • Implements context manager protocol (__enter__/__exit__) for resource management

Usage

Use this adapter when connecting CrewAI agents to the CrewAI Enterprise platform (AMP). Initialize with an enterprise action token to automatically discover and create tools for all available enterprise integrations.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/adapters/enterprise_adapter.py
  • Lines: 1-432

Signature (EnterpriseActionTool)

class EnterpriseActionTool(BaseTool):
    """A tool that executes a specific enterprise action."""

    enterprise_action_token: str = Field(default="", description="The enterprise action token")
    action_name: str = Field(default="", description="The name of the action")
    action_schema: dict[str, Any] = Field(default={}, description="The schema of the action")
    enterprise_api_base_url: str = Field(default=ENTERPRISE_API_BASE_URL, description="The base API URL")

Signature (EnterpriseActionKitToolAdapter)

class EnterpriseActionKitToolAdapter:
    """Adapter that creates BaseTool instances for enterprise actions."""

    def __init__(
        self,
        enterprise_action_token: str,
        enterprise_api_base_url: str | None = None,
    ):

Import

from crewai_tools.adapters.enterprise_adapter import (
    EnterpriseActionTool,
    EnterpriseActionKitToolAdapter,
)

I/O Contract

EnterpriseActionKitToolAdapter Inputs

Name Type Required Description
enterprise_action_token str Yes Authentication token for the enterprise API (prefix "PK_" for new tokens)
enterprise_api_base_url str or None No Override base URL (default from CREWAI_PLUS_URL env var or https://app.crewai.com)

EnterpriseActionTool Inputs

Name Type Required Description
name str Yes Tool name
description str Yes Tool description
enterprise_action_token str Yes Bearer token for API authentication
action_name str Yes Name of the enterprise action to execute
action_schema dict Yes JSON Schema defining action parameters
enterprise_api_base_url str or None No Override base URL

Outputs

Name Type Description
tools() return list[BaseTool] List of dynamically created tools from enterprise actions
_run() return str JSON result string from API execution, or error message

Key Functions

Helper Function

def get_enterprise_api_base_url() -> str:
    """Get the enterprise API base URL from environment or use default."""
    base_url = os.getenv("CREWAI_PLUS_URL", "https://app.crewai.com")
    return f"{base_url}/crewai_plus/api/v1/integrations"

Usage Examples

Basic Usage

from crewai_tools.adapters.enterprise_adapter import EnterpriseActionKitToolAdapter

# Create the adapter with an enterprise token
adapter = EnterpriseActionKitToolAdapter(
    enterprise_action_token="PK_your_token_here"
)

# Get all available enterprise tools
enterprise_tools = adapter.tools()

# Use with a CrewAI agent
agent = Agent(
    role="Enterprise Assistant",
    tools=enterprise_tools,
)

Context Manager Usage

with EnterpriseActionKitToolAdapter(
    enterprise_action_token="PK_your_token_here"
) as tools:
    agent = Agent(role="Assistant", tools=tools)

Environment Variable Configuration

# Set environment variables
# CREWAI_PLUS_URL=https://custom-instance.crewai.com
# CREWAI_ENTERPRISE_TOOLS_TOKEN=PK_fallback_token

adapter = EnterpriseActionKitToolAdapter(
    enterprise_action_token=None  # Falls back to env var
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment