macaw-adapters 0.5.22__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. macaw_adapters-0.5.22/LICENSE +190 -0
  2. macaw_adapters-0.5.22/NOTICE +5 -0
  3. macaw_adapters-0.5.22/PKG-INFO +251 -0
  4. macaw_adapters-0.5.22/README.md +200 -0
  5. macaw_adapters-0.5.22/macaw_adapters/__init__.py +35 -0
  6. macaw_adapters-0.5.22/macaw_adapters/anthropic/__init__.py +22 -0
  7. macaw_adapters-0.5.22/macaw_adapters/anthropic/secure_anthropic.py +844 -0
  8. macaw_adapters-0.5.22/macaw_adapters/langchain/__init__.py +88 -0
  9. macaw_adapters-0.5.22/macaw_adapters/langchain/_utils.py +83 -0
  10. macaw_adapters-0.5.22/macaw_adapters/langchain/agents.py +300 -0
  11. macaw_adapters-0.5.22/macaw_adapters/langchain/anthropic.py +286 -0
  12. macaw_adapters-0.5.22/macaw_adapters/langchain/callbacks.py +306 -0
  13. macaw_adapters-0.5.22/macaw_adapters/langchain/memory.py +352 -0
  14. macaw_adapters-0.5.22/macaw_adapters/langchain/openai.py +282 -0
  15. macaw_adapters-0.5.22/macaw_adapters/langchain/tools.py +158 -0
  16. macaw_adapters-0.5.22/macaw_adapters/mcp/__init__.py +46 -0
  17. macaw_adapters-0.5.22/macaw_adapters/mcp/client.py +718 -0
  18. macaw_adapters-0.5.22/macaw_adapters/mcp/decorators.py +228 -0
  19. macaw_adapters-0.5.22/macaw_adapters/mcp/fastmcp_compat.py +353 -0
  20. macaw_adapters-0.5.22/macaw_adapters/mcp/mcp.py +739 -0
  21. macaw_adapters-0.5.22/macaw_adapters/mcp/server.py +320 -0
  22. macaw_adapters-0.5.22/macaw_adapters/mcp/subscriptions.py +450 -0
  23. macaw_adapters-0.5.22/macaw_adapters/openai/__init__.py +22 -0
  24. macaw_adapters-0.5.22/macaw_adapters/openai/secure_openai.py +891 -0
  25. macaw_adapters-0.5.22/macaw_adapters.egg-info/PKG-INFO +251 -0
  26. macaw_adapters-0.5.22/macaw_adapters.egg-info/SOURCES.txt +29 -0
  27. macaw_adapters-0.5.22/macaw_adapters.egg-info/dependency_links.txt +1 -0
  28. macaw_adapters-0.5.22/macaw_adapters.egg-info/requires.txt +30 -0
  29. macaw_adapters-0.5.22/macaw_adapters.egg-info/top_level.txt +1 -0
  30. macaw_adapters-0.5.22/pyproject.toml +74 -0
  31. macaw_adapters-0.5.22/setup.cfg +4 -0
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on behalf
53
+ of the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 MACAW Security
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ MACAW Adapters
2
+ Copyright 2025 MACAW Security
3
+
4
+ This product includes software developed at MACAW Security
5
+ (https://macawsecurity.ai).
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: macaw-adapters
3
+ Version: 0.5.22
4
+ Summary: Secure AI Adapters for OpenAI, Claude, LangChain, and MCP
5
+ Author-email: MACAW Security <support@macawsecurity.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://macawsecurity.ai
8
+ Project-URL: Documentation, https://macawsecurity.ai/docs
9
+ Project-URL: Repository, https://github.com/macawsecurity/secureAI
10
+ Project-URL: Console, https://console.macawsecurity.ai
11
+ Keywords: ai,security,openai,claude,langchain,mcp,macaw
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ License-File: NOTICE
26
+ Requires-Dist: requests>=2.28.0
27
+ Requires-Dist: cryptography>=41.0.0
28
+ Provides-Extra: openai
29
+ Requires-Dist: openai>=1.0.0; extra == "openai"
30
+ Provides-Extra: claude
31
+ Requires-Dist: anthropic>=0.18.0; extra == "claude"
32
+ Provides-Extra: langchain
33
+ Requires-Dist: langchain>=0.1.0; extra == "langchain"
34
+ Requires-Dist: langchain-openai>=0.0.5; extra == "langchain"
35
+ Requires-Dist: langchain-anthropic>=0.1.0; extra == "langchain"
36
+ Provides-Extra: mcp
37
+ Requires-Dist: mcp>=0.1.0; extra == "mcp"
38
+ Provides-Extra: all
39
+ Requires-Dist: openai>=1.0.0; extra == "all"
40
+ Requires-Dist: anthropic>=0.18.0; extra == "all"
41
+ Requires-Dist: langchain>=0.1.0; extra == "all"
42
+ Requires-Dist: langchain-openai>=0.0.5; extra == "all"
43
+ Requires-Dist: langchain-anthropic>=0.1.0; extra == "all"
44
+ Requires-Dist: mcp>=0.1.0; extra == "all"
45
+ Provides-Extra: dev
46
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
47
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
48
+ Requires-Dist: black>=23.0.0; extra == "dev"
49
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
50
+ Dynamic: license-file
51
+
52
+ # MACAW Secure AI Adapters
53
+
54
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
55
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://python.org)
56
+ [![Version](https://img.shields.io/badge/version-0.5.22-green.svg)](https://github.com/macawsecurity/secureAI)
57
+
58
+ **Drop-in replacements for OpenAI, Anthropic, LangChain, and MCP for deterministic policy-based security controls for enterprise apps.**
59
+
60
+ ## What This Is
61
+
62
+ Open source interfaces that add MACAW transparently to popular LLM and Agentic frameworks.
63
+
64
+ 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.
65
+
66
+ These adapters are thin wrappers that route requests through the MACAW security layer. Change one import line and get:
67
+
68
+ - **Deterministic policy enforcement** - Control models, tokens, operations, data access, and actions performed
69
+ - **Identity propagation** - User identity flows through every LLM call for per-user policies
70
+ - **Cryptographic audit trail** - Complete record of all AI operations with signatures
71
+ - **Zero code changes** - Your existing code works unchanged
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ # Install with specific adapter
77
+ pip install macaw-adapters[openai]
78
+ pip install macaw-adapters[anthropic]
79
+ pip install macaw-adapters[langchain]
80
+ pip install macaw-adapters[mcp]
81
+
82
+ # Install all adapters
83
+ pip install macaw-adapters[all]
84
+ ```
85
+
86
+ ## Quick Start
87
+
88
+ ### SecureOpenAI
89
+
90
+ ```python
91
+ # Before
92
+ from openai import OpenAI
93
+ client = OpenAI()
94
+
95
+ # After - just change the import
96
+ from macaw_adapters.openai import SecureOpenAI
97
+ client = SecureOpenAI(app_name="my-app")
98
+
99
+ # Same API, now with MACAW security
100
+ response = client.chat.completions.create(
101
+ model="gpt-4",
102
+ messages=[{"role": "user", "content": "Hello!"}]
103
+ )
104
+ ```
105
+
106
+ ### SecureAnthropic
107
+
108
+ ```python
109
+ # Before
110
+ from anthropic import Anthropic
111
+ client = Anthropic()
112
+
113
+ # After
114
+ from macaw_adapters.anthropic import SecureAnthropic
115
+ client = SecureAnthropic(app_name="my-app")
116
+
117
+ # Same API
118
+ response = client.messages.create(
119
+ model="claude-3-haiku-20240307",
120
+ max_tokens=100,
121
+ messages=[{"role": "user", "content": "Hello!"}]
122
+ )
123
+ ```
124
+
125
+ ### SecureMCP
126
+
127
+ ```python
128
+ from macaw_adapters.mcp import SecureMCP
129
+
130
+ mcp = SecureMCP("calculator")
131
+
132
+ @mcp.tool(description="Add two numbers")
133
+ def add(a: float, b: float) -> float:
134
+ return a + b
135
+
136
+ mcp.run()
137
+ ```
138
+
139
+ ### LangChain
140
+
141
+ ```python
142
+ # Before
143
+ from langchain_openai import ChatOpenAI
144
+
145
+ # After
146
+ from macaw_adapters.langchain import ChatOpenAI
147
+
148
+ # Same API
149
+ llm = ChatOpenAI(model="gpt-4")
150
+ response = llm.invoke("Hello!")
151
+ ```
152
+
153
+ ## Multi-User Support
154
+
155
+ For SaaS applications with per-user policies:
156
+
157
+ ```python
158
+ from macaw_adapters.openai import SecureOpenAI
159
+ from macaw_client import MACAWClient, RemoteIdentityProvider
160
+
161
+ # Create shared service
162
+ service = SecureOpenAI(app_name="my-saas")
163
+
164
+ # Authenticate user
165
+ jwt_token, _ = RemoteIdentityProvider().login("alice", "password")
166
+ user = MACAWClient(user_name="alice", iam_token=jwt_token, agent_type="user")
167
+ user.register()
168
+
169
+ # Bind user to service - their identity flows through
170
+ user_openai = service.bind_to_user(user)
171
+
172
+ # Policies evaluated against alice's permissions
173
+ response = user_openai.chat.completions.create(...)
174
+ ```
175
+
176
+ ## How It Works
177
+
178
+ ```
179
+ ┌─────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
180
+ │ Your App │────▶│ Secure Adapter │────▶│ LLM API │
181
+ │ │ │ (SecureOpenAI,etc) │ │ (OpenAI, Claude) │
182
+ └─────────────┘ └──────────┬──────────┘ └─────────────────────┘
183
+
184
+
185
+ ┌─────────────────────┐
186
+ │ MACAW Client │
187
+ │ Endpoint │
188
+ └──────────┬──────────┘
189
+
190
+
191
+ ┌─────────────────────┐
192
+ │ Trust Layer │
193
+ │ Control Plane │
194
+ │ ───────────────── │
195
+ │ • Policy Engine │
196
+ │ • Identity/Claims │
197
+ │ • Audit Trail │
198
+ └─────────────────────┘
199
+ ```
200
+
201
+ ## Key Features
202
+
203
+ | Feature | Description |
204
+ |---------|-------------|
205
+ | **Drop-in Replacement** | Change one import, keep all your code |
206
+ | **Per-User Policies** | Different users get different permissions |
207
+ | **Model Restrictions** | Control which models each user can access |
208
+ | **Token Limits** | Enforce max_tokens per user/role |
209
+ | **Streaming Support** | Full support for streaming responses |
210
+ | **Audit Logging** | Cryptographically signed audit trail |
211
+
212
+ ## Requirements
213
+
214
+ - **Python 3.9+**
215
+ - **macaw_client v0.5.22+** - The MACAW client library
216
+
217
+ ### Getting Started
218
+
219
+ 1. Sign up at [console.macawsecurity.ai](https://console.macawsecurity.ai)
220
+ 2. Download and install macaw_client
221
+ 3. Configure your workspace and policies
222
+ 4. Install macaw-adapters and start building
223
+
224
+ ## Adapters
225
+
226
+ | Adapter | Package | Wraps |
227
+ |---------|---------|-------|
228
+ | SecureOpenAI | `macaw_adapters.openai` | OpenAI Python SDK |
229
+ | SecureAnthropic | `macaw_adapters.anthropic` | Anthropic Python SDK |
230
+ | SecureMCP | `macaw_adapters.mcp` | Model Context Protocol |
231
+ | LangChain | `macaw_adapters.langchain` | LangChain (OpenAI, Anthropic, Agents) |
232
+
233
+ ## Examples
234
+
235
+ See the [examples/](examples/) directory for complete working examples:
236
+
237
+ - `examples/openai/` - OpenAI adapter examples
238
+ - `examples/anthropic/` - Anthropic adapter examples
239
+ - `examples/langchain/` - LangChain integration examples
240
+ - `examples/mcp/` - MCP server and client examples
241
+
242
+ ## Links
243
+
244
+ - **GitHub**: [github.com/macawsecurity/secureAI](https://github.com/macawsecurity/secureAI)
245
+ - **Documentation**: [docs.macawsecurity.ai](https://docs.macawsecurity.ai)
246
+ - **Console**: [console.macawsecurity.ai](https://console.macawsecurity.ai)
247
+ - **Support**: help@macawsecurity.com
248
+
249
+ ## License
250
+
251
+ Apache 2.0 - See [LICENSE](LICENSE) for details.
@@ -0,0 +1,200 @@
1
+ # MACAW Secure AI Adapters
2
+
3
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
4
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://python.org)
5
+ [![Version](https://img.shields.io/badge/version-0.5.22-green.svg)](https://github.com/macawsecurity/secureAI)
6
+
7
+ **Drop-in replacements for OpenAI, Anthropic, LangChain, and MCP for deterministic policy-based security controls for enterprise apps.**
8
+
9
+ ## What This Is
10
+
11
+ Open source interfaces that add MACAW transparently to popular LLM and Agentic frameworks.
12
+
13
+ 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.
14
+
15
+ These adapters are thin wrappers that route requests through the MACAW security layer. Change one import line and get:
16
+
17
+ - **Deterministic policy enforcement** - Control models, tokens, operations, data access, and actions performed
18
+ - **Identity propagation** - User identity flows through every LLM call for per-user policies
19
+ - **Cryptographic audit trail** - Complete record of all AI operations with signatures
20
+ - **Zero code changes** - Your existing code works unchanged
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ # Install with specific adapter
26
+ pip install macaw-adapters[openai]
27
+ pip install macaw-adapters[anthropic]
28
+ pip install macaw-adapters[langchain]
29
+ pip install macaw-adapters[mcp]
30
+
31
+ # Install all adapters
32
+ pip install macaw-adapters[all]
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ### SecureOpenAI
38
+
39
+ ```python
40
+ # Before
41
+ from openai import OpenAI
42
+ client = OpenAI()
43
+
44
+ # After - just change the import
45
+ from macaw_adapters.openai import SecureOpenAI
46
+ client = SecureOpenAI(app_name="my-app")
47
+
48
+ # Same API, now with MACAW security
49
+ response = client.chat.completions.create(
50
+ model="gpt-4",
51
+ messages=[{"role": "user", "content": "Hello!"}]
52
+ )
53
+ ```
54
+
55
+ ### SecureAnthropic
56
+
57
+ ```python
58
+ # Before
59
+ from anthropic import Anthropic
60
+ client = Anthropic()
61
+
62
+ # After
63
+ from macaw_adapters.anthropic import SecureAnthropic
64
+ client = SecureAnthropic(app_name="my-app")
65
+
66
+ # Same API
67
+ response = client.messages.create(
68
+ model="claude-3-haiku-20240307",
69
+ max_tokens=100,
70
+ messages=[{"role": "user", "content": "Hello!"}]
71
+ )
72
+ ```
73
+
74
+ ### SecureMCP
75
+
76
+ ```python
77
+ from macaw_adapters.mcp import SecureMCP
78
+
79
+ mcp = SecureMCP("calculator")
80
+
81
+ @mcp.tool(description="Add two numbers")
82
+ def add(a: float, b: float) -> float:
83
+ return a + b
84
+
85
+ mcp.run()
86
+ ```
87
+
88
+ ### LangChain
89
+
90
+ ```python
91
+ # Before
92
+ from langchain_openai import ChatOpenAI
93
+
94
+ # After
95
+ from macaw_adapters.langchain import ChatOpenAI
96
+
97
+ # Same API
98
+ llm = ChatOpenAI(model="gpt-4")
99
+ response = llm.invoke("Hello!")
100
+ ```
101
+
102
+ ## Multi-User Support
103
+
104
+ For SaaS applications with per-user policies:
105
+
106
+ ```python
107
+ from macaw_adapters.openai import SecureOpenAI
108
+ from macaw_client import MACAWClient, RemoteIdentityProvider
109
+
110
+ # Create shared service
111
+ service = SecureOpenAI(app_name="my-saas")
112
+
113
+ # Authenticate user
114
+ jwt_token, _ = RemoteIdentityProvider().login("alice", "password")
115
+ user = MACAWClient(user_name="alice", iam_token=jwt_token, agent_type="user")
116
+ user.register()
117
+
118
+ # Bind user to service - their identity flows through
119
+ user_openai = service.bind_to_user(user)
120
+
121
+ # Policies evaluated against alice's permissions
122
+ response = user_openai.chat.completions.create(...)
123
+ ```
124
+
125
+ ## How It Works
126
+
127
+ ```
128
+ ┌─────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
129
+ │ Your App │────▶│ Secure Adapter │────▶│ LLM API │
130
+ │ │ │ (SecureOpenAI,etc) │ │ (OpenAI, Claude) │
131
+ └─────────────┘ └──────────┬──────────┘ └─────────────────────┘
132
+
133
+
134
+ ┌─────────────────────┐
135
+ │ MACAW Client │
136
+ │ Endpoint │
137
+ └──────────┬──────────┘
138
+
139
+
140
+ ┌─────────────────────┐
141
+ │ Trust Layer │
142
+ │ Control Plane │
143
+ │ ───────────────── │
144
+ │ • Policy Engine │
145
+ │ • Identity/Claims │
146
+ │ • Audit Trail │
147
+ └─────────────────────┘
148
+ ```
149
+
150
+ ## Key Features
151
+
152
+ | Feature | Description |
153
+ |---------|-------------|
154
+ | **Drop-in Replacement** | Change one import, keep all your code |
155
+ | **Per-User Policies** | Different users get different permissions |
156
+ | **Model Restrictions** | Control which models each user can access |
157
+ | **Token Limits** | Enforce max_tokens per user/role |
158
+ | **Streaming Support** | Full support for streaming responses |
159
+ | **Audit Logging** | Cryptographically signed audit trail |
160
+
161
+ ## Requirements
162
+
163
+ - **Python 3.9+**
164
+ - **macaw_client v0.5.22+** - The MACAW client library
165
+
166
+ ### Getting Started
167
+
168
+ 1. Sign up at [console.macawsecurity.ai](https://console.macawsecurity.ai)
169
+ 2. Download and install macaw_client
170
+ 3. Configure your workspace and policies
171
+ 4. Install macaw-adapters and start building
172
+
173
+ ## Adapters
174
+
175
+ | Adapter | Package | Wraps |
176
+ |---------|---------|-------|
177
+ | SecureOpenAI | `macaw_adapters.openai` | OpenAI Python SDK |
178
+ | SecureAnthropic | `macaw_adapters.anthropic` | Anthropic Python SDK |
179
+ | SecureMCP | `macaw_adapters.mcp` | Model Context Protocol |
180
+ | LangChain | `macaw_adapters.langchain` | LangChain (OpenAI, Anthropic, Agents) |
181
+
182
+ ## Examples
183
+
184
+ See the [examples/](examples/) directory for complete working examples:
185
+
186
+ - `examples/openai/` - OpenAI adapter examples
187
+ - `examples/anthropic/` - Anthropic adapter examples
188
+ - `examples/langchain/` - LangChain integration examples
189
+ - `examples/mcp/` - MCP server and client examples
190
+
191
+ ## Links
192
+
193
+ - **GitHub**: [github.com/macawsecurity/secureAI](https://github.com/macawsecurity/secureAI)
194
+ - **Documentation**: [docs.macawsecurity.ai](https://docs.macawsecurity.ai)
195
+ - **Console**: [console.macawsecurity.ai](https://console.macawsecurity.ai)
196
+ - **Support**: help@macawsecurity.com
197
+
198
+ ## License
199
+
200
+ Apache 2.0 - See [LICENSE](LICENSE) for details.
@@ -0,0 +1,35 @@
1
+ """
2
+ MACAW Adapters - Secure AI Adapters for Enterprise
3
+
4
+ Security adapters for popular AI frameworks including OpenAI, Anthropic,
5
+ LangChain, and MCP (Model Context Protocol).
6
+
7
+ Usage:
8
+ from macaw_adapters.openai import SecureOpenAI
9
+ from macaw_adapters.anthropic import SecureAnthropic
10
+ from macaw_adapters.langchain.agents import create_react_agent, AgentExecutor
11
+ from macaw_adapters.mcp import SecureMCP
12
+
13
+ Prerequisites:
14
+ - MACAW Client Library: Download from https://macawsecurity.ai
15
+ - Free Account: Create at https://console.macawsecurity.ai
16
+
17
+ For more information, visit: https://macawsecurity.ai
18
+ """
19
+
20
+ __version__ = "0.5.22"
21
+ __author__ = "MACAW Security"
22
+ __license__ = "Apache-2.0"
23
+
24
+ from macaw_adapters import openai
25
+ from macaw_adapters import anthropic
26
+ from macaw_adapters import langchain
27
+ from macaw_adapters import mcp
28
+
29
+ __all__ = [
30
+ "openai",
31
+ "anthropic",
32
+ "langchain",
33
+ "mcp",
34
+ "__version__",
35
+ ]