maigp-mcp 1.1.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.
- maigp_mcp-1.1.0/.gitignore +56 -0
- maigp_mcp-1.1.0/PKG-INFO +76 -0
- maigp_mcp-1.1.0/README.md +61 -0
- maigp_mcp-1.1.0/SPEC.md +340 -0
- maigp_mcp-1.1.0/aigp_mcp/__init__.py +81 -0
- maigp_mcp-1.1.0/maigp_mcp/__init__.py +33 -0
- maigp_mcp-1.1.0/maigp_mcp/client.py +222 -0
- maigp_mcp-1.1.0/maigp_mcp/config.py +59 -0
- maigp_mcp-1.1.0/maigp_mcp/evidence.py +267 -0
- maigp_mcp-1.1.0/maigp_mcp/models.py +66 -0
- maigp_mcp-1.1.0/maigp_mcp/scope.py +46 -0
- maigp_mcp-1.1.0/pyproject.toml +20 -0
- maigp_mcp-1.1.0/tests/__init__.py +0 -0
- maigp_mcp-1.1.0/tests/test_deprecated_import_name.py +94 -0
- maigp_mcp-1.1.0/tests/test_scope.py +53 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.venv/
|
|
8
|
+
.eggs/
|
|
9
|
+
|
|
10
|
+
# Node
|
|
11
|
+
node_modules/
|
|
12
|
+
dist/
|
|
13
|
+
|
|
14
|
+
# Go
|
|
15
|
+
bin/
|
|
16
|
+
|
|
17
|
+
# Rust
|
|
18
|
+
target/
|
|
19
|
+
|
|
20
|
+
# .NET
|
|
21
|
+
bin/
|
|
22
|
+
obj/
|
|
23
|
+
|
|
24
|
+
# Java
|
|
25
|
+
*.class
|
|
26
|
+
out/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
.kiro/
|
|
32
|
+
*.swp
|
|
33
|
+
|
|
34
|
+
# OS
|
|
35
|
+
.DS_Store
|
|
36
|
+
Thumbs.db
|
|
37
|
+
|
|
38
|
+
# Secrets (never commit)
|
|
39
|
+
.env
|
|
40
|
+
*.pem
|
|
41
|
+
*.key
|
|
42
|
+
*.pdf
|
|
43
|
+
BACKLOG/
|
|
44
|
+
patent/
|
|
45
|
+
docs/.archive/
|
|
46
|
+
review/
|
|
47
|
+
|
|
48
|
+
# Generated navigable spec split — derived from the monoliths by
|
|
49
|
+
# specification/tools/spec_split.py; the manifest + monoliths are the
|
|
50
|
+
# source of truth, not this output. Same convention as Mars (spec/*/*/).
|
|
51
|
+
specification/*/*/
|
|
52
|
+
specification/split-index.md
|
|
53
|
+
|
|
54
|
+
# Local rendering/preview site — self-contained, not part of the
|
|
55
|
+
# published specification, never pushed.
|
|
56
|
+
site/
|
maigp_mcp-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: maigp-mcp
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: AIGP governance adapter for MCP tool invocations — policy, scope, consent, evidence
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Provides-Extra: all
|
|
7
|
+
Requires-Dist: boto3; extra == 'all'
|
|
8
|
+
Provides-Extra: aws
|
|
9
|
+
Requires-Dist: boto3; extra == 'aws'
|
|
10
|
+
Provides-Extra: dynamodb
|
|
11
|
+
Requires-Dist: boto3; extra == 'dynamodb'
|
|
12
|
+
Provides-Extra: s3
|
|
13
|
+
Requires-Dist: boto3; extra == 's3'
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# maigp-mcp
|
|
17
|
+
|
|
18
|
+
AIGP governance for MCP (Model Context Protocol) tool invocations.
|
|
19
|
+
|
|
20
|
+
Part of **MAIGP** — the Mediated AI Governance Protocol: a runtime consent / scope / evidence layer for AI systems. Every governed call is **CHECK**ed before it runs (policy, scope, jurisdiction, circuit-breaker) and **RECORD**ed + **TRACE**d as tamper-evident evidence after.
|
|
21
|
+
|
|
22
|
+
## What it governs
|
|
23
|
+
|
|
24
|
+
Governs MCP tool calls — policy, scope, consent, classification, and evidence.
|
|
25
|
+
|
|
26
|
+
## Governance model
|
|
27
|
+
|
|
28
|
+
This adapter maps the framework's lifecycle onto the AIGP agent-governance loop provided by [`maigp-agent-core`](https://pypi.org/project/maigp-agent-core/):
|
|
29
|
+
|
|
30
|
+
| Framework event | AIGP action |
|
|
31
|
+
|---|---|
|
|
32
|
+
| run / invocation start | **CHECK** (`pre_invoke`) — allowed? under what authority? |
|
|
33
|
+
| each model reply | token accounting (`on_model_call`) |
|
|
34
|
+
| each tool / function call | tool governance (`on_tool_call`) |
|
|
35
|
+
| run complete | **RECORD** + **TRACE** (`post_invoke`) |
|
|
36
|
+
| failure | `on_error` (recorded, then re-raised) |
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install maigp-mcp
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Pulls in [`maigp-agent-core`](https://pypi.org/project/maigp-agent-core/) (shared lifecycle) and, transitively, [`maigp-client`](https://pypi.org/project/maigp-client/).
|
|
46
|
+
|
|
47
|
+
## Quick start
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from maigp_mcp import GovernedMCPClient, MCPGovernanceConfig
|
|
51
|
+
|
|
52
|
+
config = MCPGovernanceConfig(
|
|
53
|
+
mode="ENFORCE",
|
|
54
|
+
gov_url="https://gov.example.com",
|
|
55
|
+
app_id="mcp-gateway",
|
|
56
|
+
hmac_secret="...",
|
|
57
|
+
)
|
|
58
|
+
governed = GovernedMCPClient(mcp_client, config)
|
|
59
|
+
|
|
60
|
+
# Pre-check → execute only if allowed → post-record evidence
|
|
61
|
+
result = await governed.call_tool("wiz", "listVulnerabilities",
|
|
62
|
+
{"severity": "HIGH"})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Modes & exports
|
|
66
|
+
|
|
67
|
+
`mode="ENFORCE"` blocks disallowed calls (raising `GovernanceDenied`); monitor-only modes record without blocking. Exports include `AccessDecision`, `GovernanceDenied`, and `ToolEvidence`.
|
|
68
|
+
|
|
69
|
+
## Links
|
|
70
|
+
|
|
71
|
+
- Protocol, specs & full adapter catalog: https://github.com/owner-spec/aigp-protocol
|
|
72
|
+
- Issues: https://github.com/owner-spec/aigp-protocol/issues
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
License: Proprietary. © Kanjani AI Research & Causum.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# maigp-mcp
|
|
2
|
+
|
|
3
|
+
AIGP governance for MCP (Model Context Protocol) tool invocations.
|
|
4
|
+
|
|
5
|
+
Part of **MAIGP** — the Mediated AI Governance Protocol: a runtime consent / scope / evidence layer for AI systems. Every governed call is **CHECK**ed before it runs (policy, scope, jurisdiction, circuit-breaker) and **RECORD**ed + **TRACE**d as tamper-evident evidence after.
|
|
6
|
+
|
|
7
|
+
## What it governs
|
|
8
|
+
|
|
9
|
+
Governs MCP tool calls — policy, scope, consent, classification, and evidence.
|
|
10
|
+
|
|
11
|
+
## Governance model
|
|
12
|
+
|
|
13
|
+
This adapter maps the framework's lifecycle onto the AIGP agent-governance loop provided by [`maigp-agent-core`](https://pypi.org/project/maigp-agent-core/):
|
|
14
|
+
|
|
15
|
+
| Framework event | AIGP action |
|
|
16
|
+
|---|---|
|
|
17
|
+
| run / invocation start | **CHECK** (`pre_invoke`) — allowed? under what authority? |
|
|
18
|
+
| each model reply | token accounting (`on_model_call`) |
|
|
19
|
+
| each tool / function call | tool governance (`on_tool_call`) |
|
|
20
|
+
| run complete | **RECORD** + **TRACE** (`post_invoke`) |
|
|
21
|
+
| failure | `on_error` (recorded, then re-raised) |
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install maigp-mcp
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Pulls in [`maigp-agent-core`](https://pypi.org/project/maigp-agent-core/) (shared lifecycle) and, transitively, [`maigp-client`](https://pypi.org/project/maigp-client/).
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from maigp_mcp import GovernedMCPClient, MCPGovernanceConfig
|
|
36
|
+
|
|
37
|
+
config = MCPGovernanceConfig(
|
|
38
|
+
mode="ENFORCE",
|
|
39
|
+
gov_url="https://gov.example.com",
|
|
40
|
+
app_id="mcp-gateway",
|
|
41
|
+
hmac_secret="...",
|
|
42
|
+
)
|
|
43
|
+
governed = GovernedMCPClient(mcp_client, config)
|
|
44
|
+
|
|
45
|
+
# Pre-check → execute only if allowed → post-record evidence
|
|
46
|
+
result = await governed.call_tool("wiz", "listVulnerabilities",
|
|
47
|
+
{"severity": "HIGH"})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Modes & exports
|
|
51
|
+
|
|
52
|
+
`mode="ENFORCE"` blocks disallowed calls (raising `GovernanceDenied`); monitor-only modes record without blocking. Exports include `AccessDecision`, `GovernanceDenied`, and `ToolEvidence`.
|
|
53
|
+
|
|
54
|
+
## Links
|
|
55
|
+
|
|
56
|
+
- Protocol, specs & full adapter catalog: https://github.com/owner-spec/aigp-protocol
|
|
57
|
+
- Issues: https://github.com/owner-spec/aigp-protocol/issues
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
License: Proprietary. © Kanjani AI Research & Causum.
|
maigp_mcp-1.1.0/SPEC.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# SPEC: maigp_mcp — AIGP Adapter for MCP Tool Governance
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-07-09
|
|
4
|
+
**Status:** Spec
|
|
5
|
+
**Location:** `aigp-protocol/sdks/python/adapters/mcp/`
|
|
6
|
+
**Purpose:** Govern MCP tool invocations with AIGP — policy enforcement, consent gating, evidence recording.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. What It Does
|
|
11
|
+
|
|
12
|
+
Wraps any MCP tool call with AIGP governance:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from maigp_mcp import GovernedMCPClient
|
|
16
|
+
|
|
17
|
+
# Without governance (current):
|
|
18
|
+
result = await mcp_client.call_tool("listVulnerabilities", {"severity": "HIGH"})
|
|
19
|
+
|
|
20
|
+
# With governance (maigp_mcp):
|
|
21
|
+
governed = GovernedMCPClient(mcp_client, aigp_config)
|
|
22
|
+
result = await governed.call_tool("wiz", "listVulnerabilities", {"severity": "HIGH"})
|
|
23
|
+
# → PRE: checks policy (is this agent allowed to call wiz tools?)
|
|
24
|
+
# → PRE: checks consent (does TIER_2 consent exist for this data?)
|
|
25
|
+
# → PRE: checks scope (is read:vulnerabilities in the allowed scope?)
|
|
26
|
+
# → EXECUTE: calls the MCP tool
|
|
27
|
+
# → POST: records AIGP evidence (who, what, when, under what authority)
|
|
28
|
+
# → POST: hashes input/output for tamper detection
|
|
29
|
+
# → RETURNS: result (or GovernanceDenied exception)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 2. Architecture
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Agent
|
|
38
|
+
│
|
|
39
|
+
▼
|
|
40
|
+
maigp_mcp.GovernedMCPClient
|
|
41
|
+
│
|
|
42
|
+
├── PRE-CHECK ──────────────────────────┐
|
|
43
|
+
│ • Policy evaluation (GOV_APP) │
|
|
44
|
+
│ • Scope enforcement (allowed tools) │ ← AIGP governance
|
|
45
|
+
│ • Consent verification (tier check) │
|
|
46
|
+
│ • Data classification match │
|
|
47
|
+
├───────────────────────────────────────┘
|
|
48
|
+
│
|
|
49
|
+
├── EXECUTE ────────────────────────────┐
|
|
50
|
+
│ • MCP Helper call_tool() │ ← Actual tool invocation
|
|
51
|
+
├───────────────────────────────────────┘
|
|
52
|
+
│
|
|
53
|
+
├── POST-RECORD ────────────────────────┐
|
|
54
|
+
│ • Evidence record (trace store) │
|
|
55
|
+
│ • Input/output hash │ ← AIGP evidence
|
|
56
|
+
│ • Duration, status, errors │
|
|
57
|
+
│ • Evidence chain linkage │
|
|
58
|
+
├───────────────────────────────────────┘
|
|
59
|
+
│
|
|
60
|
+
▼
|
|
61
|
+
Result (or GovernanceDenied)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 3. Module Structure
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
aigp-protocol/sdks/python/adapters/mcp/
|
|
70
|
+
├── pyproject.toml
|
|
71
|
+
├── maigp_mcp/
|
|
72
|
+
│ ├── __init__.py # Exports: GovernedMCPClient, MCPGovernanceConfig
|
|
73
|
+
│ ├── client.py # GovernedMCPClient — wraps MCP calls
|
|
74
|
+
│ ├── policy.py # Policy evaluation (calls GOV_APP or local rules)
|
|
75
|
+
│ ├── consent.py # Consent tier verification
|
|
76
|
+
│ ├── scope.py # Scope enforcement (which tools are allowed)
|
|
77
|
+
│ ├── evidence.py # AIGP evidence recording
|
|
78
|
+
│ ├── models.py # Pydantic models (ToolInvocation, Evidence, Decision)
|
|
79
|
+
│ └── config.py # MCPGovernanceConfig
|
|
80
|
+
└── tests/
|
|
81
|
+
├── test_client.py
|
|
82
|
+
├── test_policy.py
|
|
83
|
+
└── test_evidence.py
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 4. Core API
|
|
89
|
+
|
|
90
|
+
### 4.1 GovernedMCPClient
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
class GovernedMCPClient:
|
|
94
|
+
"""Wraps MCP tool calls with AIGP governance."""
|
|
95
|
+
|
|
96
|
+
def __init__(
|
|
97
|
+
self,
|
|
98
|
+
mcp_client, # The actual MCP client/helper
|
|
99
|
+
config: MCPGovernanceConfig, # Governance configuration
|
|
100
|
+
):
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
async def call_tool(
|
|
104
|
+
self,
|
|
105
|
+
server_id: str, # Which MCP server (e.g. "wiz")
|
|
106
|
+
tool_name: str, # Which tool (e.g. "listVulnerabilities")
|
|
107
|
+
arguments: dict, # Tool arguments
|
|
108
|
+
*,
|
|
109
|
+
agent_id: str = "", # Calling agent identity
|
|
110
|
+
session_id: str = "", # AIGP session ID (for chaining)
|
|
111
|
+
consent_reference: str = "", # Consent record ID (if pre-obtained)
|
|
112
|
+
) -> ToolResult:
|
|
113
|
+
"""Call an MCP tool with full AIGP governance."""
|
|
114
|
+
...
|
|
115
|
+
|
|
116
|
+
async def list_tools(
|
|
117
|
+
self,
|
|
118
|
+
agent_id: str = "",
|
|
119
|
+
classification: str = "",
|
|
120
|
+
) -> list[GovernedTool]:
|
|
121
|
+
"""List available tools filtered by agent's permissions."""
|
|
122
|
+
...
|
|
123
|
+
|
|
124
|
+
async def check_access(
|
|
125
|
+
self,
|
|
126
|
+
server_id: str,
|
|
127
|
+
tool_name: str,
|
|
128
|
+
agent_id: str,
|
|
129
|
+
) -> AccessDecision:
|
|
130
|
+
"""Pre-check if an agent can call a specific tool (without calling it)."""
|
|
131
|
+
...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 4.2 MCPGovernanceConfig
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
class MCPGovernanceConfig:
|
|
138
|
+
"""Configuration for MCP governance."""
|
|
139
|
+
|
|
140
|
+
# Governance mode
|
|
141
|
+
mode: str = "REPORT" # REPORT | ENFORCE | TRACE
|
|
142
|
+
|
|
143
|
+
# Policy source
|
|
144
|
+
gov_url: str = "" # GOV_APP URL for policy evaluation
|
|
145
|
+
local_policy: dict = {} # Or: inline policy rules (for offline)
|
|
146
|
+
|
|
147
|
+
# Evidence store
|
|
148
|
+
evidence_store: str = "s3" # s3 | dynamodb | local
|
|
149
|
+
evidence_bucket: str = "" # S3 bucket for evidence
|
|
150
|
+
|
|
151
|
+
# Scope rules (which agents can use which servers/tools)
|
|
152
|
+
scope_rules: dict = {}
|
|
153
|
+
# Example:
|
|
154
|
+
# {
|
|
155
|
+
# "cpg_agent_v2": {"allowed_servers": ["wiz", "aws-security-agent"], "denied_tools": []},
|
|
156
|
+
# "graph_query_agent": {"allowed_servers": ["aws-documentation", "oscal"], "denied_tools": ["*__delete*"]},
|
|
157
|
+
# "*": {"allowed_servers": ["aws-documentation"], "denied_tools": ["*__write*", "*__delete*"]}
|
|
158
|
+
# }
|
|
159
|
+
|
|
160
|
+
# Classification requirements
|
|
161
|
+
classification_rules: dict = {}
|
|
162
|
+
# Example:
|
|
163
|
+
# {
|
|
164
|
+
# "wiz": "HIGH",
|
|
165
|
+
# "aws-documentation": "LOW",
|
|
166
|
+
# "servicenow": "HIGH",
|
|
167
|
+
# }
|
|
168
|
+
|
|
169
|
+
# Consent tiers
|
|
170
|
+
consent_tiers: dict = {}
|
|
171
|
+
# Example:
|
|
172
|
+
# {
|
|
173
|
+
# "HIGH": "TIER_2", # HIGH-classified tools need TIER_2 consent
|
|
174
|
+
# "MEDIUM": "TIER_1", # MEDIUM needs TIER_1
|
|
175
|
+
# "LOW": "NONE", # LOW needs no consent
|
|
176
|
+
# }
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 5. Governance Modes
|
|
182
|
+
|
|
183
|
+
| Mode | PRE-CHECK | EXECUTE | POST-RECORD | On Denial |
|
|
184
|
+
|---|---|---|---|---|
|
|
185
|
+
| **TRACE** | Log only (no block) | Always execute | Always record | Log warning, proceed |
|
|
186
|
+
| **REPORT** | Evaluate + log | Always execute | Always record | Log violation, proceed |
|
|
187
|
+
| **ENFORCE** | Evaluate + block | Only if allowed | Always record | Raise GovernanceDenied |
|
|
188
|
+
|
|
189
|
+
Start with REPORT for visibility, move to ENFORCE once policies are tuned.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 6. Evidence Record
|
|
194
|
+
|
|
195
|
+
Every governed tool call produces an evidence record:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"evidence_type": "MCP_TOOL_INVOCATION",
|
|
200
|
+
"evidence_id": "EVD-MCP-20260709-150000-001",
|
|
201
|
+
"timestamp": "2026-07-09T15:00:00Z",
|
|
202
|
+
|
|
203
|
+
"identity": {
|
|
204
|
+
"agent_id": "cpg_agent_v2",
|
|
205
|
+
"session_id": "sess-abc123",
|
|
206
|
+
"delegation_chain": ["user:admin@org.com", "agent:cpg_agent_v2"]
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
"action": {
|
|
210
|
+
"server_id": "wiz",
|
|
211
|
+
"tool_name": "listVulnerabilities",
|
|
212
|
+
"arguments_hash": "sha256:abc...",
|
|
213
|
+
"result_hash": "sha256:def...",
|
|
214
|
+
"status": "SUCCESS",
|
|
215
|
+
"duration_ms": 342
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
"governance": {
|
|
219
|
+
"mode": "ENFORCE",
|
|
220
|
+
"policy_id": "POL-MCP-001",
|
|
221
|
+
"decision": "ALLOW",
|
|
222
|
+
"scope_check": "PASSED",
|
|
223
|
+
"classification": "HIGH",
|
|
224
|
+
"consent_tier": "TIER_2",
|
|
225
|
+
"consent_reference": "CONSENT-2026-001",
|
|
226
|
+
"data_residency": "us-east-1"
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
"provenance": {
|
|
230
|
+
"aigp_version": "5.1.0",
|
|
231
|
+
"adapter": "maigp_mcp",
|
|
232
|
+
"evidence_chain_id": "CHAIN-MCP-WIZ-001",
|
|
233
|
+
"parent_evidence_id": "EVD-AGENT-20260709-145959-001"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## 7. Scope Enforcement Examples
|
|
241
|
+
|
|
242
|
+
### Allow: CPG agent calling Wiz for vulnerability scan
|
|
243
|
+
```
|
|
244
|
+
Agent: cpg_agent_v2
|
|
245
|
+
Server: wiz
|
|
246
|
+
Tool: listVulnerabilities
|
|
247
|
+
Rule: cpg_agent_v2 → allowed_servers: ["wiz"]
|
|
248
|
+
Decision: ALLOW
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Deny: Query agent trying to write to ServiceNow
|
|
252
|
+
```
|
|
253
|
+
Agent: graph_query_agent
|
|
254
|
+
Server: servicenow
|
|
255
|
+
Tool: createIncident
|
|
256
|
+
Rule: graph_query_agent → denied_tools: ["*__create*", "*__write*", "*__delete*"]
|
|
257
|
+
Decision: DENY (scope violation: write operation not permitted for read-only agent)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Deny: Unregistered agent calling HIGH tool
|
|
261
|
+
```
|
|
262
|
+
Agent: unknown_agent
|
|
263
|
+
Server: wiz
|
|
264
|
+
Tool: deleteAsset
|
|
265
|
+
Rule: * → denied_tools: ["*__delete*"]
|
|
266
|
+
Decision: DENY (destructive operation blocked by default policy)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 8. Integration with Managed/Unmanaged MCP
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
# Unmanaged MCP (current — no governance):
|
|
275
|
+
result = await mcp_helper.call_tool("wiz", "listVulnerabilities", args)
|
|
276
|
+
|
|
277
|
+
# Managed MCP (with maigp_mcp):
|
|
278
|
+
governed = GovernedMCPClient(mcp_helper, config)
|
|
279
|
+
result = await governed.call_tool("wiz", "listVulnerabilities", args, agent_id="cpg_agent")
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The `GovernedMCPClient` is a **drop-in wrapper**. Existing code continues to work — you just wrap the client. No changes to MCP Helper internals.
|
|
283
|
+
|
|
284
|
+
For the AgentCore bridge, the wrapper sits at the bridge layer:
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
Agent → AgentCore → MCP Bridge → maigp_mcp (governance) → MCP Helper → MCP Server
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 9. Package Definition
|
|
293
|
+
|
|
294
|
+
```toml
|
|
295
|
+
# pyproject.toml
|
|
296
|
+
[project]
|
|
297
|
+
name = "maigp-mcp"
|
|
298
|
+
version = "1.0.0"
|
|
299
|
+
description = "AIGP adapter for governed MCP tool invocations"
|
|
300
|
+
requires-python = ">=3.10"
|
|
301
|
+
dependencies = [
|
|
302
|
+
"maigp-client>=5.0.0",
|
|
303
|
+
"pydantic>=2.0",
|
|
304
|
+
"httpx>=0.24",
|
|
305
|
+
]
|
|
306
|
+
|
|
307
|
+
[project.optional-dependencies]
|
|
308
|
+
s3 = ["boto3"]
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 10. Implementation Estimate
|
|
314
|
+
|
|
315
|
+
| Task | Effort |
|
|
316
|
+
|---|---|
|
|
317
|
+
| `client.py` (GovernedMCPClient) | 1 day |
|
|
318
|
+
| `policy.py` (GOV_APP integration + local rules) | 1 day |
|
|
319
|
+
| `scope.py` (agent → server/tool permission matrix) | 0.5 day |
|
|
320
|
+
| `consent.py` (tier verification) | 0.5 day |
|
|
321
|
+
| `evidence.py` (S3/DynamoDB evidence writer) | 1 day |
|
|
322
|
+
| `config.py` + `models.py` | 0.5 day |
|
|
323
|
+
| Tests | 1 day |
|
|
324
|
+
| Integration with MCP Helper bridge | 1 day |
|
|
325
|
+
|
|
326
|
+
**Total: ~6.5 days**
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 11. Relationship to Other Adapters
|
|
331
|
+
|
|
332
|
+
| Adapter | What It Governs | Where It Sits |
|
|
333
|
+
|---|---|---|
|
|
334
|
+
| `maigp_strands` | Strands agent actions | Inside agent code |
|
|
335
|
+
| `maigp_langchain` | LangChain tool calls | Inside agent code |
|
|
336
|
+
| `maigp_agentcore` | AgentCore invocations | AgentCore middleware |
|
|
337
|
+
| **`maigp_mcp`** | **MCP tool calls** | **MCP Helper bridge** |
|
|
338
|
+
| `aigp_a2a` *(also missing)* | Agent-to-agent delegation | AgentCore routing |
|
|
339
|
+
|
|
340
|
+
`maigp_mcp` is the **tool-layer governance** — it doesn't care about which framework called it. Whether a Strands agent, LangChain agent, or direct API call invokes an MCP tool, `maigp_mcp` governs it at the MCP Helper level.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Deprecated import name: the package is now ``maigp_mcp`` (PyPI: ``maigp-mcp``).
|
|
2
|
+
|
|
3
|
+
``import aigp_mcp`` and ``from aigp_mcp.<module> import ...`` keep working during the deprecation period.
|
|
4
|
+
Every name and every submodule here is the *same object* as in ``maigp_mcp`` (submodules are registered in
|
|
5
|
+
``sys.modules`` under the old name), so ``isinstance`` checks and module state are shared. The old
|
|
6
|
+
import name is removed in the next major version of maigp-mcp. Change ``aigp_mcp`` to ``maigp_mcp`` in your imports.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import importlib
|
|
12
|
+
import importlib.abc
|
|
13
|
+
import importlib.util
|
|
14
|
+
import pkgutil
|
|
15
|
+
import sys
|
|
16
|
+
import warnings
|
|
17
|
+
|
|
18
|
+
warnings.warn(
|
|
19
|
+
"The 'aigp_mcp' import name is deprecated: the package is now 'maigp_mcp' (PyPI: maigp-mcp). "
|
|
20
|
+
"Replace 'aigp_mcp' with 'maigp_mcp' in your imports. 'aigp_mcp' is removed in the next major version of maigp-mcp.",
|
|
21
|
+
DeprecationWarning,
|
|
22
|
+
stacklevel=2,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
import maigp_mcp as _new # noqa: E402
|
|
26
|
+
|
|
27
|
+
_OLD = __name__
|
|
28
|
+
_NEW = _new.__name__
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class _AliasLoader(importlib.abc.Loader):
|
|
32
|
+
def __init__(self, module):
|
|
33
|
+
self._module = module
|
|
34
|
+
|
|
35
|
+
def create_module(self, spec):
|
|
36
|
+
return self._module
|
|
37
|
+
|
|
38
|
+
def exec_module(self, module):
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class _AliasFinder(importlib.abc.MetaPathFinder):
|
|
43
|
+
"""Resolve ``aigp_mcp.<anything>`` to the matching ``maigp_mcp.<anything>`` module (same object)."""
|
|
44
|
+
|
|
45
|
+
def find_spec(self, fullname, path=None, target=None):
|
|
46
|
+
if not fullname.startswith(_OLD + "."):
|
|
47
|
+
return None
|
|
48
|
+
try:
|
|
49
|
+
module = importlib.import_module(_NEW + fullname[len(_OLD):])
|
|
50
|
+
except ImportError:
|
|
51
|
+
return None
|
|
52
|
+
return importlib.util.spec_from_loader(fullname, _AliasLoader(module), is_package=hasattr(module, "__path__"))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if not any(isinstance(f, _AliasFinder) for f in sys.meta_path):
|
|
56
|
+
sys.meta_path.insert(0, _AliasFinder())
|
|
57
|
+
|
|
58
|
+
_SUBMODULES = []
|
|
59
|
+
for _info in pkgutil.walk_packages(_new.__path__, _NEW + "."):
|
|
60
|
+
try:
|
|
61
|
+
_module = importlib.import_module(_info.name)
|
|
62
|
+
except ImportError: # optional dependency missing: still resolvable lazily by _AliasFinder
|
|
63
|
+
continue
|
|
64
|
+
_alias = _OLD + _info.name[len(_NEW):]
|
|
65
|
+
sys.modules[_alias] = _module
|
|
66
|
+
_SUBMODULES.append(_alias[len(_OLD) + 1:])
|
|
67
|
+
if "." not in _alias[len(_OLD) + 1:]:
|
|
68
|
+
globals()[_alias[len(_OLD) + 1:]] = _module
|
|
69
|
+
|
|
70
|
+
from maigp_mcp import * # noqa: E402,F401,F403
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def __getattr__(name):
|
|
74
|
+
# Private names, __version__ and deprecated class aliases resolve on the new package.
|
|
75
|
+
try:
|
|
76
|
+
return getattr(_new, name)
|
|
77
|
+
except AttributeError:
|
|
78
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
__all__ = list(getattr(_new, "__all__", ())) + [s for s in _SUBMODULES if "." not in s]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""AIGP-MCP — Governance adapter for MCP tool invocations.
|
|
2
|
+
|
|
3
|
+
Wraps MCP tool calls with AIGP governance:
|
|
4
|
+
- Pre-check: policy, scope, consent, classification
|
|
5
|
+
- Execute: only if allowed (ENFORCE mode)
|
|
6
|
+
- Post-record: evidence (who, what, when, under what authority)
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
from maigp_mcp import GovernedMCPClient, MCPGovernanceConfig
|
|
10
|
+
|
|
11
|
+
config = MCPGovernanceConfig(
|
|
12
|
+
mode="ENFORCE",
|
|
13
|
+
gov_url="https://www.cyber-ai-gov.com",
|
|
14
|
+
app_id="mcp-gateway",
|
|
15
|
+
hmac_secret="...",
|
|
16
|
+
)
|
|
17
|
+
governed = GovernedMCPClient(mcp_client, config)
|
|
18
|
+
result = await governed.call_tool("wiz", "listVulnerabilities", {"severity": "HIGH"})
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
__version__ = "1.1.0"
|
|
22
|
+
|
|
23
|
+
from .client import GovernedMCPClient
|
|
24
|
+
from .config import MCPGovernanceConfig
|
|
25
|
+
from .models import AccessDecision, GovernanceDenied, ToolEvidence
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"GovernedMCPClient",
|
|
29
|
+
"MCPGovernanceConfig",
|
|
30
|
+
"AccessDecision",
|
|
31
|
+
"GovernanceDenied",
|
|
32
|
+
"ToolEvidence",
|
|
33
|
+
]
|