control-zero 0.2.0__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.
- control_zero-0.2.0/.gitignore +63 -0
- control_zero-0.2.0/LICENSE +17 -0
- control_zero-0.2.0/PKG-INFO +216 -0
- control_zero-0.2.0/README.md +167 -0
- control_zero-0.2.0/control_zero/__init__.py +31 -0
- control_zero-0.2.0/control_zero/client.py +584 -0
- control_zero-0.2.0/control_zero/integrations/crewai/__init__.py +53 -0
- control_zero-0.2.0/control_zero/integrations/crewai/agent.py +267 -0
- control_zero-0.2.0/control_zero/integrations/crewai/crew.py +381 -0
- control_zero-0.2.0/control_zero/integrations/crewai/task.py +291 -0
- control_zero-0.2.0/control_zero/integrations/crewai/tool.py +299 -0
- control_zero-0.2.0/control_zero/integrations/langchain/__init__.py +58 -0
- control_zero-0.2.0/control_zero/integrations/langchain/agent.py +311 -0
- control_zero-0.2.0/control_zero/integrations/langchain/callbacks.py +441 -0
- control_zero-0.2.0/control_zero/integrations/langchain/chain.py +319 -0
- control_zero-0.2.0/control_zero/integrations/langchain/graph.py +441 -0
- control_zero-0.2.0/control_zero/integrations/langchain/tool.py +271 -0
- control_zero-0.2.0/control_zero/llm/__init__.py +77 -0
- control_zero-0.2.0/control_zero/llm/anthropic/__init__.py +35 -0
- control_zero-0.2.0/control_zero/llm/anthropic/client.py +136 -0
- control_zero-0.2.0/control_zero/llm/anthropic/messages.py +375 -0
- control_zero-0.2.0/control_zero/llm/base.py +551 -0
- control_zero-0.2.0/control_zero/llm/cohere/__init__.py +32 -0
- control_zero-0.2.0/control_zero/llm/cohere/client.py +402 -0
- control_zero-0.2.0/control_zero/llm/gemini/__init__.py +34 -0
- control_zero-0.2.0/control_zero/llm/gemini/client.py +486 -0
- control_zero-0.2.0/control_zero/llm/groq/__init__.py +32 -0
- control_zero-0.2.0/control_zero/llm/groq/client.py +330 -0
- control_zero-0.2.0/control_zero/llm/mistral/__init__.py +32 -0
- control_zero-0.2.0/control_zero/llm/mistral/client.py +319 -0
- control_zero-0.2.0/control_zero/llm/ollama/__init__.py +31 -0
- control_zero-0.2.0/control_zero/llm/ollama/client.py +439 -0
- control_zero-0.2.0/control_zero/llm/openai/__init__.py +34 -0
- control_zero-0.2.0/control_zero/llm/openai/chat.py +331 -0
- control_zero-0.2.0/control_zero/llm/openai/client.py +182 -0
- control_zero-0.2.0/control_zero/logging/__init__.py +5 -0
- control_zero-0.2.0/control_zero/logging/async_logger.py +65 -0
- control_zero-0.2.0/control_zero/mcp/__init__.py +5 -0
- control_zero-0.2.0/control_zero/mcp/middleware.py +148 -0
- control_zero-0.2.0/control_zero/policy/__init__.py +5 -0
- control_zero-0.2.0/control_zero/policy/enforcer.py +99 -0
- control_zero-0.2.0/control_zero/secrets/__init__.py +5 -0
- control_zero-0.2.0/control_zero/secrets/manager.py +77 -0
- control_zero-0.2.0/control_zero/types.py +51 -0
- control_zero-0.2.0/examples/README.md +65 -0
- control_zero-0.2.0/examples/analytics_agent.py +211 -0
- control_zero-0.2.0/examples/database_agent.py +176 -0
- control_zero-0.2.0/examples/github_agent.py +232 -0
- control_zero-0.2.0/examples/guides/crewai_governance.py +49 -0
- control_zero-0.2.0/examples/guides/langchain_governance.py +51 -0
- control_zero-0.2.0/examples/guides/langgraph_governance.py +40 -0
- control_zero-0.2.0/examples/guides/mcp_middleware.py +80 -0
- control_zero-0.2.0/examples/guides/provider_anthropic_governance.py +31 -0
- control_zero-0.2.0/examples/guides/provider_deepseek_governance.py +33 -0
- control_zero-0.2.0/examples/guides/provider_gemini_governance.py +28 -0
- control_zero-0.2.0/examples/guides/provider_groq_governance.py +30 -0
- control_zero-0.2.0/examples/guides/provider_moonshot_governance.py +33 -0
- control_zero-0.2.0/examples/guides/provider_openai_governance.py +34 -0
- control_zero-0.2.0/examples/multi_tool_agent.py +315 -0
- control_zero-0.2.0/examples/slack_bot.py +143 -0
- control_zero-0.2.0/pyproject.toml +104 -0
- control_zero-0.2.0/tests/__init__.py +1 -0
- control_zero-0.2.0/tests/conftest.py +83 -0
- control_zero-0.2.0/tests/test_client.py +310 -0
- control_zero-0.2.0/tests/test_crewai_integration.py +545 -0
- control_zero-0.2.0/tests/test_langchain_integration.py +479 -0
- control_zero-0.2.0/tests/test_live_api.py +444 -0
- control_zero-0.2.0/tests/test_llm_wrappers.py +641 -0
- control_zero-0.2.0/tests/test_mcp_middleware.py +243 -0
- control_zero-0.2.0/tests/test_passthrough.py +41 -0
- control_zero-0.2.0/tests/test_policy.py +228 -0
- control_zero-0.2.0/tests/test_secrets.py +218 -0
- control_zero-0.2.0/tests/test_types.py +194 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.coverage
|
|
39
|
+
.coverage.*
|
|
40
|
+
.cache
|
|
41
|
+
nosetests.xml
|
|
42
|
+
coverage.xml
|
|
43
|
+
coverage_html/
|
|
44
|
+
*.cover
|
|
45
|
+
.hypothesis/
|
|
46
|
+
.pytest_cache/
|
|
47
|
+
|
|
48
|
+
# Environments
|
|
49
|
+
.env
|
|
50
|
+
.venv
|
|
51
|
+
env/
|
|
52
|
+
venv/
|
|
53
|
+
ENV/
|
|
54
|
+
|
|
55
|
+
# IDE
|
|
56
|
+
.idea/
|
|
57
|
+
.vscode/
|
|
58
|
+
*.swp
|
|
59
|
+
*.swo
|
|
60
|
+
|
|
61
|
+
# OS
|
|
62
|
+
.DS_Store
|
|
63
|
+
Thumbs.db
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2024 Control Zero
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: control-zero
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Enterprise MCP governance SDK - secrets, policies, and observability
|
|
5
|
+
Project-URL: Homepage, https://controlzero.dev
|
|
6
|
+
Project-URL: Documentation, https://docs.controlzero.dev
|
|
7
|
+
Author-email: Control Zero <hello@controlzero.dev>
|
|
8
|
+
License: Proprietary
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: governance,mcp,observability,policy,secrets
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Requires-Dist: cryptography>=41.0.0
|
|
20
|
+
Requires-Dist: httpx>=0.25.0
|
|
21
|
+
Requires-Dist: pydantic>=2.0.0
|
|
22
|
+
Provides-Extra: all
|
|
23
|
+
Requires-Dist: anthropic>=0.20.0; extra == 'all'
|
|
24
|
+
Requires-Dist: crewai>=0.30.0; extra == 'all'
|
|
25
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'all'
|
|
26
|
+
Requires-Dist: langchain>=0.1.0; extra == 'all'
|
|
27
|
+
Requires-Dist: langgraph>=0.0.20; extra == 'all'
|
|
28
|
+
Requires-Dist: mcp>=0.1.0; extra == 'all'
|
|
29
|
+
Requires-Dist: openai>=1.0.0; extra == 'all'
|
|
30
|
+
Provides-Extra: crewai
|
|
31
|
+
Requires-Dist: crewai>=0.30.0; extra == 'crewai'
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: anthropic>=0.20.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: openai>=1.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: respx>=0.20.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
42
|
+
Provides-Extra: langchain
|
|
43
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
|
|
44
|
+
Requires-Dist: langchain>=0.1.0; extra == 'langchain'
|
|
45
|
+
Requires-Dist: langgraph>=0.0.20; extra == 'langchain'
|
|
46
|
+
Provides-Extra: mcp
|
|
47
|
+
Requires-Dist: mcp>=0.1.0; extra == 'mcp'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# Control Zero Python SDK
|
|
51
|
+
|
|
52
|
+
Enterprise MCP governance - secrets, policies, and observability for AI agents.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install control-zero
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from control_zero import ControlZeroClient
|
|
64
|
+
|
|
65
|
+
# Initialize with your API key
|
|
66
|
+
client = ControlZeroClient(api_key="cz_live_xxx")
|
|
67
|
+
|
|
68
|
+
# This fetches config, secrets, and policies from Control Zero
|
|
69
|
+
client.initialize()
|
|
70
|
+
|
|
71
|
+
# Call MCP tools - secrets are injected automatically!
|
|
72
|
+
result = client.call_tool("github", "list_issues", {"repo": "acme/app"})
|
|
73
|
+
|
|
74
|
+
# Close when done (flushes logs)
|
|
75
|
+
client.close()
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Features
|
|
79
|
+
|
|
80
|
+
### Automatic Secret Injection
|
|
81
|
+
|
|
82
|
+
Secrets configured in the Control Zero dashboard are automatically:
|
|
83
|
+
1. Fetched encrypted from the server
|
|
84
|
+
2. Decrypted in memory
|
|
85
|
+
3. Injected into your MCP calls
|
|
86
|
+
4. Wiped from memory on session end
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# No need to manage secrets in your code!
|
|
90
|
+
# GitHub PAT is automatically injected
|
|
91
|
+
result = client.call_tool("github", "create_issue", {
|
|
92
|
+
"repo": "acme/app",
|
|
93
|
+
"title": "Bug report",
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Policy Enforcement
|
|
98
|
+
|
|
99
|
+
Policies defined in the dashboard are enforced locally:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from control_zero import PolicyDeniedError
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
result = client.call_tool("stripe", "create_charge", {...})
|
|
106
|
+
except PolicyDeniedError as e:
|
|
107
|
+
print(f"Denied: {e.decision.reason}")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Audit Logging
|
|
111
|
+
|
|
112
|
+
All tool calls are automatically logged for compliance:
|
|
113
|
+
|
|
114
|
+
- Timestamp, tool, method
|
|
115
|
+
- Latency and status
|
|
116
|
+
- Policy decisions
|
|
117
|
+
- Errors (without sensitive data)
|
|
118
|
+
|
|
119
|
+
Logs are batched and sent asynchronously to avoid impacting performance.
|
|
120
|
+
|
|
121
|
+
## Async Usage
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from control_zero import AsyncControlZeroClient
|
|
125
|
+
|
|
126
|
+
async with AsyncControlZeroClient(api_key="cz_live_xxx") as client:
|
|
127
|
+
result = await client.call_tool("github", "list_issues", {"repo": "acme/app"})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## MCP Client Wrapping
|
|
131
|
+
|
|
132
|
+
Wrap an existing MCP client:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from mcp import Client
|
|
136
|
+
from control_zero import ControlZeroClient, MCPMiddleware
|
|
137
|
+
|
|
138
|
+
# Initialize Control Zero
|
|
139
|
+
cz = ControlZeroClient(api_key="cz_live_xxx")
|
|
140
|
+
cz.initialize()
|
|
141
|
+
|
|
142
|
+
# Wrap your MCP client
|
|
143
|
+
mcp = Client()
|
|
144
|
+
wrapped = MCPMiddleware(cz).wrap(mcp)
|
|
145
|
+
|
|
146
|
+
# Use wrapped client - all calls go through Control Zero
|
|
147
|
+
result = await wrapped.call_tool("github", "list_issues")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Configuration
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
client = ControlZeroClient(
|
|
154
|
+
api_key="cz_live_xxx", # Required
|
|
155
|
+
agent_name="marketing-bot", # Optional, for logging
|
|
156
|
+
base_url="https://api.controlzero.dev", # Or self-hosted
|
|
157
|
+
)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## API Key Types
|
|
161
|
+
|
|
162
|
+
- `cz_live_*` - Production keys (real secrets, real logging)
|
|
163
|
+
- `cz_test_*` - Test keys (mock responses, test logging)
|
|
164
|
+
|
|
165
|
+
## Security
|
|
166
|
+
|
|
167
|
+
- Secrets are held in memory only, never written to disk
|
|
168
|
+
- Memory is securely wiped on session end
|
|
169
|
+
- All communication is encrypted (TLS)
|
|
170
|
+
- Policies are enforced locally for low latency
|
|
171
|
+
|
|
172
|
+
## Development
|
|
173
|
+
|
|
174
|
+
### Running Tests
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Install dev dependencies
|
|
178
|
+
pip install -e ".[dev]"
|
|
179
|
+
|
|
180
|
+
# Run all tests
|
|
181
|
+
python -m pytest tests/ -v
|
|
182
|
+
|
|
183
|
+
# Run with coverage
|
|
184
|
+
python -m pytest tests/ --cov=control_zero --cov-report=term-missing
|
|
185
|
+
|
|
186
|
+
# Run specific test files
|
|
187
|
+
python -m pytest tests/test_types.py -v
|
|
188
|
+
python -m pytest tests/test_policy.py -v
|
|
189
|
+
python -m pytest tests/test_secrets.py -v
|
|
190
|
+
python -m pytest tests/test_client.py -v
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Code Quality
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Format and lint
|
|
197
|
+
ruff check --fix .
|
|
198
|
+
ruff format .
|
|
199
|
+
|
|
200
|
+
# Type checking
|
|
201
|
+
mypy control_zero/
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Examples
|
|
205
|
+
|
|
206
|
+
See the [examples/](./examples/) directory for complete usage examples:
|
|
207
|
+
|
|
208
|
+
- **slack_bot.py** - Secure Slack messaging with channel restrictions
|
|
209
|
+
- **database_agent.py** - PostgreSQL with read-only policies
|
|
210
|
+
- **analytics_agent.py** - ClickHouse queries with governance
|
|
211
|
+
- **github_agent.py** - GitHub operations with branch protection
|
|
212
|
+
- **multi_tool_agent.py** - Complete multi-tool workflow
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
Proprietary - Control Zero, Inc.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Control Zero Python SDK
|
|
2
|
+
|
|
3
|
+
Enterprise MCP governance - secrets, policies, and observability for AI agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install control-zero
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from control_zero import ControlZeroClient
|
|
15
|
+
|
|
16
|
+
# Initialize with your API key
|
|
17
|
+
client = ControlZeroClient(api_key="cz_live_xxx")
|
|
18
|
+
|
|
19
|
+
# This fetches config, secrets, and policies from Control Zero
|
|
20
|
+
client.initialize()
|
|
21
|
+
|
|
22
|
+
# Call MCP tools - secrets are injected automatically!
|
|
23
|
+
result = client.call_tool("github", "list_issues", {"repo": "acme/app"})
|
|
24
|
+
|
|
25
|
+
# Close when done (flushes logs)
|
|
26
|
+
client.close()
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
### Automatic Secret Injection
|
|
32
|
+
|
|
33
|
+
Secrets configured in the Control Zero dashboard are automatically:
|
|
34
|
+
1. Fetched encrypted from the server
|
|
35
|
+
2. Decrypted in memory
|
|
36
|
+
3. Injected into your MCP calls
|
|
37
|
+
4. Wiped from memory on session end
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
# No need to manage secrets in your code!
|
|
41
|
+
# GitHub PAT is automatically injected
|
|
42
|
+
result = client.call_tool("github", "create_issue", {
|
|
43
|
+
"repo": "acme/app",
|
|
44
|
+
"title": "Bug report",
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Policy Enforcement
|
|
49
|
+
|
|
50
|
+
Policies defined in the dashboard are enforced locally:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from control_zero import PolicyDeniedError
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
result = client.call_tool("stripe", "create_charge", {...})
|
|
57
|
+
except PolicyDeniedError as e:
|
|
58
|
+
print(f"Denied: {e.decision.reason}")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Audit Logging
|
|
62
|
+
|
|
63
|
+
All tool calls are automatically logged for compliance:
|
|
64
|
+
|
|
65
|
+
- Timestamp, tool, method
|
|
66
|
+
- Latency and status
|
|
67
|
+
- Policy decisions
|
|
68
|
+
- Errors (without sensitive data)
|
|
69
|
+
|
|
70
|
+
Logs are batched and sent asynchronously to avoid impacting performance.
|
|
71
|
+
|
|
72
|
+
## Async Usage
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from control_zero import AsyncControlZeroClient
|
|
76
|
+
|
|
77
|
+
async with AsyncControlZeroClient(api_key="cz_live_xxx") as client:
|
|
78
|
+
result = await client.call_tool("github", "list_issues", {"repo": "acme/app"})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## MCP Client Wrapping
|
|
82
|
+
|
|
83
|
+
Wrap an existing MCP client:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from mcp import Client
|
|
87
|
+
from control_zero import ControlZeroClient, MCPMiddleware
|
|
88
|
+
|
|
89
|
+
# Initialize Control Zero
|
|
90
|
+
cz = ControlZeroClient(api_key="cz_live_xxx")
|
|
91
|
+
cz.initialize()
|
|
92
|
+
|
|
93
|
+
# Wrap your MCP client
|
|
94
|
+
mcp = Client()
|
|
95
|
+
wrapped = MCPMiddleware(cz).wrap(mcp)
|
|
96
|
+
|
|
97
|
+
# Use wrapped client - all calls go through Control Zero
|
|
98
|
+
result = await wrapped.call_tool("github", "list_issues")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Configuration
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
client = ControlZeroClient(
|
|
105
|
+
api_key="cz_live_xxx", # Required
|
|
106
|
+
agent_name="marketing-bot", # Optional, for logging
|
|
107
|
+
base_url="https://api.controlzero.dev", # Or self-hosted
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API Key Types
|
|
112
|
+
|
|
113
|
+
- `cz_live_*` - Production keys (real secrets, real logging)
|
|
114
|
+
- `cz_test_*` - Test keys (mock responses, test logging)
|
|
115
|
+
|
|
116
|
+
## Security
|
|
117
|
+
|
|
118
|
+
- Secrets are held in memory only, never written to disk
|
|
119
|
+
- Memory is securely wiped on session end
|
|
120
|
+
- All communication is encrypted (TLS)
|
|
121
|
+
- Policies are enforced locally for low latency
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
### Running Tests
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Install dev dependencies
|
|
129
|
+
pip install -e ".[dev]"
|
|
130
|
+
|
|
131
|
+
# Run all tests
|
|
132
|
+
python -m pytest tests/ -v
|
|
133
|
+
|
|
134
|
+
# Run with coverage
|
|
135
|
+
python -m pytest tests/ --cov=control_zero --cov-report=term-missing
|
|
136
|
+
|
|
137
|
+
# Run specific test files
|
|
138
|
+
python -m pytest tests/test_types.py -v
|
|
139
|
+
python -m pytest tests/test_policy.py -v
|
|
140
|
+
python -m pytest tests/test_secrets.py -v
|
|
141
|
+
python -m pytest tests/test_client.py -v
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Code Quality
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Format and lint
|
|
148
|
+
ruff check --fix .
|
|
149
|
+
ruff format .
|
|
150
|
+
|
|
151
|
+
# Type checking
|
|
152
|
+
mypy control_zero/
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Examples
|
|
156
|
+
|
|
157
|
+
See the [examples/](./examples/) directory for complete usage examples:
|
|
158
|
+
|
|
159
|
+
- **slack_bot.py** - Secure Slack messaging with channel restrictions
|
|
160
|
+
- **database_agent.py** - PostgreSQL with read-only policies
|
|
161
|
+
- **analytics_agent.py** - ClickHouse queries with governance
|
|
162
|
+
- **github_agent.py** - GitHub operations with branch protection
|
|
163
|
+
- **multi_tool_agent.py** - Complete multi-tool workflow
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
Proprietary - Control Zero, Inc.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Control Zero - Enterprise MCP Governance SDK
|
|
3
|
+
|
|
4
|
+
The "magic" SDK that handles authentication, secret injection, policy enforcement,
|
|
5
|
+
and observability for MCP tool calls.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
from control_zero import ControlZeroClient
|
|
9
|
+
|
|
10
|
+
# Initialize with your API key
|
|
11
|
+
client = ControlZeroClient(api_key="cz_live_xxx")
|
|
12
|
+
|
|
13
|
+
# Call MCP tools - secrets are injected automatically
|
|
14
|
+
result = await client.call_tool("github", "list_issues", {"repo": "acme/app"})
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from control_zero.client import ControlZeroClient, AsyncControlZeroClient
|
|
18
|
+
from control_zero.mcp import MCPMiddleware
|
|
19
|
+
from control_zero.policy import PolicyDecision, PolicyDeniedError
|
|
20
|
+
from control_zero.types import ToolConfig, SessionConfig
|
|
21
|
+
|
|
22
|
+
__version__ = "0.1.0"
|
|
23
|
+
__all__ = [
|
|
24
|
+
"ControlZeroClient",
|
|
25
|
+
"AsyncControlZeroClient",
|
|
26
|
+
"MCPMiddleware",
|
|
27
|
+
"PolicyDecision",
|
|
28
|
+
"PolicyDeniedError",
|
|
29
|
+
"ToolConfig",
|
|
30
|
+
"SessionConfig",
|
|
31
|
+
]
|