@ggui-ai/mcp-server 0.1.0-rc.1
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 +201 -0
- package/README.md +48 -0
- package/dist/admin-blueprints-transport.d.ts +114 -0
- package/dist/admin-blueprints-transport.d.ts.map +1 -0
- package/dist/admin-blueprints-transport.js +118 -0
- package/dist/admin-oauth-providers-transport.d.ts +40 -0
- package/dist/admin-oauth-providers-transport.d.ts.map +1 -0
- package/dist/admin-oauth-providers-transport.js +263 -0
- package/dist/auth.d.ts +39 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +75 -0
- package/dist/build-mcp.d.ts +128 -0
- package/dist/build-mcp.d.ts.map +1 -0
- package/dist/build-mcp.js +113 -0
- package/dist/code-store-fs.d.ts +19 -0
- package/dist/code-store-fs.d.ts.map +1 -0
- package/dist/code-store-fs.js +98 -0
- package/dist/console-auth.d.ts +139 -0
- package/dist/console-auth.d.ts.map +1 -0
- package/dist/console-auth.js +102 -0
- package/dist/console-cache.d.ts +78 -0
- package/dist/console-cache.d.ts.map +1 -0
- package/dist/console-cache.js +105 -0
- package/dist/console-headers.d.ts +124 -0
- package/dist/console-headers.d.ts.map +1 -0
- package/dist/console-headers.js +49 -0
- package/dist/console-llm-trace.d.ts +66 -0
- package/dist/console-llm-trace.d.ts.map +1 -0
- package/dist/console-llm-trace.js +105 -0
- package/dist/console-payloads.d.ts +67 -0
- package/dist/console-payloads.d.ts.map +1 -0
- package/dist/console-payloads.js +105 -0
- package/dist/console-theme-routes.d.ts +111 -0
- package/dist/console-theme-routes.d.ts.map +1 -0
- package/dist/console-theme-routes.js +202 -0
- package/dist/console-timeline.d.ts +45 -0
- package/dist/console-timeline.d.ts.map +1 -0
- package/dist/console-timeline.js +169 -0
- package/dist/console-validator.d.ts +67 -0
- package/dist/console-validator.d.ts.map +1 -0
- package/dist/console-validator.js +105 -0
- package/dist/console-welcome.d.ts +7 -0
- package/dist/console-welcome.d.ts.map +1 -0
- package/dist/console-welcome.js +221 -0
- package/dist/csrf-middleware.d.ts +55 -0
- package/dist/csrf-middleware.d.ts.map +1 -0
- package/dist/csrf-middleware.js +138 -0
- package/dist/email-login.d.ts +174 -0
- package/dist/email-login.d.ts.map +1 -0
- package/dist/email-login.js +254 -0
- package/dist/email-resend.d.ts +29 -0
- package/dist/email-resend.d.ts.map +1 -0
- package/dist/email-resend.js +71 -0
- package/dist/email-sender-from-env.d.ts +34 -0
- package/dist/email-sender-from-env.d.ts.map +1 -0
- package/dist/email-sender-from-env.js +112 -0
- package/dist/email-smtp.d.ts +42 -0
- package/dist/email-smtp.d.ts.map +1 -0
- package/dist/email-smtp.js +81 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/instructions-presets.d.ts +112 -0
- package/dist/instructions-presets.d.ts.map +1 -0
- package/dist/instructions-presets.js +195 -0
- package/dist/llm-backed-negotiator.d.ts +178 -0
- package/dist/llm-backed-negotiator.d.ts.map +1 -0
- package/dist/llm-backed-negotiator.js +579 -0
- package/dist/logger.d.ts +23 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +41 -0
- package/dist/mcp-apps-inbound.d.ts +86 -0
- package/dist/mcp-apps-inbound.d.ts.map +1 -0
- package/dist/mcp-apps-inbound.js +278 -0
- package/dist/mcp-apps-outbound.d.ts +448 -0
- package/dist/mcp-apps-outbound.d.ts.map +1 -0
- package/dist/mcp-apps-outbound.js +1163 -0
- package/dist/mcp-mounts.d.ts +239 -0
- package/dist/mcp-mounts.d.ts.map +1 -0
- package/dist/mcp-mounts.js +222 -0
- package/dist/oauth-login-types.d.ts +160 -0
- package/dist/oauth-login-types.d.ts.map +1 -0
- package/dist/oauth-login-types.js +9 -0
- package/dist/oauth-login.d.ts +77 -0
- package/dist/oauth-login.d.ts.map +1 -0
- package/dist/oauth-login.js +455 -0
- package/dist/oauth-providers/github.d.ts +17 -0
- package/dist/oauth-providers/github.d.ts.map +1 -0
- package/dist/oauth-providers/github.js +89 -0
- package/dist/oauth-providers/google.d.ts +18 -0
- package/dist/oauth-providers/google.d.ts.map +1 -0
- package/dist/oauth-providers/google.js +59 -0
- package/dist/oauth-providers-store.d.ts +32 -0
- package/dist/oauth-providers-store.d.ts.map +1 -0
- package/dist/oauth-providers-store.js +291 -0
- package/dist/oauth.d.ts +347 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +686 -0
- package/dist/pairing-transport.d.ts +99 -0
- package/dist/pairing-transport.d.ts.map +1 -0
- package/dist/pairing-transport.js +223 -0
- package/dist/rate-limit-middleware.d.ts +36 -0
- package/dist/rate-limit-middleware.d.ts.map +1 -0
- package/dist/rate-limit-middleware.js +57 -0
- package/dist/render-gate.d.ts +87 -0
- package/dist/render-gate.d.ts.map +1 -0
- package/dist/render-gate.js +77 -0
- package/dist/render-rate-limit.d.ts +59 -0
- package/dist/render-rate-limit.d.ts.map +1 -0
- package/dist/render-rate-limit.js +73 -0
- package/dist/render-signing.d.ts +98 -0
- package/dist/render-signing.d.ts.map +1 -0
- package/dist/render-signing.js +113 -0
- package/dist/request-context.d.ts +113 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/request-context.js +154 -0
- package/dist/reserved-validators.d.ts +22 -0
- package/dist/reserved-validators.d.ts.map +1 -0
- package/dist/reserved-validators.js +101 -0
- package/dist/schema-compat.d.ts +167 -0
- package/dist/schema-compat.d.ts.map +1 -0
- package/dist/schema-compat.js +187 -0
- package/dist/security-headers-middleware.d.ts +38 -0
- package/dist/security-headers-middleware.d.ts.map +1 -0
- package/dist/security-headers-middleware.js +30 -0
- package/dist/server.d.ts +2060 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +6338 -0
- package/dist/session-channel.d.ts +651 -0
- package/dist/session-channel.d.ts.map +1 -0
- package/dist/session-channel.js +1756 -0
- package/dist/storage.d.ts +89 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +171 -0
- package/dist/thread-transport.d.ts +118 -0
- package/dist/thread-transport.d.ts.map +1 -0
- package/dist/thread-transport.js +478 -0
- package/dist/user-session-auth.d.ts +167 -0
- package/dist/user-session-auth.d.ts.map +1 -0
- package/dist/user-session-auth.js +148 -0
- package/package.json +76 -0
package/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 describing the origin of the Work and
|
|
141
|
+
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 Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
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 Loqu, Inc. (Guuey)
|
|
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
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @ggui-ai/mcp-server
|
|
2
|
+
|
|
3
|
+
Self-hosted [MCP](https://modelcontextprotocol.io) server for the **ggui protocol** —
|
|
4
|
+
the interface layer that lets AI agents describe UIs in natural language and have
|
|
5
|
+
ggui generate ephemeral interfaces for them.
|
|
6
|
+
|
|
7
|
+
This package is the HTTP/MCP binding layer. It composes
|
|
8
|
+
[`@ggui-ai/mcp-server-handlers`](https://www.npmjs.com/package/@ggui-ai/mcp-server-handlers)
|
|
9
|
+
(the tool handler logic) with the reference adapters from
|
|
10
|
+
[`@ggui-ai/mcp-server-core`](https://www.npmjs.com/package/@ggui-ai/mcp-server-core)
|
|
11
|
+
(in-memory, SQLite, and filesystem storage) to produce a runnable server. No business
|
|
12
|
+
logic lives here — to change tool behavior, edit the handler package.
|
|
13
|
+
|
|
14
|
+
## Run it with the CLI
|
|
15
|
+
|
|
16
|
+
The simplest way to start a server is the `ggui` CLI shipped by `@ggui-ai/cli`:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx @ggui-ai/cli serve
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`ggui serve` boots this package with the OSS defaults — in-memory session store
|
|
23
|
+
(or SQLite when `better-sqlite3` is installed), no-auth dev posture, and every UI
|
|
24
|
+
declared in `ggui.json` surfaced through the blueprint tools.
|
|
25
|
+
|
|
26
|
+
## Embed it directly
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createGguiServer } from "@ggui-ai/mcp-server";
|
|
30
|
+
|
|
31
|
+
const server = createGguiServer();
|
|
32
|
+
await server.listen(4567);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`createGguiServer` accepts a `CreateGguiServerOptions` bundle to swap in your own
|
|
36
|
+
auth adapter, storage backends, blueprint provider, rate limiter, and more. Every
|
|
37
|
+
seam is an interface from `@ggui-ai/mcp-server-core`, so production deployments bind
|
|
38
|
+
their own implementations without forking this package.
|
|
39
|
+
|
|
40
|
+
## Scope
|
|
41
|
+
|
|
42
|
+
This package deliberately does **not** embed cloud-specific wiring (AWS, DynamoDB,
|
|
43
|
+
Redis), and it does not implement authoring, pairing, or UI generation — those are
|
|
44
|
+
separate packages and protocol flows.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
Apache-2.0
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin blueprints transport — `POST /admin/blueprints` route that
|
|
3
|
+
* registers a runtime manifest into the active {@link BlueprintProvider}.
|
|
4
|
+
*
|
|
5
|
+
* Enables runtime blueprint registration. Before this transport the
|
|
6
|
+
* only way to seed a blueprint was declarative via
|
|
7
|
+
* `ggui.json#blueprints.include`; registration at runtime was
|
|
8
|
+
* unreachable.
|
|
9
|
+
*
|
|
10
|
+
* One route:
|
|
11
|
+
*
|
|
12
|
+
* POST /admin/blueprints — admin. Bearer auth → builder only.
|
|
13
|
+
* Body: {id, name, description?,
|
|
14
|
+
* category?, tags?, updatedAt?}.
|
|
15
|
+
* Calls `provider.addManifest()` if
|
|
16
|
+
* the bound provider exposes it;
|
|
17
|
+
* returns `{ok: true, id}` on success.
|
|
18
|
+
*
|
|
19
|
+
* ## Persistence
|
|
20
|
+
*
|
|
21
|
+
* **In-memory only.** Runtime-registered manifests survive until
|
|
22
|
+
* the server process exits. Rationale:
|
|
23
|
+
*
|
|
24
|
+
* - Persisting to `ggui.json` means rewriting an operator-owned
|
|
25
|
+
* file on mutation (surprising at best, dangerous at worst —
|
|
26
|
+
* the file is usually committed to source control).
|
|
27
|
+
* - Persisting to a sidecar file (`~/.ggui/blueprints.json`) adds
|
|
28
|
+
* file-atomic-write + concurrency + schema-validation surface
|
|
29
|
+
* that isn't load-bearing for Q6's "register blueprints"
|
|
30
|
+
* promise.
|
|
31
|
+
* - Plan doc explicitly permits this choice: "Or: keep runtime
|
|
32
|
+
* regs in-memory only — decision in slice, default to
|
|
33
|
+
* persistence."
|
|
34
|
+
*
|
|
35
|
+
* A follow-up slice can add disk persistence if operators ask for
|
|
36
|
+
* it; this transport's contract doesn't change (the route is
|
|
37
|
+
* still `POST /admin/blueprints` with the same body shape).
|
|
38
|
+
*
|
|
39
|
+
* ## Provider capability negotiation
|
|
40
|
+
*
|
|
41
|
+
* The narrowed `BlueprintProvider` interface (`list` + `get` only,
|
|
42
|
+
* per 2026-04-18 registry-source architecture lock) has no
|
|
43
|
+
* mutation surface. `addManifest()` is an impl-specific affordance
|
|
44
|
+
* on {@link ManifestBlueprintProvider}. At mount time this module
|
|
45
|
+
* checks for the method structurally and returns 501 Not
|
|
46
|
+
* Implemented when absent — so operators running a
|
|
47
|
+
* provider that genuinely can't accept runtime registrations
|
|
48
|
+
* (e.g., a future `DynamoBlueprintProvider` backed by an external
|
|
49
|
+
* catalog) see a clean error rather than a mysterious 500.
|
|
50
|
+
*
|
|
51
|
+
* ## Error mapping
|
|
52
|
+
*
|
|
53
|
+
* - Missing / malformed body → 400 {code: 'bad_request'}.
|
|
54
|
+
* - Unauthenticated → 401 {code: 'unauthenticated'}.
|
|
55
|
+
* - Non-builder identity → 403 {code: 'forbidden'}.
|
|
56
|
+
* - Provider without `addManifest` → 501 {code: 'not_supported'}.
|
|
57
|
+
* - Unexpected thrown → 500 {code: 'internal'}.
|
|
58
|
+
*
|
|
59
|
+
* Routes are mounted on the same Express app the server already
|
|
60
|
+
* owns — no sub-router, same `/admin/*` firewall convention as
|
|
61
|
+
* pairing.
|
|
62
|
+
*/
|
|
63
|
+
import type { Express } from 'express';
|
|
64
|
+
import type { AuthAdapter, BlueprintProvider } from '@ggui-ai/mcp-server-core';
|
|
65
|
+
import type { Logger } from './logger.js';
|
|
66
|
+
/**
|
|
67
|
+
* Default URL path the admin-blueprints route is mounted at. Sits
|
|
68
|
+
* under the same `/admin/` prefix as `/admin/pair/init` so one
|
|
69
|
+
* firewall rule gates the whole admin surface.
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFAULT_ADMIN_BLUEPRINTS_PATH = "/admin/blueprints";
|
|
72
|
+
/**
|
|
73
|
+
* Structural subset of {@link ManifestBlueprintProvider.addManifest}.
|
|
74
|
+
* Duck-typed so this module stays decoupled from the in-memory
|
|
75
|
+
* impl-class import — any {@link BlueprintProvider} that carries an
|
|
76
|
+
* `addManifest` method with the declared shape works.
|
|
77
|
+
*/
|
|
78
|
+
export interface ManifestRegistrable {
|
|
79
|
+
addManifest(manifest: {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
category?: string;
|
|
84
|
+
tags?: readonly string[];
|
|
85
|
+
updatedAt?: string;
|
|
86
|
+
}): void;
|
|
87
|
+
}
|
|
88
|
+
/** Narrow type guard — does the provider accept runtime registrations? */
|
|
89
|
+
export declare function providerAcceptsManifests(provider: BlueprintProvider): provider is BlueprintProvider & ManifestRegistrable;
|
|
90
|
+
export interface AdminBlueprintsTransportOptions {
|
|
91
|
+
/** Required. The provider runtime registrations land on. */
|
|
92
|
+
readonly provider: BlueprintProvider;
|
|
93
|
+
/**
|
|
94
|
+
* Required. Same AuthAdapter the `/mcp` + pairing endpoints use.
|
|
95
|
+
* Gates the route; MUST resolve to a `builder` identity for
|
|
96
|
+
* registration to succeed.
|
|
97
|
+
*/
|
|
98
|
+
readonly auth: AuthAdapter;
|
|
99
|
+
/** Structured logger; a per-route child is derived. */
|
|
100
|
+
readonly logger: Logger;
|
|
101
|
+
/**
|
|
102
|
+
* URL path the route is mounted at. Defaults to
|
|
103
|
+
* {@link DEFAULT_ADMIN_BLUEPRINTS_PATH}. Pass `null` to disable
|
|
104
|
+
* the route — operators who want the server but not the admin
|
|
105
|
+
* HTTP surface.
|
|
106
|
+
*/
|
|
107
|
+
readonly path?: string | null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Mount the admin-blueprints route onto an existing Express app.
|
|
111
|
+
* Call once per server; mounting twice registers the route twice.
|
|
112
|
+
*/
|
|
113
|
+
export declare function mountAdminBlueprintsTransport(app: Express, opts: AdminBlueprintsTransportOptions): void;
|
|
114
|
+
//# sourceMappingURL=admin-blueprints-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-blueprints-transport.d.ts","sourceRoot":"","sources":["../src/admin-blueprints-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,QAAQ,EAAE;QACpB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,IAAI,CAAC;CACV;AAED,0EAA0E;AAC1E,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,iBAAiB,GAC1B,QAAQ,IAAI,iBAAiB,GAAG,mBAAmB,CAIrD;AAED,MAAM,WAAW,+BAA+B;IAC9C,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,+BAA+B,GACpC,IAAI,CA8GN"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { resolveIdentity, UnauthenticatedError } from './auth.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default URL path the admin-blueprints route is mounted at. Sits
|
|
4
|
+
* under the same `/admin/` prefix as `/admin/pair/init` so one
|
|
5
|
+
* firewall rule gates the whole admin surface.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_ADMIN_BLUEPRINTS_PATH = '/admin/blueprints';
|
|
8
|
+
/** Narrow type guard — does the provider accept runtime registrations? */
|
|
9
|
+
export function providerAcceptsManifests(provider) {
|
|
10
|
+
return (typeof provider.addManifest === 'function');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Mount the admin-blueprints route onto an existing Express app.
|
|
14
|
+
* Call once per server; mounting twice registers the route twice.
|
|
15
|
+
*/
|
|
16
|
+
export function mountAdminBlueprintsTransport(app, opts) {
|
|
17
|
+
const path = opts.path === undefined ? DEFAULT_ADMIN_BLUEPRINTS_PATH : opts.path;
|
|
18
|
+
if (path === null)
|
|
19
|
+
return;
|
|
20
|
+
const capable = providerAcceptsManifests(opts.provider);
|
|
21
|
+
if (!capable) {
|
|
22
|
+
opts.logger.info('admin_blueprints_not_supported', {
|
|
23
|
+
reason: 'bound BlueprintProvider does not expose addManifest; route will return 501 on hit',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
app.post(path, async (req, res) => {
|
|
27
|
+
const reqLogger = opts.logger.child({ route: 'POST ' + path });
|
|
28
|
+
// 1. Auth. Same builder-only gate as /admin/pair/init.
|
|
29
|
+
try {
|
|
30
|
+
const identity = await resolveIdentity(opts.auth, req);
|
|
31
|
+
if (identity.identity.kind !== 'builder') {
|
|
32
|
+
reqLogger.warn('admin_blueprints_forbidden', {
|
|
33
|
+
identityKind: identity.identity.kind,
|
|
34
|
+
});
|
|
35
|
+
res.status(403).json({
|
|
36
|
+
error: {
|
|
37
|
+
code: 'forbidden',
|
|
38
|
+
message: `POST ${path} requires a builder identity.`,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (err instanceof UnauthenticatedError) {
|
|
46
|
+
reqLogger.warn('admin_blueprints_unauthenticated', { reason: err.message });
|
|
47
|
+
res.status(401).json({
|
|
48
|
+
error: { code: 'unauthenticated', message: err.message },
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
reqLogger.error('admin_blueprints_unexpected_error', { error: String(err) });
|
|
53
|
+
res.status(500).json({ error: { code: 'internal', message: 'Internal server error' } });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// 2. Body validation. Minimum shape: {id: string, name: string}.
|
|
57
|
+
// Optional fields: description, category, tags (string[]),
|
|
58
|
+
// updatedAt (ISO string). Anything else is ignored.
|
|
59
|
+
const body = (req.body ?? {});
|
|
60
|
+
const id = typeof body['id'] === 'string' ? body['id'] : undefined;
|
|
61
|
+
const name = typeof body['name'] === 'string' ? body['name'] : undefined;
|
|
62
|
+
if (!id || !name) {
|
|
63
|
+
reqLogger.debug?.('admin_blueprints_bad_request', {
|
|
64
|
+
hasId: id !== undefined,
|
|
65
|
+
hasName: name !== undefined,
|
|
66
|
+
});
|
|
67
|
+
res.status(400).json({
|
|
68
|
+
error: {
|
|
69
|
+
code: 'bad_request',
|
|
70
|
+
message: `POST ${path} requires a JSON body with non-empty string \`id\` and \`name\`.`,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Optionals — narrow strictly; silently drop fields that don't
|
|
76
|
+
// match. Duck-typed body-to-manifest shape matches the
|
|
77
|
+
// ManifestBlueprintSeed contract in @ggui-ai/mcp-server-core.
|
|
78
|
+
const description = typeof body['description'] === 'string' ? body['description'] : undefined;
|
|
79
|
+
const category = typeof body['category'] === 'string' ? body['category'] : undefined;
|
|
80
|
+
const updatedAt = typeof body['updatedAt'] === 'string' ? body['updatedAt'] : undefined;
|
|
81
|
+
const tags = Array.isArray(body['tags'])
|
|
82
|
+
? body['tags'].filter((t) => typeof t === 'string')
|
|
83
|
+
: undefined;
|
|
84
|
+
// 3. Capability check. Performed per-request (not once at mount
|
|
85
|
+
// time) so operators swapping providers in a test harness see
|
|
86
|
+
// current state, not stale mount-time state.
|
|
87
|
+
if (!providerAcceptsManifests(opts.provider)) {
|
|
88
|
+
reqLogger.warn('admin_blueprints_not_supported', { id });
|
|
89
|
+
res.status(501).json({
|
|
90
|
+
error: {
|
|
91
|
+
code: 'not_supported',
|
|
92
|
+
message: 'The bound BlueprintProvider does not accept runtime manifest registrations.',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// 4. Register. In-memory only — addManifest is idempotent per
|
|
98
|
+
// the ManifestBlueprintProvider contract (same id overwrites).
|
|
99
|
+
try {
|
|
100
|
+
opts.provider.addManifest({
|
|
101
|
+
id,
|
|
102
|
+
name,
|
|
103
|
+
...(description !== undefined ? { description } : {}),
|
|
104
|
+
...(category !== undefined ? { category } : {}),
|
|
105
|
+
...(tags !== undefined && tags.length > 0 ? { tags } : {}),
|
|
106
|
+
...(updatedAt !== undefined ? { updatedAt } : {}),
|
|
107
|
+
});
|
|
108
|
+
reqLogger.info('admin_blueprints_registered', { id, name });
|
|
109
|
+
res.status(200).json({ ok: true, id });
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
reqLogger.error('admin_blueprints_failed', { id, error: String(err) });
|
|
113
|
+
res.status(500).json({
|
|
114
|
+
error: { code: 'internal', message: 'Internal server error' },
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin OAuth providers transport.
|
|
3
|
+
*
|
|
4
|
+
* Builder-only REST surface so the operator's `/admin/oauth-providers`
|
|
5
|
+
* page can list, paste, toggle, and delete OAuth provider client
|
|
6
|
+
* credentials. Persistence lives in {@link OAuthProvidersStore} —
|
|
7
|
+
* this module is the HTTP shell around it.
|
|
8
|
+
*
|
|
9
|
+
* Endpoints (all gated on builder identity via the same `resolveIdentity`
|
|
10
|
+
* pattern as `/admin/blueprints`):
|
|
11
|
+
*
|
|
12
|
+
* - `GET /ggui/admin/oauth-providers` → list (clientSecret redacted)
|
|
13
|
+
* - `PUT /ggui/admin/oauth-providers/:providerId` → put (200 redacted record)
|
|
14
|
+
* - `POST /ggui/admin/oauth-providers/:providerId/toggle` → setEnabled (204)
|
|
15
|
+
* - `DELETE /ggui/admin/oauth-providers/:providerId` → remove (204)
|
|
16
|
+
*
|
|
17
|
+
* **clientSecret is NEVER emitted in any response.** The server is
|
|
18
|
+
* the only place a paste-time secret lives — once it's in the file,
|
|
19
|
+
* the API surface only proves it's configured, not what it is.
|
|
20
|
+
*
|
|
21
|
+
* Audit hooks fire on every mutating endpoint. PUT → `auth.oauth-config.write`,
|
|
22
|
+
* toggle → `auth.oauth-config.write`, DELETE → `auth.oauth-config.delete`.
|
|
23
|
+
* Audit sink failures are swallowed so a sink outage never fails the
|
|
24
|
+
* primary action.
|
|
25
|
+
*/
|
|
26
|
+
import type { Express } from 'express';
|
|
27
|
+
import type { AuditSink, AuthAdapter } from '@ggui-ai/mcp-server-core';
|
|
28
|
+
import type { Logger } from './logger.js';
|
|
29
|
+
import type { OAuthProvidersStore } from './oauth-providers-store.js';
|
|
30
|
+
export declare const DEFAULT_ADMIN_OAUTH_PROVIDERS_PATH = "/ggui/admin/oauth-providers";
|
|
31
|
+
export interface AdminOAuthProvidersTransportOptions {
|
|
32
|
+
readonly store: OAuthProvidersStore;
|
|
33
|
+
readonly auth: AuthAdapter;
|
|
34
|
+
readonly logger: Logger;
|
|
35
|
+
readonly auditSink?: AuditSink;
|
|
36
|
+
/** Defaults to {@link DEFAULT_ADMIN_OAUTH_PROVIDERS_PATH}. */
|
|
37
|
+
readonly path?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function mountAdminOAuthProvidersTransport(app: Express, opts: AdminOAuthProvidersTransportOptions): void;
|
|
40
|
+
//# sourceMappingURL=admin-oauth-providers-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-oauth-providers-transport.d.ts","sourceRoot":"","sources":["../src/admin-oauth-providers-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAEV,SAAS,EACT,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,eAAO,MAAM,kCAAkC,gCAAgC,CAAC;AAEhF,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAqCD,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,mCAAmC,GACxC,IAAI,CAiQN"}
|