Skip to main content

Secure AI Adapters for OpenAI, Claude, LangChain, and MCP

Project description

MACAW Secure AI Adapters

License Python Version

Drop-in replacements for OpenAI, Anthropic, LangChain, and MCP for deterministic policy-based security controls for enterprise apps.

What This Is

Open source interfaces that add MACAW transparently to popular LLM and Agentic frameworks.

MACAW creates a distributed zero-trust mesh where tool endpoints serve as policy enforcement points, enabling preventative, deterministic security controls - even for non-deterministic LLMs and Agentic applications.

These adapters are thin wrappers that route requests through the MACAW security layer. Change one import line and get:

  • Deterministic policy enforcement - Control models, tokens, operations, data access, and actions performed
  • Identity propagation - User identity flows through every LLM call for per-user policies
  • Cryptographic audit trail - Complete record of all AI operations with signatures
  • Zero code changes - Your existing code works unchanged

Learn more about our research: Authenticated Workflows | Protecting Context and Prompts

Installation

From PyPI:

pip install macaw-adapters[all]

# Or install specific adapters only
pip install macaw-adapters[openai]
pip install macaw-adapters[anthropic]
pip install macaw-adapters[langchain]
pip install macaw-adapters[mcp]

From source:

git clone https://github.com/macawsecurity/secureAI.git
pip install "./secureAI[all]"

Quick Start

SecureOpenAI

# Before
from openai import OpenAI
client = OpenAI()

# After - just change the import
from macaw_adapters.openai import SecureOpenAI
client = SecureOpenAI(app_name="my-app")

# Same API, now with MACAW security
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

SecureAnthropic

# Before
from anthropic import Anthropic
client = Anthropic()

# After
from macaw_adapters.anthropic import SecureAnthropic
client = SecureAnthropic(app_name="my-app")

# Same API
response = client.messages.create(
    model="claude-3-haiku-20240307",
    max_tokens=100,
    messages=[{"role": "user", "content": "Hello!"}]
)

SecureMCP

from macaw_adapters.mcp import SecureMCP

mcp = SecureMCP("calculator")

@mcp.tool(description="Add two numbers")
def add(a: float, b: float) -> float:
    return a + b

mcp.run()

LangChain

# Before
from langchain_openai import ChatOpenAI

# After
from macaw_adapters.langchain import ChatOpenAI

# Same API
llm = ChatOpenAI(model="gpt-4")
response = llm.invoke("Hello!")

Multi-User Support

For SaaS applications with per-user policies:

from macaw_adapters.openai import SecureOpenAI
from macaw_client import MACAWClient, RemoteIdentityProvider

# Create shared service
service = SecureOpenAI(app_name="my-saas")

# Authenticate user
jwt_token, _ = RemoteIdentityProvider().login("alice", "password")
user = MACAWClient(user_name="alice", iam_token=jwt_token, agent_type="user")
user.register()

# Bind user to service - their identity flows through
user_openai = service.bind_to_user(user)

# Policies evaluated against alice's permissions
response = user_openai.chat.completions.create(...)

How It Works

┌─────────────┐     ┌─────────────────────┐     ┌─────────────────────┐
│   Your App  │────▶│  Secure Adapter     │────▶│   LLM API           │
│             │     │  (SecureOpenAI,etc) │     │   (OpenAI, Claude)  │
└─────────────┘     └──────────┬──────────┘     └─────────────────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │  MACAW Client       │
                    │  Endpoint           │
                    └──────────┬──────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │  Trust Layer        │
                    │  Control Plane      │
                    │  ─────────────────  │
                    │  • Policy Engine    │
                    │  • Identity/Claims  │
                    │  • Audit Trail      │
                    └─────────────────────┘

Key Features

Feature Description
Drop-in Replacement Change one import, keep all your code
Per-User Policies Different users get different permissions
Model Restrictions Control which models each user can access
Token Limits Enforce max_tokens per user/role
Streaming Support Full support for streaming responses
Audit Logging Cryptographically signed audit trail

Requirements

  • Python 3.9+
  • macaw_client v0.5.25+ - The MACAW client library (download from console)

Getting Started

  1. Sign up at console.macawsecurity.ai
  2. Download and install macaw_client
  3. Configure your workspace and policies
  4. Install macaw-adapters and start building

Adapters

Adapter Package Wraps
SecureOpenAI macaw_adapters.openai OpenAI Python SDK
SecureAnthropic macaw_adapters.anthropic Anthropic Python SDK
SecureMCP macaw_adapters.mcp Model Context Protocol
LangChain macaw_adapters.langchain LangChain (OpenAI, Anthropic, Agents)

Examples

See the examples/ directory for complete working examples:

  • examples/openai/ - OpenAI adapter examples
  • examples/anthropic/ - Anthropic adapter examples
  • examples/langchain/ - LangChain integration examples
  • examples/mcp/ - MCP server and client examples

Console Dev Hub

Everything in this repository is also available in the MACAW Console's Dev Hub with interactive features:

Console > Dev Hub
├── Quick Start
│   └── Download Client SDK (macOS/Linux/Windows, Python 3.9-3.12) and Adapters
├── Tutorials
│   └── Role-Based Access Control
│       ├── Multi-User SaaS Patterns
│       ├── Agent Orchestration
│       └── Policy Hierarchies
├── Examples
│   ├── OpenAI (drop-in, multi-user, streaming, A2A)
│   ├── Anthropic (drop-in, multi-user, streaming, A2A)
│   ├── MCP
│   │   ├── Simple Invocation
│   │   ├── Discovery & Resources
│   │   ├── Logging
│   │   ├── Progress Tracking
│   │   ├── Sampling
│   │   ├── Elicitation
│   │   └── Roots
│   └── LangChain
│       ├── Drop-in Agents
│       ├── Multi-user Permissions
│       ├── Agent Orchestration
│       ├── LLM Wrappers (OpenAI, Anthropic)
│       └── Memory Integration
└── Reference
    ├── MACAW Client SDK
    ├── Adapter APIs
    ├── MAPL Policy Language
    └── Claims Mapping

Access at console.macawsecurity.ai → Dev Hub tab.

Research

Learn more about the technical foundations of MACAW:

Links

License

Apache 2.0 - See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macaw_adapters-0.5.26.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macaw_adapters-0.5.26-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file macaw_adapters-0.5.26.tar.gz.

File metadata

  • Download URL: macaw_adapters-0.5.26.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for macaw_adapters-0.5.26.tar.gz
Algorithm Hash digest
SHA256 151727643b8d3e270b2f2fe1775a8e1b1e240af4b30fd54a1abf440b8bcebdf3
MD5 ab80c3205c6f511030668fcd68c5f6e2
BLAKE2b-256 5a53e1a3d171bda68ef06aa492bb88e69455ec150ff462a6c3598ed95360e98d

See more details on using hashes here.

File details

Details for the file macaw_adapters-0.5.26-py3-none-any.whl.

File metadata

File hashes

Hashes for macaw_adapters-0.5.26-py3-none-any.whl
Algorithm Hash digest
SHA256 76a54eabb8a0ffd93aba60922b2a034db8a7e39890223dfacc0fc733a1edac9f
MD5 c4a7063af8f2cd1a568d10b0e570531f
BLAKE2b-256 1a3237d8e7054ca1ec628dfaba690fcf293082d97b73b9448b7a8bdb8a040cc4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page