@clawdreyhepburn/carapace 0.1.0
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.
- package/LICENSE +190 -0
- package/NOTICE +13 -0
- package/README.md +408 -0
- package/openclaw.plugin.json +57 -0
- package/package.json +32 -0
- package/src/cedar-engine-cedarling.ts +585 -0
- package/src/cedar-engine.ts +426 -0
- package/src/gui/html.ts +919 -0
- package/src/gui/server.ts +169 -0
- package/src/index.ts +208 -0
- package/src/mcp-aggregator.ts +178 -0
- package/src/types.ts +107 -0
- package/tsconfig.json +16 -0
package/LICENSE
ADDED
|
@@ -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 owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
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 the 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 any 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 2026 Clawdrey Hepburn LLC. All rights reserved.
|
|
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.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Carapace
|
|
2
|
+
Copyright 2026 Clawdrey Hepburn LLC. All rights reserved.
|
|
3
|
+
|
|
4
|
+
"Carapace" is a trademark of Clawdrey Hepburn LLC. The name and associated
|
|
5
|
+
branding may not be used to endorse or promote products derived from this
|
|
6
|
+
software without specific prior written permission.
|
|
7
|
+
|
|
8
|
+
This product includes software developed by:
|
|
9
|
+
- Clawdrey Hepburn LLC (https://clawdrey.com)
|
|
10
|
+
- The Janssen Project / Gluu (https://github.com/JanssenProject/jans) — Cedarling WASM
|
|
11
|
+
- The Cedar Policy Project (https://www.cedarpolicy.com/) — Cedar policy language
|
|
12
|
+
|
|
13
|
+
Licensed under the Apache License, Version 2.0.
|
package/README.md
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">🦞 Carapace</h1>
|
|
3
|
+
<p align="center"><strong>Your agent's exoskeleton.</strong></p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
Immutable policy boundaries for MCP tool access.<br>
|
|
6
|
+
Powered by <a href="https://www.cedarpolicy.com/">Cedar</a> +
|
|
7
|
+
<a href="https://github.com/JanssenProject/jans/tree/main/jans-cedarling">Cedarling WASM</a>.
|
|
8
|
+
</p>
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="#installation">Installation</a> •
|
|
11
|
+
<a href="#quick-start">Quick Start</a> •
|
|
12
|
+
<a href="#how-it-works">How It Works</a> •
|
|
13
|
+
<a href="#gui">Control GUI</a> •
|
|
14
|
+
<a href="#security">Security</a> •
|
|
15
|
+
<a href="#attribution">Attribution</a>
|
|
16
|
+
</p>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Carapace is an [OpenClaw](https://github.com/openclaw/openclaw) plugin that sits between your AI agent and its MCP tools. It aggregates multiple MCP servers, discovers their tools, and enforces [Cedar](https://www.cedarpolicy.com/) authorization policies on every tool call — with a local GUI where humans can see and control everything.
|
|
22
|
+
|
|
23
|
+
**The problem:** MCP gives agents access to tools. But who decides *which* tools an agent can use? Today the answer is "whatever's in the config file" — a static, all-or-nothing list with no audit trail, no formal guarantees, and no human oversight.
|
|
24
|
+
|
|
25
|
+
**The solution:** Carapace puts Cedar between your agent and its tools. Cedar policies are declarative, auditable, and formally verifiable. The local GUI makes it accessible to humans who don't want to write policy files by hand. Toggle a switch, and the Cedar policy updates. It's that simple.
|
|
26
|
+
|
|
27
|
+
## Design Philosophy
|
|
28
|
+
|
|
29
|
+
**Installing Carapace should never break your agent.** The default policy is `allow-all` — every tool works exactly as before. Carapace gives you *visibility* first (see what tools exist, what's being called) and *control* second (add `forbid` policies for tools you want to restrict). When you're ready for full least-privilege, switch to `deny-all` and explicitly permit only what you need.
|
|
30
|
+
|
|
31
|
+
The progression:
|
|
32
|
+
1. **Install** → everything works, you can see all tools in the GUI
|
|
33
|
+
2. **Observe** → watch what your agent uses, understand the tool landscape
|
|
34
|
+
3. **Restrict** → forbid dangerous tools (write, execute) you don't want
|
|
35
|
+
4. **Lock down** → switch to `deny-all` for full least-privilege (optional)
|
|
36
|
+
|
|
37
|
+
## Architecture
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
+-------------+ +----------------------------+ +-----------------+
|
|
41
|
+
| | | Carapace | | MCP Server A |
|
|
42
|
+
| OpenClaw |---->| |---->| (filesystem) |
|
|
43
|
+
| Agent | | +----------------------+ | +-----------------+
|
|
44
|
+
| | | | Cedarling WASM | | | MCP Server B |
|
|
45
|
+
| | | | (Cedar 4.4.2) | |---->| (GitHub) |
|
|
46
|
+
| | | +----------------------+ | +-----------------+
|
|
47
|
+
| | | +----------------------+ | | MCP Server C |
|
|
48
|
+
| | | | Local Control GUI | |---->| (database) |
|
|
49
|
+
| | | +----------------------+ | +-----------------+
|
|
50
|
+
+-------------+ +--------------+--------------+
|
|
51
|
+
|
|
|
52
|
+
+------+------+
|
|
53
|
+
| Human |
|
|
54
|
+
| (browser) |
|
|
55
|
+
+-------------+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Every tool call flows through Cedar evaluation.** If the policy says deny, the call never reaches the upstream MCP server. The agent gets a clear denial message with the reason.
|
|
59
|
+
|
|
60
|
+
## Screenshots
|
|
61
|
+
|
|
62
|
+
### Tools Dashboard
|
|
63
|
+
The main view shows all discovered MCP tools across all connected servers, with category badges, toggle switches, and smart filtering.
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
Tools are automatically categorized by risk level:
|
|
68
|
+
- ✏️ **Write** (orange) — creates or modifies data
|
|
69
|
+
- ⚡ **Execute** (red) — triggers operations, toggles state
|
|
70
|
+
- 🔍 **Browse** (blue) — lists, searches, inspects metadata
|
|
71
|
+
- 📖 **Read** (teal) — retrieves content, no side effects
|
|
72
|
+
|
|
73
|
+
Default sort puts the riskiest tools at the top. Filter by category, status, server, or search.
|
|
74
|
+
|
|
75
|
+
### Policy Management
|
|
76
|
+
View, edit, and delete Cedar policies. Each policy card shows its effect (permit/forbid) and expands to reveal the full policy text in an inline editor.
|
|
77
|
+
|
|
78
|
+

|
|
79
|
+
|
|
80
|
+
### Visual Policy Builder
|
|
81
|
+
Build Cedar policies without writing code. Dropdowns are populated from your Cedar schema — entity types, actions, and discovered tools. A live preview shows the Cedar policy updating in real-time as you fill in fields.
|
|
82
|
+
|
|
83
|
+

|
|
84
|
+
|
|
85
|
+
### Schema Editor
|
|
86
|
+
View and edit the Cedar schema directly. The schema defines what entity types, actions, and attributes exist in your policy world.
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
### Prerequisites
|
|
93
|
+
|
|
94
|
+
- [Node.js](https://nodejs.org/) 20 or later
|
|
95
|
+
- [OpenClaw](https://github.com/openclaw/openclaw) (optional — Carapace can also run standalone)
|
|
96
|
+
|
|
97
|
+
### As an OpenClaw Plugin
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Install the plugin
|
|
101
|
+
openclaw plugins install @openclaw/carapace
|
|
102
|
+
|
|
103
|
+
# Configure your MCP servers
|
|
104
|
+
openclaw configure
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Standalone (for development/testing)
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
git clone https://github.com/clawdreyhepburn/carapace.git
|
|
111
|
+
cd carapace
|
|
112
|
+
npm install
|
|
113
|
+
npx tsx test/harness.ts
|
|
114
|
+
# Open http://localhost:19820
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
### 1. Configure upstream MCP servers
|
|
120
|
+
|
|
121
|
+
In your OpenClaw config, add the servers you want Carapace to manage:
|
|
122
|
+
|
|
123
|
+
```json5
|
|
124
|
+
{
|
|
125
|
+
plugins: {
|
|
126
|
+
entries: {
|
|
127
|
+
"carapace": {
|
|
128
|
+
enabled: true,
|
|
129
|
+
config: {
|
|
130
|
+
guiPort: 19820,
|
|
131
|
+
defaultPolicy: "allow-all",
|
|
132
|
+
servers: {
|
|
133
|
+
"filesystem": {
|
|
134
|
+
transport: "stdio",
|
|
135
|
+
command: "npx",
|
|
136
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/docs"]
|
|
137
|
+
},
|
|
138
|
+
"github": {
|
|
139
|
+
transport: "stdio",
|
|
140
|
+
command: "npx",
|
|
141
|
+
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
142
|
+
env: { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 2. Open the control GUI
|
|
153
|
+
|
|
154
|
+
Navigate to [http://localhost:19820](http://localhost:19820) in your browser. You'll see all discovered tools from all connected servers.
|
|
155
|
+
|
|
156
|
+
### 3. Enable tools
|
|
157
|
+
|
|
158
|
+
Toggle individual tools on/off. Each toggle writes a Cedar policy:
|
|
159
|
+
|
|
160
|
+
- **Toggle ON** → creates a `permit` policy for that tool
|
|
161
|
+
- **Toggle OFF** → creates a `forbid` policy for that tool
|
|
162
|
+
|
|
163
|
+
### 4. Create custom policies
|
|
164
|
+
|
|
165
|
+
Click **"+ New Policy"** to open the visual builder, or edit policies directly in the Policies tab. Examples:
|
|
166
|
+
|
|
167
|
+
```cedar
|
|
168
|
+
// Allow the agent to read files but not write them
|
|
169
|
+
permit(
|
|
170
|
+
principal is Jans::Workload,
|
|
171
|
+
action == Jans::Action::"call_tool",
|
|
172
|
+
resource == Jans::Tool::"filesystem/read_file"
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// Block all write operations across all servers
|
|
176
|
+
forbid(
|
|
177
|
+
principal,
|
|
178
|
+
action == Jans::Action::"call_tool",
|
|
179
|
+
resource == Jans::Tool::"filesystem/write_file"
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// Allow everything (use with caution)
|
|
183
|
+
permit(
|
|
184
|
+
principal is Jans::Workload,
|
|
185
|
+
action,
|
|
186
|
+
resource
|
|
187
|
+
);
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 5. Verify policies
|
|
191
|
+
|
|
192
|
+
Click **⚡ Verify** to validate that all policies are syntactically correct and consistent.
|
|
193
|
+
|
|
194
|
+
## How It Works
|
|
195
|
+
|
|
196
|
+
### Cedar Policy Evaluation
|
|
197
|
+
|
|
198
|
+
Carapace uses [Cedarling](https://github.com/JanssenProject/jans/tree/main/jans-cedarling), Gluu's high-performance Cedar policy engine compiled to WebAssembly. This means:
|
|
199
|
+
|
|
200
|
+
- **Real Cedar evaluation** — not a simplified subset. Full Cedar 4.4.2 with the official Rust SDK.
|
|
201
|
+
- **Forbid always wins** — if any policy says `forbid`, the request is denied regardless of any `permit` policies. This is core Cedar semantics and prevents privilege escalation.
|
|
202
|
+
- **Allow-all by default** — installing Carapace doesn't break anything. All tools work until you add `forbid` policies. Switch to `deny-all` when you're ready for least-privilege.
|
|
203
|
+
- **Sub-millisecond evaluation** — WASM runs at near-native speed. Typical authorization decisions take <6ms.
|
|
204
|
+
|
|
205
|
+
### Policy Store Format
|
|
206
|
+
|
|
207
|
+
Policies are stored as individual `.cedar` files in the policy directory (default: `~/.openclaw/mcp-policies/`). On startup and after any change, Carapace builds a [Cedarling Policy Store](https://github.com/JanssenProject/jans/wiki/Cedarling-Nativity-Plan) — a portable JSON bundle containing all policies, the Cedar schema, and trusted issuer configuration.
|
|
208
|
+
|
|
209
|
+
### Tool Categorization
|
|
210
|
+
|
|
211
|
+
Tools are automatically categorized by operation type based on name analysis:
|
|
212
|
+
|
|
213
|
+
| Category | Color | Risk | Examples |
|
|
214
|
+
|----------|-------|------|----------|
|
|
215
|
+
| ✏️ Write | Orange | High | `write_file`, `edit_file`, `create_directory` |
|
|
216
|
+
| ⚡ Execute | Red | High | `toggle-logging`, `trigger-long-running-operation` |
|
|
217
|
+
| 🔍 Browse | Blue | Medium | `list_directory`, `search_files`, `get-env` |
|
|
218
|
+
| 📖 Read | Teal | Low | `read_file`, `echo`, `get-sum` |
|
|
219
|
+
|
|
220
|
+
The default sort order puts Write and Execute tools at the top — the tools that need human review first.
|
|
221
|
+
|
|
222
|
+
### API Endpoints
|
|
223
|
+
|
|
224
|
+
The GUI communicates with Carapace through a local REST API:
|
|
225
|
+
|
|
226
|
+
| Endpoint | Method | Description |
|
|
227
|
+
|----------|--------|-------------|
|
|
228
|
+
| `/api/status` | GET | Server status, all tools, all policies |
|
|
229
|
+
| `/api/tools` | GET | List tools (optional `?server=` filter) |
|
|
230
|
+
| `/api/toggle` | POST | Enable/disable a tool `{"tool": "...", "enabled": true}` |
|
|
231
|
+
| `/api/policy` | POST | Create/update a policy `{"id": "...", "raw": "..."}` |
|
|
232
|
+
| `/api/policy` | DELETE | Delete a policy `{"id": "..."}` |
|
|
233
|
+
| `/api/policies` | GET | List all policies |
|
|
234
|
+
| `/api/schema` | GET | Get Cedar schema (parsed + raw) |
|
|
235
|
+
| `/api/schema` | POST | Update Cedar schema `{"raw": "..."}` |
|
|
236
|
+
| `/api/verify` | POST | Verify all policies |
|
|
237
|
+
|
|
238
|
+
## Security
|
|
239
|
+
|
|
240
|
+
### Threat Model
|
|
241
|
+
|
|
242
|
+
Carapace is designed to protect against:
|
|
243
|
+
|
|
244
|
+
1. **Overprivileged agents** — An agent configured with access to 50 MCP tools but only needing 5. Start with allow-all (safe install), then use the GUI to lock down what you don't need. Switch to `deny-all` for full least-privilege.
|
|
245
|
+
|
|
246
|
+
2. **Privilege escalation via tool chaining** — An agent using a permitted tool to accomplish what a forbidden tool would do. Cedar's `forbid`-always-wins semantics help here: you can blanket-permit and then surgically forbid dangerous operations.
|
|
247
|
+
|
|
248
|
+
3. **Configuration drift** — Tool permissions accumulating over time without review. The GUI provides a single view of all permissions, and policies are stored as auditable files.
|
|
249
|
+
|
|
250
|
+
### What Carapace Does NOT Protect Against
|
|
251
|
+
|
|
252
|
+
- **Malicious MCP servers** — Carapace trusts the upstream MCP servers to behave as described. It does not sandbox server execution.
|
|
253
|
+
- **Tool argument validation** — Carapace authorizes *which* tool can be called, not *what arguments* are passed. (Cedar conditions can add argument-level checks, but this requires custom policies.)
|
|
254
|
+
- **Network-level attacks** — The GUI runs on localhost without authentication. See [GUI Security](#gui-security) below.
|
|
255
|
+
|
|
256
|
+
### GUI Security
|
|
257
|
+
|
|
258
|
+
The control GUI binds to `127.0.0.1` (localhost only) by default. It is **not** accessible from the network.
|
|
259
|
+
|
|
260
|
+
> ⚠️ **Do not expose the GUI port to the network.** The API has no authentication. Anyone who can reach the API can modify policies.
|
|
261
|
+
|
|
262
|
+
If you need remote access, put it behind an authenticated reverse proxy (e.g., Caddy with basic auth, or an SSH tunnel).
|
|
263
|
+
|
|
264
|
+
### Policy File Security
|
|
265
|
+
|
|
266
|
+
Policy files are stored in `~/.openclaw/mcp-policies/` by default. Ensure this directory has appropriate file permissions:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
chmod 700 ~/.openclaw/mcp-policies/
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Cedar Schema Trust
|
|
273
|
+
|
|
274
|
+
The Cedar schema defines what entity types and actions exist. A modified schema could allow policies to be written that appear restrictive but are actually permissive due to type mismatches. Treat the schema file with the same care as the policies themselves.
|
|
275
|
+
|
|
276
|
+
## Configuration Reference
|
|
277
|
+
|
|
278
|
+
| Property | Type | Default | Description |
|
|
279
|
+
|----------|------|---------|-------------|
|
|
280
|
+
| `guiPort` | number | `19820` | Port for the local control GUI |
|
|
281
|
+
| `servers` | object | `{}` | Upstream MCP servers (see [Quick Start](#quick-start)) |
|
|
282
|
+
| `policyDir` | string | `~/.openclaw/mcp-policies/` | Directory for Cedar policy files |
|
|
283
|
+
| `defaultPolicy` | `"deny-all"` \| `"allow-all"` | `"allow-all"` | Default policy for tools. `allow-all` keeps everything working on install — use the GUI to restrict. `deny-all` requires explicit permits. |
|
|
284
|
+
| `verify` | boolean | `false` | Run verification on policy changes |
|
|
285
|
+
|
|
286
|
+
### Server Configuration
|
|
287
|
+
|
|
288
|
+
Each server entry supports:
|
|
289
|
+
|
|
290
|
+
| Property | Type | Description |
|
|
291
|
+
|----------|------|-------------|
|
|
292
|
+
| `transport` | `"stdio"` \| `"http"` \| `"sse"` | Transport protocol (stdio supported in v0.1) |
|
|
293
|
+
| `command` | string | Command to run (stdio transport) |
|
|
294
|
+
| `args` | string[] | Command arguments |
|
|
295
|
+
| `env` | object | Environment variables |
|
|
296
|
+
| `url` | string | Server URL (http/sse transport) |
|
|
297
|
+
|
|
298
|
+
## Development
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
git clone https://github.com/clawdreyhepburn/carapace.git
|
|
302
|
+
cd carapace
|
|
303
|
+
npm install
|
|
304
|
+
|
|
305
|
+
# Run the test harness (starts 2 MCP servers + GUI)
|
|
306
|
+
npx tsx test/harness.ts
|
|
307
|
+
|
|
308
|
+
# Type check
|
|
309
|
+
npx tsc --noEmit
|
|
310
|
+
|
|
311
|
+
# Run tests
|
|
312
|
+
npm test
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Project Structure
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
carapace/
|
|
319
|
+
├── src/
|
|
320
|
+
│ ├── index.ts # OpenClaw plugin entry point
|
|
321
|
+
│ ├── cedar-engine-cedarling.ts # Cedarling WASM integration
|
|
322
|
+
│ ├── cedar-engine.ts # Fallback Cedar engine (no WASM)
|
|
323
|
+
│ ├── mcp-aggregator.ts # MCP server connection & tool discovery
|
|
324
|
+
│ ├── types.ts # Shared TypeScript types
|
|
325
|
+
│ └── gui/
|
|
326
|
+
│ ├── server.ts # HTTP server for the control GUI
|
|
327
|
+
│ └── html.ts # Single-file GUI (HTML + CSS + JS)
|
|
328
|
+
├── test/
|
|
329
|
+
│ └── harness.ts # Standalone test harness
|
|
330
|
+
├── policies/ # Default policy directory
|
|
331
|
+
├── docs/
|
|
332
|
+
│ └── screenshots/ # GUI screenshots
|
|
333
|
+
├── LICENSE # Apache-2.0
|
|
334
|
+
├── NOTICE # Attribution and trademark notice
|
|
335
|
+
└── package.json
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Learn More
|
|
339
|
+
|
|
340
|
+
Want to understand the ideas behind Carapace? Check out the **Cedar for AI Agents** blog series:
|
|
341
|
+
|
|
342
|
+
1. [Part 1: Why Your AI Agent Needs a Policy Language](https://clawdrey.com/blog/cedar-for-ai-agents-part-1-why-your-ai-agent-needs-a-policy-language.html)
|
|
343
|
+
2. [Part 2: Writing Your First Agent Policy](https://clawdrey.com/blog/cedar-for-ai-agents-part-2-writing-your-first-agent-policy.html)
|
|
344
|
+
3. [Part 3: When Forbid Meets Permit](https://clawdrey.com/blog/cedar-for-ai-agents-part-3-when-forbid-meets-permit.html)
|
|
345
|
+
4. [Part 4: Proving It — SMT Solvers and Why I Trust Math More Than Tests](https://clawdrey.com/blog/proving-it-smt-solvers-and-why-i-trust-math-more-than-tests.html)
|
|
346
|
+
|
|
347
|
+
More writing, projects, and general lobster antics at [clawdrey.com](https://clawdrey.com).
|
|
348
|
+
|
|
349
|
+
## Built With
|
|
350
|
+
|
|
351
|
+
- **[Cedar](https://www.cedarpolicy.com/)** — Policy language by AWS. Declarative, analyzable, fast.
|
|
352
|
+
- **[Cedarling](https://github.com/JanssenProject/jans/tree/main/jans-cedarling)** — Cedar policy engine by [Gluu](https://gluu.org/), compiled to WebAssembly. Provides JWT-aware authorization and the Policy Store format.
|
|
353
|
+
- **[MCP (Model Context Protocol)](https://modelcontextprotocol.io/)** — Open protocol for connecting AI agents to tools and data sources.
|
|
354
|
+
- **[OpenClaw](https://github.com/openclaw/openclaw)** — Open-source AI agent runtime.
|
|
355
|
+
|
|
356
|
+
## Contributors
|
|
357
|
+
|
|
358
|
+
<!-- ALL-CONTRIBUTORS-LIST:START -->
|
|
359
|
+
| Avatar | Name | Role |
|
|
360
|
+
|--------|------|------|
|
|
361
|
+
| <img src="https://github.com/ClawdreyHepworthy.png" width="50"> | **Clawdrey Hepburn** ([@ClawdreyHepburn](https://x.com/ClawdreyHepburn)) | Creator, primary author |
|
|
362
|
+
| <img src="https://github.com/Sarahcec.png" width="50"> | **Sarah Cecchetti** ([@Sarahcec](https://github.com/Sarahcec)) | Co-creator, product direction |
|
|
363
|
+
| <img src="https://github.com/nynymike.png" width="50"> | **Michael Schwartz** ([@nynymike](https://github.com/nynymike)) | Cedarling / Gluu |
|
|
364
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
365
|
+
|
|
366
|
+
## License
|
|
367
|
+
|
|
368
|
+
Copyright 2026 Clawdrey Hepburn LLC. All rights reserved.
|
|
369
|
+
|
|
370
|
+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full text.
|
|
371
|
+
|
|
372
|
+
**"Carapace"** is a trademark of Clawdrey Hepburn LLC. See [NOTICE](NOTICE) for trademark details.
|
|
373
|
+
|
|
374
|
+
## Attribution & Usage Guidelines
|
|
375
|
+
|
|
376
|
+
We'd love for you to tell people you use Carapace! Here's how to reference it correctly:
|
|
377
|
+
|
|
378
|
+
### ✅ Correct Usage
|
|
379
|
+
|
|
380
|
+
- "**Protected by Carapace**" — great for badges and footers
|
|
381
|
+
- "**Powered by Carapace**" — great for technical documentation
|
|
382
|
+
- "**Built with Carapace**" — great for project READMEs
|
|
383
|
+
- "**Uses Carapace for MCP tool authorization**" — great for blog posts
|
|
384
|
+
|
|
385
|
+
### Badge
|
|
386
|
+
|
|
387
|
+
```markdown
|
|
388
|
+

|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+

|
|
392
|
+
|
|
393
|
+
### ❌ Incorrect Usage
|
|
394
|
+
|
|
395
|
+
- ~~"**Made by Carapace**"~~ — Carapace is a policy engine, not a manufacturer. This implies liability on our part for what your agent does.
|
|
396
|
+
- ~~"**Certified by Carapace**"~~ — We don't certify anything. Carapace enforces policies you write.
|
|
397
|
+
- ~~"**Carapace-approved**"~~ — Same issue. The policies are yours; the enforcement is ours.
|
|
398
|
+
|
|
399
|
+
**The distinction matters:** Carapace enforces *your* policies. You are responsible for writing good policies. We are responsible for evaluating them correctly.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
<p align="center">
|
|
404
|
+
<em>A carapace is the hard upper shell of a crustacean — an immutable boundary that defines the limits of the creature inside. It protects, it constrains, it's structural.</em>
|
|
405
|
+
</p>
|
|
406
|
+
<p align="center">
|
|
407
|
+
<strong>Your agent's exoskeleton.</strong>
|
|
408
|
+
</p>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "carapace",
|
|
3
|
+
"name": "Carapace",
|
|
4
|
+
"description": "Immutable policy boundaries for MCP tool access. Your agent's exoskeleton.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"guiPort": {
|
|
11
|
+
"type": "number",
|
|
12
|
+
"default": 19820,
|
|
13
|
+
"description": "Port for the local control GUI"
|
|
14
|
+
},
|
|
15
|
+
"servers": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "Upstream MCP servers to aggregate",
|
|
18
|
+
"additionalProperties": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"transport": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"enum": ["stdio", "http", "sse"],
|
|
24
|
+
"default": "stdio"
|
|
25
|
+
},
|
|
26
|
+
"command": { "type": "string" },
|
|
27
|
+
"args": { "type": "array", "items": { "type": "string" } },
|
|
28
|
+
"env": { "type": "object", "additionalProperties": { "type": "string" } },
|
|
29
|
+
"url": { "type": "string" }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"policyDir": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"default": "~/.openclaw/mcp-policies/",
|
|
36
|
+
"description": "Directory for Cedar policy files"
|
|
37
|
+
},
|
|
38
|
+
"defaultPolicy": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": ["deny-all", "allow-all"],
|
|
41
|
+
"default": "allow-all",
|
|
42
|
+
"description": "Default policy for tools. allow-all (default) keeps everything working — use the GUI to restrict. deny-all requires explicit permits."
|
|
43
|
+
},
|
|
44
|
+
"verify": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Run cvc5 formal verification on policy changes"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"uiHints": {
|
|
52
|
+
"guiPort": { "label": "GUI Port", "placeholder": "19820" },
|
|
53
|
+
"policyDir": { "label": "Policy Directory" },
|
|
54
|
+
"defaultPolicy": { "label": "Default Policy for New Tools" },
|
|
55
|
+
"verify": { "label": "Enable Formal Verification" }
|
|
56
|
+
}
|
|
57
|
+
}
|