noldorian 0.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.
- noldorian-0.1.0/.gitignore +8 -0
- noldorian-0.1.0/CONTRIBUTING.md +14 -0
- noldorian-0.1.0/LICENSE +201 -0
- noldorian-0.1.0/PKG-INFO +101 -0
- noldorian-0.1.0/README.md +78 -0
- noldorian-0.1.0/SECURE_CAPABILITY_BROKER.md +156 -0
- noldorian-0.1.0/SECURITY.md +13 -0
- noldorian-0.1.0/pyproject.toml +49 -0
- noldorian-0.1.0/src/noldorian/__init__.py +7 -0
- noldorian-0.1.0/src/noldorian/__main__.py +7 -0
- noldorian-0.1.0/src/noldorian/cli.py +72 -0
- noldorian-0.1.0/src/noldorian/client.py +117 -0
- noldorian-0.1.0/src/noldorian/errors.py +5 -0
- noldorian-0.1.0/src/noldorian/mcp.py +163 -0
- noldorian-0.1.0/tests/test_public_package.py +90 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions are welcome through GitHub pull requests.
|
|
4
|
+
|
|
5
|
+
Before opening a pull request, run the public-package and family tests shown in
|
|
6
|
+
`.github/workflows/test.yml`. New credential providers must expose a closed
|
|
7
|
+
operation set, validate all arguments before resolving a credential, avoid
|
|
8
|
+
shells and caller-selected executables, structurally parse provider output,
|
|
9
|
+
and include non-disclosure tests.
|
|
10
|
+
|
|
11
|
+
Do not include credential values, account-specific policy, custody paths,
|
|
12
|
+
machine authorization lists, or customer configuration in issues, fixtures,
|
|
13
|
+
commits, or build artifacts. Report vulnerabilities privately as described in
|
|
14
|
+
`SECURITY.md`.
|
noldorian-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 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 Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Everplay-Tech LLC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
noldorian-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: noldorian
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Agent-safe discovery and policy-bound use of local credential capabilities
|
|
5
|
+
Project-URL: Documentation, https://github.com/E-TECH-PLAYTECH/noldorian#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/E-TECH-PLAYTECH/noldorian/issues
|
|
7
|
+
Project-URL: Repository, https://github.com/E-TECH-PLAYTECH/noldorian
|
|
8
|
+
Author: Everplay-Tech LLC
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,credentials,mcp,secrets,security,unix-socket
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Topic :: Security
|
|
20
|
+
Classifier: Topic :: System :: Systems Administration
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# Noldorian
|
|
25
|
+
|
|
26
|
+
Noldorian lets agents discover and invoke approved credential capabilities
|
|
27
|
+
without giving them a secret-value API.
|
|
28
|
+
|
|
29
|
+
The public `noldorian` package is a zero-dependency client, CLI, and MCP server
|
|
30
|
+
for the local root-owned capability broker. The broker exposes public metadata
|
|
31
|
+
and a closed set of typed operations; credential values, custody paths,
|
|
32
|
+
arbitrary commands, and raw HTTP requests stay outside the agent surface.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python3 -m pip install noldorian
|
|
38
|
+
# or
|
|
39
|
+
uv tool install noldorian
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Query capabilities
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
noldorian status
|
|
46
|
+
noldorian list
|
|
47
|
+
noldorian describe openai.tunnel.admin
|
|
48
|
+
noldorian invoke openai.tunnel.admin tunnels.list \
|
|
49
|
+
--arguments-json '{"organization_ids":["org_example"]}'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The client does not provide registration, enrollment, import, export,
|
|
53
|
+
clipboard, shell, or secret-retrieval commands.
|
|
54
|
+
|
|
55
|
+
## MCP
|
|
56
|
+
|
|
57
|
+
Run the bundled stdio MCP server:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
noldorian-mcp
|
|
61
|
+
# equivalent: python3 -m noldorian.mcp
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
It exposes four tools:
|
|
65
|
+
|
|
66
|
+
- `broker_status`
|
|
67
|
+
- `list_credential_capabilities`
|
|
68
|
+
- `describe_credential_capability`
|
|
69
|
+
- `invoke_credential_capability`
|
|
70
|
+
|
|
71
|
+
## Broker installation
|
|
72
|
+
|
|
73
|
+
The root-owned broker and human enrollment ceremony currently live in the
|
|
74
|
+
`keyabra` package in this repository. See the
|
|
75
|
+
[secure capability broker design](https://github.com/E-TECH-PLAYTECH/noldorian/blob/main/SECURE_CAPABILITY_BROKER.md)
|
|
76
|
+
for installation, the trust boundary, and the adapter contract.
|
|
77
|
+
|
|
78
|
+
Publishing the implementation does not publish or weaken the live broker
|
|
79
|
+
state. Credentials, capability grants, account identifiers, and authorized
|
|
80
|
+
machine identities are local configuration and must never be committed or
|
|
81
|
+
included in distributions.
|
|
82
|
+
|
|
83
|
+
## Noldorian family
|
|
84
|
+
|
|
85
|
+
This repository also contains the operator-focused tools that originated the
|
|
86
|
+
Noldorian tier:
|
|
87
|
+
|
|
88
|
+
| Package | CLI | Purpose |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| `keyabra` | `keyabra` | Human secret enrollment and root broker service |
|
|
91
|
+
| `xadabra` | `xadabra` | Interactive placeholder runner |
|
|
92
|
+
| `binabra` | `abra` | Portable bin-directory anchor |
|
|
93
|
+
| `xabra` | `xabra` | Verified direct-distribution app installer |
|
|
94
|
+
| `xalakazam` | `xalakazam` | Operator orientation and checkpoints |
|
|
95
|
+
|
|
96
|
+
## Security and license
|
|
97
|
+
|
|
98
|
+
Please use GitHub's private vulnerability-reporting flow; see the
|
|
99
|
+
[security policy](https://github.com/E-TECH-PLAYTECH/noldorian/blob/main/SECURITY.md).
|
|
100
|
+
Noldorian is licensed under the
|
|
101
|
+
[Apache License 2.0](https://github.com/E-TECH-PLAYTECH/noldorian/blob/main/LICENSE).
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Noldorian
|
|
2
|
+
|
|
3
|
+
Noldorian lets agents discover and invoke approved credential capabilities
|
|
4
|
+
without giving them a secret-value API.
|
|
5
|
+
|
|
6
|
+
The public `noldorian` package is a zero-dependency client, CLI, and MCP server
|
|
7
|
+
for the local root-owned capability broker. The broker exposes public metadata
|
|
8
|
+
and a closed set of typed operations; credential values, custody paths,
|
|
9
|
+
arbitrary commands, and raw HTTP requests stay outside the agent surface.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
python3 -m pip install noldorian
|
|
15
|
+
# or
|
|
16
|
+
uv tool install noldorian
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Query capabilities
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
noldorian status
|
|
23
|
+
noldorian list
|
|
24
|
+
noldorian describe openai.tunnel.admin
|
|
25
|
+
noldorian invoke openai.tunnel.admin tunnels.list \
|
|
26
|
+
--arguments-json '{"organization_ids":["org_example"]}'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The client does not provide registration, enrollment, import, export,
|
|
30
|
+
clipboard, shell, or secret-retrieval commands.
|
|
31
|
+
|
|
32
|
+
## MCP
|
|
33
|
+
|
|
34
|
+
Run the bundled stdio MCP server:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
noldorian-mcp
|
|
38
|
+
# equivalent: python3 -m noldorian.mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
It exposes four tools:
|
|
42
|
+
|
|
43
|
+
- `broker_status`
|
|
44
|
+
- `list_credential_capabilities`
|
|
45
|
+
- `describe_credential_capability`
|
|
46
|
+
- `invoke_credential_capability`
|
|
47
|
+
|
|
48
|
+
## Broker installation
|
|
49
|
+
|
|
50
|
+
The root-owned broker and human enrollment ceremony currently live in the
|
|
51
|
+
`keyabra` package in this repository. See the
|
|
52
|
+
[secure capability broker design](https://github.com/E-TECH-PLAYTECH/noldorian/blob/main/SECURE_CAPABILITY_BROKER.md)
|
|
53
|
+
for installation, the trust boundary, and the adapter contract.
|
|
54
|
+
|
|
55
|
+
Publishing the implementation does not publish or weaken the live broker
|
|
56
|
+
state. Credentials, capability grants, account identifiers, and authorized
|
|
57
|
+
machine identities are local configuration and must never be committed or
|
|
58
|
+
included in distributions.
|
|
59
|
+
|
|
60
|
+
## Noldorian family
|
|
61
|
+
|
|
62
|
+
This repository also contains the operator-focused tools that originated the
|
|
63
|
+
Noldorian tier:
|
|
64
|
+
|
|
65
|
+
| Package | CLI | Purpose |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `keyabra` | `keyabra` | Human secret enrollment and root broker service |
|
|
68
|
+
| `xadabra` | `xadabra` | Interactive placeholder runner |
|
|
69
|
+
| `binabra` | `abra` | Portable bin-directory anchor |
|
|
70
|
+
| `xabra` | `xabra` | Verified direct-distribution app installer |
|
|
71
|
+
| `xalakazam` | `xalakazam` | Operator orientation and checkpoints |
|
|
72
|
+
|
|
73
|
+
## Security and license
|
|
74
|
+
|
|
75
|
+
Please use GitHub's private vulnerability-reporting flow; see the
|
|
76
|
+
[security policy](https://github.com/E-TECH-PLAYTECH/noldorian/blob/main/SECURITY.md).
|
|
77
|
+
Noldorian is licensed under the
|
|
78
|
+
[Apache License 2.0](https://github.com/E-TECH-PLAYTECH/noldorian/blob/main/LICENSE).
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Noldorian credential capability broker
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Agents need to know which authenticated operations are available without being
|
|
6
|
+
able to retrieve, print, transform, copy, or choose an arbitrary process that
|
|
7
|
+
receives the credential. Legacy Keyabra env-vaults solve human paste and
|
|
8
|
+
shell-history problems, but they are not an agent isolation boundary: an agent
|
|
9
|
+
running as the same Unix user can read a `0600` file, and an arbitrary
|
|
10
|
+
`keyabra run` command can deliberately encode or transmit its environment.
|
|
11
|
+
|
|
12
|
+
The capability broker adds that missing boundary.
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
owner hidden prompt / owner import
|
|
16
|
+
│
|
|
17
|
+
▼
|
|
18
|
+
root-owned broker + secret custody
|
|
19
|
+
│
|
|
20
|
+
┌──────────┴──────────┐
|
|
21
|
+
▼ ▼
|
|
22
|
+
public capability fixed adapter
|
|
23
|
+
metadata (typed arguments)
|
|
24
|
+
│ │
|
|
25
|
+
└──────────┬──────────┘
|
|
26
|
+
▼
|
|
27
|
+
sanitized receipt / MCP result
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
There is intentionally no secret export, clipboard, arbitrary shell, or raw
|
|
31
|
+
HTTP operation in the broker or its MCP server.
|
|
32
|
+
|
|
33
|
+
## Trust boundary
|
|
34
|
+
|
|
35
|
+
Production installation runs as a root LaunchDaemon. Its application and
|
|
36
|
+
state are root-owned under:
|
|
37
|
+
|
|
38
|
+
`/Library/Application Support/NoldorianKeyBroker`
|
|
39
|
+
|
|
40
|
+
Secret custody files and the capability catalog are mode `0600` below a mode
|
|
41
|
+
`0700` state directory. Authorized desktop agents communicate through
|
|
42
|
+
`/var/run/noldorian-key-broker.sock`. The daemon verifies the Unix peer UID;
|
|
43
|
+
request-supplied identity is ignored.
|
|
44
|
+
|
|
45
|
+
Normal authorized UIDs may only:
|
|
46
|
+
|
|
47
|
+
- check service status;
|
|
48
|
+
- list public capability metadata;
|
|
49
|
+
- describe one capability; and
|
|
50
|
+
- invoke an operation already compiled into an adapter and allowed by the
|
|
51
|
+
owner-controlled catalog.
|
|
52
|
+
|
|
53
|
+
Only UID 0 may register a capability, enroll a credential, or import one entry
|
|
54
|
+
from a legacy Keyabra env-vault. An agent cannot gain owner access without an
|
|
55
|
+
operator satisfying the operating system's administrator gate.
|
|
56
|
+
|
|
57
|
+
The broker cannot protect against a compromised root account or a modified
|
|
58
|
+
operating system. Legacy dotenv vaults remain outside this guarantee until
|
|
59
|
+
their entries are imported and the plaintext copies are retired by the owner.
|
|
60
|
+
|
|
61
|
+
## Capability contract
|
|
62
|
+
|
|
63
|
+
Public metadata contains:
|
|
64
|
+
|
|
65
|
+
- a stable capability ID;
|
|
66
|
+
- provider and human description;
|
|
67
|
+
- approved operation names;
|
|
68
|
+
- resource scope such as organization/workspace IDs; and
|
|
69
|
+
- `available: true|false`.
|
|
70
|
+
|
|
71
|
+
It never contains credential values or fragments, custody paths, token length,
|
|
72
|
+
fingerprints, hashes, or arbitrary executable commands.
|
|
73
|
+
|
|
74
|
+
The catalog accepts only whitelisted fields and adapters. The initial adapter
|
|
75
|
+
is `openai_tunnel_admin`, with these operations:
|
|
76
|
+
|
|
77
|
+
- `tunnels.list`
|
|
78
|
+
- `tunnels.get`
|
|
79
|
+
- `tunnels.create`
|
|
80
|
+
|
|
81
|
+
Arguments are validated and translated to the native `tunnel-client admin
|
|
82
|
+
tunnels` command tree without a shell. The key exists only in the child
|
|
83
|
+
environment. Results are parsed as JSON and recursively redact sensitive
|
|
84
|
+
field names plus direct, URL-encoded, base64, URL-safe-base64, and hexadecimal
|
|
85
|
+
secret representations.
|
|
86
|
+
|
|
87
|
+
## Install on macOS
|
|
88
|
+
|
|
89
|
+
From the Noldorian checkout:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
sudo keyabra/scripts/install_broker_macos.sh --user "$USER"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The installer creates a root-owned zipapp, trusted copy of the provider
|
|
96
|
+
client, LaunchDaemon, state directory, and Unix socket. It does not register a
|
|
97
|
+
capability or enroll a key unless an owner supplies `--capability SPEC.json`.
|
|
98
|
+
|
|
99
|
+
## Owner enrollment
|
|
100
|
+
|
|
101
|
+
To register or update another non-secret policy:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
cp keyabra/examples/openai-tunnel-admin.capability.json /tmp/tunnel-policy.json
|
|
105
|
+
# Edit the copied public placeholders, then:
|
|
106
|
+
sudo keyabra broker register /tmp/tunnel-policy.json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
If the credential already exists in a legacy vault, import it by reference;
|
|
110
|
+
the agent and client never receive its value:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
sudo keyabra broker import-env \
|
|
114
|
+
openai.tunnel.admin \
|
|
115
|
+
/absolute/path/to/keyabra.env \
|
|
116
|
+
OPENAI_ADMIN_KEY
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For a new credential, enroll through Keyabra's confirmed hidden prompt:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sudo keyabra broker enroll openai.tunnel.admin
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
After live provider validation, the owner should retire the legacy plaintext
|
|
126
|
+
entry through a separate reviewed migration. Enrollment never silently
|
|
127
|
+
deletes the source.
|
|
128
|
+
|
|
129
|
+
## Agent use
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
keyabra broker status
|
|
133
|
+
keyabra broker list
|
|
134
|
+
keyabra broker describe openai.tunnel.admin
|
|
135
|
+
keyabra broker invoke openai.tunnel.admin tunnels.list \
|
|
136
|
+
--arguments-json '{"organization_ids":["org_example"]}'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
MCP server:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
python3 mcp/noldorian_capabilities_mcp.py
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The MCP tools are `broker_status`, `list_credential_capabilities`,
|
|
146
|
+
`describe_credential_capability`, and `invoke_credential_capability`. No owner
|
|
147
|
+
or secret-value tool is exposed over MCP.
|
|
148
|
+
|
|
149
|
+
## Adding a provider
|
|
150
|
+
|
|
151
|
+
Provider support is code, not catalog data. A new adapter must define a closed
|
|
152
|
+
operation set, validate every argument before resolving the secret, avoid
|
|
153
|
+
shells and caller-supplied executables, validate provider identity and scope,
|
|
154
|
+
structurally parse provider output, redact sensitive fields and common secret
|
|
155
|
+
encodings, and include tests proving credentials never appear in results,
|
|
156
|
+
errors, commands, or receipts.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
Noldorian is designed so agent-facing clients can discover and invoke approved
|
|
4
|
+
credential capabilities without retrieving credential values.
|
|
5
|
+
|
|
6
|
+
Please report suspected vulnerabilities privately through GitHub's **Report a
|
|
7
|
+
vulnerability** flow for `E-TECH-PLAYTECH/noldorian`. Do not open a public issue
|
|
8
|
+
that contains credentials, custody paths, authentication headers, private
|
|
9
|
+
account identifiers, or exploit details for an unpatched vulnerability.
|
|
10
|
+
|
|
11
|
+
The broker does not defend against a compromised root account or modified
|
|
12
|
+
operating system. Legacy same-user dotenv vaults and arbitrary command runners
|
|
13
|
+
are operator compatibility surfaces, not agent isolation boundaries.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "noldorian"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Agent-safe discovery and policy-bound use of local credential capabilities"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Everplay-Tech LLC" }]
|
|
14
|
+
keywords = ["agents", "credentials", "mcp", "security", "secrets", "unix-socket"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: Apache Software License",
|
|
20
|
+
"Operating System :: MacOS",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
23
|
+
"Topic :: Security",
|
|
24
|
+
"Topic :: System :: Systems Administration",
|
|
25
|
+
]
|
|
26
|
+
dependencies = []
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
noldorian = "noldorian.cli:main"
|
|
30
|
+
noldorian-mcp = "noldorian.mcp:main"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Documentation = "https://github.com/E-TECH-PLAYTECH/noldorian#readme"
|
|
34
|
+
Issues = "https://github.com/E-TECH-PLAYTECH/noldorian/issues"
|
|
35
|
+
Repository = "https://github.com/E-TECH-PLAYTECH/noldorian"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["src/noldorian"]
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.sdist]
|
|
41
|
+
include = [
|
|
42
|
+
"/src/noldorian",
|
|
43
|
+
"/tests",
|
|
44
|
+
"/README.md",
|
|
45
|
+
"/LICENSE",
|
|
46
|
+
"/SECURITY.md",
|
|
47
|
+
"/SECURE_CAPABILITY_BROKER.md",
|
|
48
|
+
"/CONTRIBUTING.md",
|
|
49
|
+
]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Public client surface for the local Noldorian capability broker."""
|
|
2
|
+
|
|
3
|
+
from noldorian.client import BrokerClient, DEFAULT_SOCKET_PATH
|
|
4
|
+
from noldorian.errors import BrokerError
|
|
5
|
+
|
|
6
|
+
__all__ = ["BrokerClient", "BrokerError", "DEFAULT_SOCKET_PATH"]
|
|
7
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Command-line interface for public Noldorian capability operations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Dict, Optional, Sequence
|
|
10
|
+
|
|
11
|
+
from noldorian import __version__
|
|
12
|
+
from noldorian.client import BrokerClient, DEFAULT_SOCKET_PATH
|
|
13
|
+
from noldorian.errors import BrokerError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _json_object(value: str) -> Dict[str, Any]:
|
|
17
|
+
try:
|
|
18
|
+
parsed = json.loads(value)
|
|
19
|
+
except json.JSONDecodeError as exc:
|
|
20
|
+
raise argparse.ArgumentTypeError("must be valid JSON") from exc
|
|
21
|
+
if not isinstance(parsed, dict):
|
|
22
|
+
raise argparse.ArgumentTypeError("must decode to a JSON object")
|
|
23
|
+
return parsed
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
27
|
+
parser = argparse.ArgumentParser(
|
|
28
|
+
prog="noldorian",
|
|
29
|
+
description="Query and invoke agent-safe credential capabilities.",
|
|
30
|
+
)
|
|
31
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"--socket",
|
|
34
|
+
type=Path,
|
|
35
|
+
default=DEFAULT_SOCKET_PATH,
|
|
36
|
+
help="broker Unix socket (default: %(default)s)",
|
|
37
|
+
)
|
|
38
|
+
commands = parser.add_subparsers(dest="command", required=True)
|
|
39
|
+
commands.add_parser("status", help="check broker readiness")
|
|
40
|
+
commands.add_parser("list", help="list public credential capabilities")
|
|
41
|
+
|
|
42
|
+
describe = commands.add_parser("describe", help="describe one capability")
|
|
43
|
+
describe.add_argument("capability_id")
|
|
44
|
+
|
|
45
|
+
invoke = commands.add_parser("invoke", help="invoke an approved capability operation")
|
|
46
|
+
invoke.add_argument("capability_id")
|
|
47
|
+
invoke.add_argument("operation")
|
|
48
|
+
invoke.add_argument("--arguments-json", type=_json_object, default={})
|
|
49
|
+
return parser
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def main(argv: Optional[Sequence[str]] = None) -> int:
|
|
53
|
+
args = build_parser().parse_args(argv)
|
|
54
|
+
client = BrokerClient(args.socket)
|
|
55
|
+
try:
|
|
56
|
+
if args.command == "status":
|
|
57
|
+
result = client.status()
|
|
58
|
+
elif args.command == "list":
|
|
59
|
+
result = client.list_capabilities()
|
|
60
|
+
elif args.command == "describe":
|
|
61
|
+
result = client.describe(args.capability_id)
|
|
62
|
+
else:
|
|
63
|
+
result = client.invoke(
|
|
64
|
+
args.capability_id,
|
|
65
|
+
args.operation,
|
|
66
|
+
args.arguments_json,
|
|
67
|
+
)
|
|
68
|
+
except (BrokerError, ValueError) as exc:
|
|
69
|
+
print(f"noldorian: {exc}", file=sys.stderr)
|
|
70
|
+
return 1
|
|
71
|
+
print(json.dumps(result, indent=2, sort_keys=True))
|
|
72
|
+
return 0
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Unix-socket client for agent-safe credential capabilities.
|
|
2
|
+
|
|
3
|
+
The public client intentionally implements no owner, enrollment, credential
|
|
4
|
+
retrieval, arbitrary command, or raw HTTP methods.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import socket
|
|
12
|
+
import uuid
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any, Dict, Mapping, Optional
|
|
15
|
+
|
|
16
|
+
from noldorian.errors import BrokerError
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DEFAULT_SOCKET_PATH = Path(
|
|
20
|
+
os.environ.get("NOLDORIAN_BROKER_SOCKET", "/var/run/noldorian-key-broker.sock")
|
|
21
|
+
)
|
|
22
|
+
MAX_REQUEST_BYTES = 1024 * 1024
|
|
23
|
+
MAX_RESPONSE_BYTES = 2 * 1024 * 1024
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class BrokerClient:
|
|
27
|
+
"""Query and invoke policy-bound capabilities without accessing secrets."""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
socket_path: Path = DEFAULT_SOCKET_PATH,
|
|
32
|
+
*,
|
|
33
|
+
timeout: float = 120.0,
|
|
34
|
+
) -> None:
|
|
35
|
+
if timeout <= 0:
|
|
36
|
+
raise ValueError("timeout must be greater than zero")
|
|
37
|
+
self.socket_path = Path(socket_path)
|
|
38
|
+
self.timeout = timeout
|
|
39
|
+
|
|
40
|
+
def _request(self, action: str, **params: Any) -> Dict[str, Any]:
|
|
41
|
+
if action not in {"status", "list", "describe", "invoke"}:
|
|
42
|
+
raise BrokerError(f"unsupported public broker action: {action}")
|
|
43
|
+
request_id = uuid.uuid4().hex
|
|
44
|
+
payload = {"id": request_id, "action": action, **params}
|
|
45
|
+
encoded = (json.dumps(payload, separators=(",", ":")) + "\n").encode("utf-8")
|
|
46
|
+
if len(encoded) > MAX_REQUEST_BYTES:
|
|
47
|
+
raise BrokerError("broker request exceeds 1 MiB")
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client:
|
|
51
|
+
client.settimeout(self.timeout)
|
|
52
|
+
client.connect(str(self.socket_path))
|
|
53
|
+
client.sendall(encoded)
|
|
54
|
+
chunks = bytearray()
|
|
55
|
+
while b"\n" not in chunks:
|
|
56
|
+
block = client.recv(65536)
|
|
57
|
+
if not block:
|
|
58
|
+
break
|
|
59
|
+
chunks.extend(block)
|
|
60
|
+
if len(chunks) > MAX_RESPONSE_BYTES:
|
|
61
|
+
raise BrokerError("broker response exceeds 2 MiB")
|
|
62
|
+
except (FileNotFoundError, ConnectionRefusedError) as exc:
|
|
63
|
+
raise BrokerError(
|
|
64
|
+
f"Noldorian broker is unavailable at {self.socket_path}"
|
|
65
|
+
) from exc
|
|
66
|
+
except OSError as exc:
|
|
67
|
+
raise BrokerError(f"Noldorian broker request failed: {exc}") from exc
|
|
68
|
+
|
|
69
|
+
line = bytes(chunks).split(b"\n", 1)[0]
|
|
70
|
+
try:
|
|
71
|
+
response = json.loads(line.decode("utf-8"))
|
|
72
|
+
except (UnicodeDecodeError, json.JSONDecodeError) as exc:
|
|
73
|
+
raise BrokerError("Noldorian broker returned an invalid response") from exc
|
|
74
|
+
if not isinstance(response, dict) or response.get("id") != request_id:
|
|
75
|
+
raise BrokerError("Noldorian broker response id mismatch")
|
|
76
|
+
if not response.get("ok"):
|
|
77
|
+
raise BrokerError(str(response.get("error", "broker request failed")))
|
|
78
|
+
result = response.get("result")
|
|
79
|
+
if not isinstance(result, dict):
|
|
80
|
+
raise BrokerError("Noldorian broker returned a non-object result")
|
|
81
|
+
return result
|
|
82
|
+
|
|
83
|
+
def status(self) -> Dict[str, Any]:
|
|
84
|
+
"""Return broker readiness and non-secret service metadata."""
|
|
85
|
+
|
|
86
|
+
return self._request("status")
|
|
87
|
+
|
|
88
|
+
def list_capabilities(self) -> Dict[str, Any]:
|
|
89
|
+
"""Return public capability metadata and availability."""
|
|
90
|
+
|
|
91
|
+
return self._request("list")
|
|
92
|
+
|
|
93
|
+
def describe(self, capability_id: str) -> Dict[str, Any]:
|
|
94
|
+
"""Describe one capability without exposing its custody details."""
|
|
95
|
+
|
|
96
|
+
if not capability_id.strip():
|
|
97
|
+
raise ValueError("capability_id must not be empty")
|
|
98
|
+
return self._request("describe", capability_id=capability_id)
|
|
99
|
+
|
|
100
|
+
def invoke(
|
|
101
|
+
self,
|
|
102
|
+
capability_id: str,
|
|
103
|
+
operation: str,
|
|
104
|
+
arguments: Optional[Mapping[str, Any]] = None,
|
|
105
|
+
) -> Dict[str, Any]:
|
|
106
|
+
"""Invoke one operation already authorized by the owner policy."""
|
|
107
|
+
|
|
108
|
+
if not capability_id.strip():
|
|
109
|
+
raise ValueError("capability_id must not be empty")
|
|
110
|
+
if not operation.strip():
|
|
111
|
+
raise ValueError("operation must not be empty")
|
|
112
|
+
return self._request(
|
|
113
|
+
"invoke",
|
|
114
|
+
capability_id=capability_id,
|
|
115
|
+
operation=operation,
|
|
116
|
+
arguments=dict(arguments or {}),
|
|
117
|
+
)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Zero-dependency MCP server for public Noldorian capability operations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Callable, Dict, Optional, TextIO
|
|
9
|
+
|
|
10
|
+
from noldorian import __version__
|
|
11
|
+
from noldorian.client import BrokerClient, DEFAULT_SOCKET_PATH
|
|
12
|
+
from noldorian.errors import BrokerError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
TOOLS = [
|
|
16
|
+
{
|
|
17
|
+
"name": "broker_status",
|
|
18
|
+
"description": "Check whether the local Noldorian capability broker is ready.",
|
|
19
|
+
"inputSchema": {"type": "object", "properties": {}, "additionalProperties": False},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "list_credential_capabilities",
|
|
23
|
+
"description": (
|
|
24
|
+
"List providers, approved operations, resources, and availability without "
|
|
25
|
+
"returning credential values or custody paths."
|
|
26
|
+
),
|
|
27
|
+
"inputSchema": {"type": "object", "properties": {}, "additionalProperties": False},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "describe_credential_capability",
|
|
31
|
+
"description": "Describe one credential capability without revealing its secret.",
|
|
32
|
+
"inputSchema": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"properties": {"capability_id": {"type": "string", "minLength": 1}},
|
|
35
|
+
"required": ["capability_id"],
|
|
36
|
+
"additionalProperties": False,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "invoke_credential_capability",
|
|
41
|
+
"description": "Invoke one fixed operation approved for a credential capability.",
|
|
42
|
+
"inputSchema": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"capability_id": {"type": "string", "minLength": 1},
|
|
46
|
+
"operation": {"type": "string", "minLength": 1},
|
|
47
|
+
"arguments": {"type": "object"},
|
|
48
|
+
},
|
|
49
|
+
"required": ["capability_id", "operation"],
|
|
50
|
+
"additionalProperties": False,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class McpServer:
|
|
57
|
+
"""Small JSON-RPC loop around a public-only :class:`BrokerClient`."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, client: Optional[BrokerClient] = None) -> None:
|
|
60
|
+
self.client = client or BrokerClient(DEFAULT_SOCKET_PATH)
|
|
61
|
+
self.dispatch: Dict[str, Callable[[Dict[str, Any]], Dict[str, Any]]] = {
|
|
62
|
+
"broker_status": lambda _args: self.client.status(),
|
|
63
|
+
"list_credential_capabilities": lambda _args: self.client.list_capabilities(),
|
|
64
|
+
"describe_credential_capability": self._describe,
|
|
65
|
+
"invoke_credential_capability": self._invoke,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
def _describe(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
69
|
+
capability_id = args.get("capability_id")
|
|
70
|
+
if not isinstance(capability_id, str) or not capability_id.strip():
|
|
71
|
+
raise BrokerError("capability_id is required")
|
|
72
|
+
return self.client.describe(capability_id)
|
|
73
|
+
|
|
74
|
+
def _invoke(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
75
|
+
capability_id = args.get("capability_id")
|
|
76
|
+
operation = args.get("operation")
|
|
77
|
+
arguments = args.get("arguments") or {}
|
|
78
|
+
if not isinstance(capability_id, str) or not capability_id.strip():
|
|
79
|
+
raise BrokerError("capability_id is required")
|
|
80
|
+
if not isinstance(operation, str) or not operation.strip():
|
|
81
|
+
raise BrokerError("operation is required")
|
|
82
|
+
if not isinstance(arguments, dict):
|
|
83
|
+
raise BrokerError("arguments must be an object")
|
|
84
|
+
return self.client.invoke(capability_id, operation, arguments)
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def _reply(output: TextIO, message_id: Any, *, result: Any = None, error: Any = None) -> None:
|
|
88
|
+
response: Dict[str, Any] = {"jsonrpc": "2.0", "id": message_id}
|
|
89
|
+
if error is not None:
|
|
90
|
+
response["error"] = error
|
|
91
|
+
else:
|
|
92
|
+
response["result"] = result
|
|
93
|
+
output.write(json.dumps(response, separators=(",", ":")) + "\n")
|
|
94
|
+
output.flush()
|
|
95
|
+
|
|
96
|
+
def serve(self, input_stream: TextIO, output_stream: TextIO) -> None:
|
|
97
|
+
for raw in input_stream:
|
|
98
|
+
try:
|
|
99
|
+
message = json.loads(raw)
|
|
100
|
+
except json.JSONDecodeError:
|
|
101
|
+
continue
|
|
102
|
+
method = message.get("method")
|
|
103
|
+
message_id = message.get("id")
|
|
104
|
+
if method == "initialize":
|
|
105
|
+
self._reply(
|
|
106
|
+
output_stream,
|
|
107
|
+
message_id,
|
|
108
|
+
result={
|
|
109
|
+
"protocolVersion": message.get("params", {}).get(
|
|
110
|
+
"protocolVersion", "2024-11-05"
|
|
111
|
+
),
|
|
112
|
+
"capabilities": {"tools": {}},
|
|
113
|
+
"serverInfo": {"name": "noldorian", "version": __version__},
|
|
114
|
+
"instructions": (
|
|
115
|
+
"List credential capabilities before authenticated work. "
|
|
116
|
+
"Never inspect vaults or request secret values."
|
|
117
|
+
),
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
elif method == "notifications/initialized":
|
|
121
|
+
continue
|
|
122
|
+
elif method == "tools/list":
|
|
123
|
+
self._reply(output_stream, message_id, result={"tools": TOOLS})
|
|
124
|
+
elif method == "tools/call":
|
|
125
|
+
params = message.get("params") or {}
|
|
126
|
+
function = self.dispatch.get(params.get("name"))
|
|
127
|
+
if function is None:
|
|
128
|
+
self._reply(
|
|
129
|
+
output_stream,
|
|
130
|
+
message_id,
|
|
131
|
+
error={"code": -32602, "message": "unknown tool"},
|
|
132
|
+
)
|
|
133
|
+
continue
|
|
134
|
+
try:
|
|
135
|
+
result = function(params.get("arguments") or {})
|
|
136
|
+
except BrokerError as exc:
|
|
137
|
+
result = {"error": str(exc)}
|
|
138
|
+
except Exception as exc: # noqa: BLE001 - fail closed without details
|
|
139
|
+
result = {"error": f"{type(exc).__name__}: broker request failed"}
|
|
140
|
+
self._reply(
|
|
141
|
+
output_stream,
|
|
142
|
+
message_id,
|
|
143
|
+
result={
|
|
144
|
+
"content": [{"type": "text", "text": json.dumps(result, indent=2)}],
|
|
145
|
+
"isError": bool(result.get("error")),
|
|
146
|
+
},
|
|
147
|
+
)
|
|
148
|
+
elif message_id is not None:
|
|
149
|
+
self._reply(
|
|
150
|
+
output_stream,
|
|
151
|
+
message_id,
|
|
152
|
+
error={"code": -32601, "message": "method not supported"},
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def main() -> None:
|
|
157
|
+
"""Run the Noldorian MCP server over standard input/output."""
|
|
158
|
+
|
|
159
|
+
McpServer().serve(sys.stdin, sys.stdout)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if __name__ == "__main__":
|
|
163
|
+
main()
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
import json
|
|
5
|
+
import unittest
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from noldorian.client import BrokerClient
|
|
9
|
+
from noldorian.errors import BrokerError
|
|
10
|
+
from noldorian.mcp import McpServer, TOOLS
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class StubClient(BrokerClient):
|
|
14
|
+
def __init__(self) -> None:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
def status(self) -> dict[str, object]:
|
|
18
|
+
return {"ready": True}
|
|
19
|
+
|
|
20
|
+
def list_capabilities(self) -> dict[str, object]:
|
|
21
|
+
return {"capabilities": [{"id": "example.capability", "available": True}]}
|
|
22
|
+
|
|
23
|
+
def describe(self, capability_id: str) -> dict[str, object]:
|
|
24
|
+
return {"id": capability_id, "available": True}
|
|
25
|
+
|
|
26
|
+
def invoke(
|
|
27
|
+
self,
|
|
28
|
+
capability_id: str,
|
|
29
|
+
operation: str,
|
|
30
|
+
arguments: dict[str, object] | None = None,
|
|
31
|
+
) -> dict[str, object]:
|
|
32
|
+
return {
|
|
33
|
+
"capability_id": capability_id,
|
|
34
|
+
"operation": operation,
|
|
35
|
+
"arguments": arguments or {},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class PublicSurfaceTests(unittest.TestCase):
|
|
40
|
+
def test_client_refuses_owner_and_secret_actions(self) -> None:
|
|
41
|
+
client = BrokerClient(Path("/tmp/not-used"))
|
|
42
|
+
for action in ("enroll", "register", "import_env", "get_secret", "shell"):
|
|
43
|
+
with self.assertRaises(BrokerError):
|
|
44
|
+
client._request(action)
|
|
45
|
+
|
|
46
|
+
def test_mcp_exposes_only_public_operations(self) -> None:
|
|
47
|
+
names = {tool["name"] for tool in TOOLS}
|
|
48
|
+
self.assertEqual(
|
|
49
|
+
names,
|
|
50
|
+
{
|
|
51
|
+
"broker_status",
|
|
52
|
+
"list_credential_capabilities",
|
|
53
|
+
"describe_credential_capability",
|
|
54
|
+
"invoke_credential_capability",
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
serialized = json.dumps(TOOLS).lower()
|
|
58
|
+
for forbidden in ("enroll", "register", "get_secret", "clipboard", "shell"):
|
|
59
|
+
self.assertNotIn(forbidden, serialized)
|
|
60
|
+
|
|
61
|
+
def test_mcp_round_trip_contains_no_internal_exception_detail(self) -> None:
|
|
62
|
+
requests = io.StringIO(
|
|
63
|
+
json.dumps({"jsonrpc": "2.0", "id": 1, "method": "tools/list"}) + "\n"
|
|
64
|
+
+ json.dumps(
|
|
65
|
+
{
|
|
66
|
+
"jsonrpc": "2.0",
|
|
67
|
+
"id": 2,
|
|
68
|
+
"method": "tools/call",
|
|
69
|
+
"params": {
|
|
70
|
+
"name": "invoke_credential_capability",
|
|
71
|
+
"arguments": {
|
|
72
|
+
"capability_id": "example.capability",
|
|
73
|
+
"operation": "example.run",
|
|
74
|
+
"arguments": {"value": "public"},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
+ "\n"
|
|
80
|
+
)
|
|
81
|
+
responses = io.StringIO()
|
|
82
|
+
McpServer(StubClient()).serve(requests, responses)
|
|
83
|
+
lines = [json.loads(line) for line in responses.getvalue().splitlines()]
|
|
84
|
+
self.assertEqual(lines[0]["result"]["tools"], TOOLS)
|
|
85
|
+
self.assertFalse(lines[1]["result"]["isError"])
|
|
86
|
+
self.assertIn("example.run", lines[1]["result"]["content"][0]["text"])
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
unittest.main()
|