|
| 1 | +# Governance for GitHub-Based Plugin Marketplaces |
| 2 | + |
| 3 | +⚠️ **IMPORTANT:** This is a SAMPLE integration example provided as a starting point. |
| 4 | +You MUST review, customize, and extend these configurations for your specific |
| 5 | +use case before deploying to production. |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +This example demonstrates how to integrate the Agent Governance Toolkit into a |
| 10 | +GitHub-based plugin marketplace. Plugins are contributed via pull requests, |
| 11 | +validated automatically in CI, and promoted through environments (dev → staging → |
| 12 | +production) only after passing governance checks. |
| 13 | + |
| 14 | +The pattern enforces: |
| 15 | + |
| 16 | +- **MCP server allowlists** — only approved servers may be referenced by plugins |
| 17 | +- **Plugin type restrictions** — control which plugin categories are accepted |
| 18 | +- **Signature requirements** — require Ed25519 signatures in production |
| 19 | +- **Tool safety rules** — block dangerous tools and enforce token budgets |
| 20 | +- **Batch evaluation** — scan all plugins on every PR for policy drift |
| 21 | + |
| 22 | +## Architecture |
| 23 | + |
| 24 | +``` |
| 25 | +┌──────────────────────────────────────────────────────────────┐ |
| 26 | +│ Plugin Marketplace (GitHub) │ |
| 27 | +│ │ |
| 28 | +│ contributor ──► Pull Request ──► CI Governance Pipeline │ |
| 29 | +│ │ |
| 30 | +│ ┌────────────────────────────────────────────────────────┐ │ |
| 31 | +│ │ PR Workflow │ │ |
| 32 | +│ │ │ │ |
| 33 | +│ │ ┌──────────────┐ ┌───────────────┐ ┌──────────┐ │ │ |
| 34 | +│ │ │ Validate │──►│ Evaluate │──►│ Verify │ │ │ |
| 35 | +│ │ │ Manifest │ │ Policy │ │ Governance│ │ │ |
| 36 | +│ │ └──────────────┘ └───────────────┘ └──────────┘ │ │ |
| 37 | +│ │ │ │ │ │ │ |
| 38 | +│ │ ▼ ▼ ▼ │ │ |
| 39 | +│ │ plugin.json marketplace- governance │ │ |
| 40 | +│ │ schema check policy.yaml attestation │ │ |
| 41 | +│ │ plugin-safety.yaml │ │ |
| 42 | +│ └────────────────────────────────────────────────────────┘ │ |
| 43 | +│ │ │ |
| 44 | +│ ┌─────────┴─────────┐ │ |
| 45 | +│ ▼ ▼ │ |
| 46 | +│ ✅ Compliant ❌ Non-compliant │ |
| 47 | +│ Merge + promote Block PR │ |
| 48 | +│ to environment with annotations │ |
| 49 | +└──────────────────────────────────────────────────────────────┘ |
| 50 | +``` |
| 51 | + |
| 52 | +## Directory Structure |
| 53 | + |
| 54 | +``` |
| 55 | +examples/marketplace-governance/ |
| 56 | +├── README.md # This file |
| 57 | +├── .github/ |
| 58 | +│ └── workflows/ |
| 59 | +│ └── plugin-governance.yml # CI workflow for PR validation |
| 60 | +├── policies/ |
| 61 | +│ ├── marketplace-policy.yaml # MCP allowlist and plugin controls |
| 62 | +│ └── plugin-safety.yaml # Tool restrictions and token budgets |
| 63 | +└── plugins/ |
| 64 | + ├── example-compliant/ |
| 65 | + │ └── plugin.json # Passes all governance checks |
| 66 | + └── example-non-compliant/ |
| 67 | + └── plugin.json # Uses a blocked MCP server |
| 68 | +``` |
| 69 | + |
| 70 | +## Step-by-Step Integration Guide |
| 71 | + |
| 72 | +### 1. Add Governance Policies to Your Repo |
| 73 | + |
| 74 | +Copy the policy files from `policies/` into your marketplace repository: |
| 75 | + |
| 76 | +```bash |
| 77 | +cp -r policies/ your-marketplace/policies/ |
| 78 | +``` |
| 79 | + |
| 80 | +The two policy files serve different purposes: |
| 81 | + |
| 82 | +| File | Purpose | |
| 83 | +|------|---------| |
| 84 | +| `marketplace-policy.yaml` | Controls which MCP servers, plugin types, and signing requirements are enforced | |
| 85 | +| `plugin-safety.yaml` | Agent-level safety rules — tool restrictions, file access auditing, token budgets | |
| 86 | + |
| 87 | +See the inline comments in each file for customization guidance. |
| 88 | + |
| 89 | +### 2. Add the GitHub Action to Your PR Workflow |
| 90 | + |
| 91 | +Copy `.github/workflows/plugin-governance.yml` into your repository. The workflow |
| 92 | +triggers on pull requests that modify files under `plugins/` and runs three jobs: |
| 93 | + |
| 94 | +1. **validate-manifest** — Checks that each changed plugin has a valid `plugin.json` |
| 95 | +2. **evaluate-policy** — Evaluates all plugins against `marketplace-policy.yaml` |
| 96 | +3. **governance-verify** — Runs the full governance attestation suite |
| 97 | + |
| 98 | +```yaml |
| 99 | +- uses: microsoft/agent-governance-toolkit/action@v2 |
| 100 | + with: |
| 101 | + command: marketplace-verify |
| 102 | + manifest-path: plugins/my-plugin/plugin.json |
| 103 | +``` |
| 104 | +
|
| 105 | +### 3. Configure Marketplace Policy |
| 106 | +
|
| 107 | +Edit `policies/marketplace-policy.yaml` to match your marketplace: |
| 108 | + |
| 109 | +- **MCP server allowlist** — Add the MCP servers your marketplace trusts |
| 110 | + (e.g., `code-search`, `ms-learn`, `playwright`). Any plugin referencing an |
| 111 | + unlisted server will be rejected. |
| 112 | +- **Plugin types** — Restrict to the types you accept (`integration`, `agent`, |
| 113 | + `policy_template`, `validator`). |
| 114 | +- **Signature requirements** — Set `require_signature: true` for production to |
| 115 | + enforce Ed25519 plugin signing. |
| 116 | + |
| 117 | +### 4. Configure Plugin Safety Policy |
| 118 | + |
| 119 | +Edit `policies/plugin-safety.yaml` to define agent-level safety rules: |
| 120 | + |
| 121 | +- **Tool restrictions** — Block dangerous tools like `shell_exec`, `eval`, and |
| 122 | + `file_delete` to prevent destructive actions. |
| 123 | +- **Audit rules** — Log sensitive operations (e.g., file access) without |
| 124 | + blocking them. |
| 125 | +- **Token budgets** — Cap the maximum tokens per tool call to prevent runaway |
| 126 | + costs. |
| 127 | + |
| 128 | +### 5. Add Pre-Commit Hooks for Local Feedback |
| 129 | + |
| 130 | +Give plugin contributors fast local feedback before they push: |
| 131 | + |
| 132 | +```bash |
| 133 | +# Install the toolkit |
| 134 | +pip install agent-governance-toolkit[full] |
| 135 | +
|
| 136 | +# Validate a single manifest |
| 137 | +python -m agent_marketplace.cli_commands verify plugins/my-plugin/plugin.json |
| 138 | +
|
| 139 | +# Batch-evaluate all plugins against policy |
| 140 | +python -m agent_marketplace.batch evaluate-batch plugins/ \ |
| 141 | + --policy policies/marketplace-policy.yaml \ |
| 142 | + --format text |
| 143 | +``` |
| 144 | + |
| 145 | +You can wire this into a Git pre-commit hook or use [pre-commit](https://pre-commit.com/). |
| 146 | + |
| 147 | +## Customization Points |
| 148 | + |
| 149 | +| What | Where | Notes | |
| 150 | +|------|-------|-------| |
| 151 | +| Allowed MCP servers | `policies/marketplace-policy.yaml` → `mcp_servers.allowed` | Add/remove servers as your trust boundary changes | |
| 152 | +| Blocked MCP servers | `policies/marketplace-policy.yaml` → `mcp_servers.blocked` | Use blocklist mode for open marketplaces | |
| 153 | +| Plugin type restrictions | `policies/marketplace-policy.yaml` → `allowed_plugin_types` | Remove to allow all types | |
| 154 | +| Signature enforcement | `policies/marketplace-policy.yaml` → `require_signature` | `false` for dev, `true` for production | |
| 155 | +| Dangerous tool rules | `policies/plugin-safety.yaml` → `rules[]` | Add rules matching your security posture | |
| 156 | +| Token budgets | `policies/plugin-safety.yaml` → `rules[]` | Adjust `max_tokens` per your cost tolerance | |
| 157 | +| CI trigger paths | `.github/workflows/plugin-governance.yml` → `paths` | Narrow or widen the trigger scope | |
| 158 | +| Toolkit version | Action input `toolkit-version` | Pin to a specific version for reproducibility | |
| 159 | +| Output format | Action input `output-format` | `json` for machine-readable, `text` for human-readable | |
| 160 | + |
| 161 | +## Related Tutorials |
| 162 | + |
| 163 | +- [Tutorial 07 — MCP Security Gateway](../../docs/tutorials/07-mcp-security-gateway.md): |
| 164 | + Deep dive into MCP server allowlisting and tool-poisoning detection |
| 165 | +- [Tutorial 10 — Plugin Marketplace](../../docs/tutorials/10-plugin-marketplace.md): |
| 166 | + End-to-end plugin lifecycle — discovery, installation, verification, and signing |
| 167 | +- [Tutorial 18 — Compliance Verification](../../docs/tutorials/18-compliance-verification.md): |
| 168 | + Governance attestation and compliance evidence generation |
| 169 | + |
| 170 | +## Related |
| 171 | + |
| 172 | +- [Policies](../policies/) — Additional sample governance policies |
| 173 | +- [Quickstart](../quickstart/) — One-file governed agents for popular frameworks |
0 commit comments