@cyanmycelium/mcp-broker 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/.mcp-broker.example/README.md +53 -0
- package/.mcp-broker.example/config.json +32 -0
- package/.mcp-broker.example/grammars/claude/fr.json +7 -0
- package/LICENSE +201 -0
- package/README.md +253 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +208 -0
- package/dist/bin.js.map +1 -0
- package/dist/broker/adapters/broker.adapter.info.d.ts +16 -0
- package/dist/broker/adapters/broker.adapter.info.js +43 -0
- package/dist/broker/adapters/broker.adapter.info.js.map +1 -0
- package/dist/broker/adapters/broker.adapter.providers.d.ts +18 -0
- package/dist/broker/adapters/broker.adapter.providers.js +61 -0
- package/dist/broker/adapters/broker.adapter.providers.js.map +1 -0
- package/dist/broker/behaviors/broker.behavior.info.d.ts +15 -0
- package/dist/broker/behaviors/broker.behavior.info.js +41 -0
- package/dist/broker/behaviors/broker.behavior.info.js.map +1 -0
- package/dist/broker/behaviors/broker.behavior.providers.d.ts +19 -0
- package/dist/broker/behaviors/broker.behavior.providers.js +69 -0
- package/dist/broker/behaviors/broker.behavior.providers.js.map +1 -0
- package/dist/broker/broker.context.d.ts +59 -0
- package/dist/broker/broker.context.js +2 -0
- package/dist/broker/broker.context.js.map +1 -0
- package/dist/broker/broker.grammars.d.ts +166 -0
- package/dist/broker/broker.grammars.js +258 -0
- package/dist/broker/broker.grammars.js.map +1 -0
- package/dist/broker/broker.server.d.ts +64 -0
- package/dist/broker/broker.server.js +111 -0
- package/dist/broker/broker.server.js.map +1 -0
- package/dist/broker/grammars/claude/en.json +16 -0
- package/dist/broker/grammars/claude/fr.json +16 -0
- package/dist/broker/grammars/default/en.json +32 -0
- package/dist/broker/grammars/default/fr.json +32 -0
- package/dist/broker/grammars/default/zh.json +32 -0
- package/dist/broker/index.d.ts +9 -0
- package/dist/broker/index.js +7 -0
- package/dist/broker/index.js.map +1 -0
- package/dist/config.d.ts +101 -0
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/stdio.upstream.d.ts +42 -0
- package/dist/stdio.upstream.js +85 -0
- package/dist/stdio.upstream.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +9 -0
- package/dist/version.js.map +1 -0
- package/dist/ws.tunnel.builder.d.ts +133 -0
- package/dist/ws.tunnel.builder.js +197 -0
- package/dist/ws.tunnel.builder.js.map +1 -0
- package/dist/ws.tunnel.d.ts +310 -0
- package/dist/ws.tunnel.js +971 -0
- package/dist/ws.tunnel.js.map +1 -0
- package/package.json +86 -0
- package/scripts/copy-assets.mjs +34 -0
- package/scripts/gen-cert.mjs +94 -0
- package/src/bin.ts +231 -0
- package/src/broker/adapters/broker.adapter.info.ts +46 -0
- package/src/broker/adapters/broker.adapter.providers.ts +67 -0
- package/src/broker/behaviors/broker.behavior.info.ts +46 -0
- package/src/broker/behaviors/broker.behavior.providers.ts +82 -0
- package/src/broker/broker.context.ts +75 -0
- package/src/broker/broker.grammars.ts +336 -0
- package/src/broker/broker.server.ts +168 -0
- package/src/broker/grammars/claude/en.json +16 -0
- package/src/broker/grammars/claude/fr.json +16 -0
- package/src/broker/grammars/default/en.json +32 -0
- package/src/broker/grammars/default/fr.json +32 -0
- package/src/broker/grammars/default/zh.json +32 -0
- package/src/broker/index.ts +24 -0
- package/src/config.ts +155 -0
- package/src/index.ts +26 -0
- package/src/stdio.upstream.ts +114 -0
- package/src/version.ts +10 -0
- package/src/ws.tunnel.builder.ts +214 -0
- package/src/ws.tunnel.ts +1269 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# `.mcp-broker.example/`
|
|
2
|
+
|
|
3
|
+
This is a template. Copy it as `.mcp-broker/` next to where you run the
|
|
4
|
+
broker, then adapt to your needs:
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
cp -r .mcp-broker.example .mcp-broker
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Layout
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
.mcp-broker/
|
|
14
|
+
├── config.json ← broker configuration (port, locale, TLS, mounts, ...)
|
|
15
|
+
├── certs/ ← TLS material (optional, gitignore this)
|
|
16
|
+
│ ├── cert.pem
|
|
17
|
+
│ └── key.pem
|
|
18
|
+
├── grammars/ ← local grammar overrides (optional)
|
|
19
|
+
│ └── <userAgent>/
|
|
20
|
+
│ └── <locale>.json
|
|
21
|
+
└── www/ ← static files served at "/" (optional)
|
|
22
|
+
└── index.html
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Path resolution
|
|
26
|
+
|
|
27
|
+
Paths inside `config.json` are resolved against the **directory of the
|
|
28
|
+
config file** (i.e. `.mcp-broker/`). So `"certs/cert.pem"` in the config
|
|
29
|
+
points at `.mcp-broker/certs/cert.pem`. The folder is self-contained.
|
|
30
|
+
|
|
31
|
+
Env vars (`MCP_BROKER_TLS_CERT`, `MCP_BROKER_WWW_DIR`, ...) are still
|
|
32
|
+
resolved against `process.cwd()` — they are the deploy-time override
|
|
33
|
+
mechanism and not tied to the config file's location.
|
|
34
|
+
|
|
35
|
+
## Grammar overrides
|
|
36
|
+
|
|
37
|
+
Drop a JSON at `grammars/<userAgent>/<locale>.json` to override individual
|
|
38
|
+
tool/resource/template descriptions for that combination. Entries you don't
|
|
39
|
+
override fall back to the packaged defaults shipped with the broker. See
|
|
40
|
+
[`docs/config.md`](../docs/config.md) for the schema.
|
|
41
|
+
|
|
42
|
+
## Suggested `.gitignore`
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
.mcp-broker/certs/
|
|
46
|
+
.mcp-broker/config.json # if it contains environment-specific values
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or, to gitignore the whole folder:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
.mcp-broker/
|
|
53
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"port": 3001,
|
|
3
|
+
"host": "0.0.0.0",
|
|
4
|
+
"locale": "fr",
|
|
5
|
+
"brokerName": "broker-eu-west",
|
|
6
|
+
|
|
7
|
+
"paths": {
|
|
8
|
+
"provider": "/provider",
|
|
9
|
+
"client": "/",
|
|
10
|
+
"mcp": "/mcp"
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
"tls": {
|
|
14
|
+
"cert": "certs/cert.pem",
|
|
15
|
+
"key": "certs/key.pem"
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"www": {
|
|
19
|
+
"open": false,
|
|
20
|
+
"mounts": [
|
|
21
|
+
{ "urlPrefix": "/", "dir": "www" }
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
"stdioUpstreams": [
|
|
26
|
+
{
|
|
27
|
+
"name": "fs",
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/data"]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
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 Guillaume Pelletier (CyanMycelium)
|
|
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,253 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/pandaGaume/mcp-broker/main/docs/assets/logo.png" alt="mcp-broker" width="160" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@cyanmycelium/mcp-broker)
|
|
6
|
+
[](https://github.com/pandaGaume/mcp-broker/actions/workflows/ci-node.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
# @cyanmycelium/mcp-broker
|
|
10
|
+
|
|
11
|
+
WebSocket-based [Model Context Protocol](https://modelcontextprotocol.io/) broker. Aggregates multiple MCP providers behind a single endpoint, with WebSocket, Streamable HTTP, SSE, and stdio client transports.
|
|
12
|
+
|
|
13
|
+
> This is the Node/TypeScript implementation of the broker. Architecture, wire protocol, and roadmap are documented language-neutrally in [../docs](../docs).
|
|
14
|
+
|
|
15
|
+
## Install and run
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
# Run the broker without installing
|
|
19
|
+
npx @cyanmycelium/mcp-broker
|
|
20
|
+
|
|
21
|
+
# Or install globally
|
|
22
|
+
npm install -g @cyanmycelium/mcp-broker
|
|
23
|
+
mcp-broker
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The broker starts on `http://localhost:3000` by default.
|
|
27
|
+
|
|
28
|
+
- Connect your MCP provider to: `ws://localhost:3000/provider/<name>`
|
|
29
|
+
- Point an MCP client at: `http://localhost:3000/<name>/mcp` (Streamable HTTP) or `http://localhost:3000/<name>/sse` (legacy SSE) or `ws://localhost:3000/<name>` (raw WS)
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
Two sources, env vars **always win** over the file. The file is the static baseline you ship with the broker; env vars are deploy-specific overrides.
|
|
34
|
+
|
|
35
|
+
### Option A — `.mcp-broker/` folder (recommended)
|
|
36
|
+
|
|
37
|
+
Drop a `.mcp-broker/` folder next to where you launch the broker. Paths
|
|
38
|
+
inside `config.json` are resolved against this folder, so it stays
|
|
39
|
+
self-contained (certs, www, grammar overrides all next to the config).
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
your-project/
|
|
43
|
+
└── .mcp-broker/
|
|
44
|
+
├── config.json ← broker configuration
|
|
45
|
+
├── certs/ ← TLS material (optional)
|
|
46
|
+
├── grammars/ ← local grammar overrides (optional)
|
|
47
|
+
└── www/ ← static dev harness (optional)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Minimal `config.json`:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"port": 3001,
|
|
55
|
+
"locale": "fr",
|
|
56
|
+
"tls": {
|
|
57
|
+
"cert": "certs/cert.pem",
|
|
58
|
+
"key": "certs/key.pem"
|
|
59
|
+
},
|
|
60
|
+
"www": {
|
|
61
|
+
"open": false,
|
|
62
|
+
"mounts": [{ "urlPrefix": "/", "dir": "www" }]
|
|
63
|
+
},
|
|
64
|
+
"stdioUpstreams": [
|
|
65
|
+
{
|
|
66
|
+
"name": "fs",
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/data"]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Start from the [`.mcp-broker.example/`](.mcp-broker.example/) template:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
cp -r node_modules/@cyanmycelium/mcp-broker/.mcp-broker.example .mcp-broker
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Full reference (every field, defaults, recipes, grammar overrides): **[docs/config.md](docs/config.md)**.
|
|
81
|
+
|
|
82
|
+
### Option B — Environment variables
|
|
83
|
+
|
|
84
|
+
| Variable | Default | Notes |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `MCP_BROKER_CONFIG` | `./.mcp-broker/config.json` | Path to a JSON config file (see above) |
|
|
87
|
+
| `MCP_BROKER_PORT` | `3000` | TCP port to listen on |
|
|
88
|
+
| `MCP_BROKER_HOST` | `0.0.0.0` | Interface to bind |
|
|
89
|
+
| `MCP_BROKER_PROVIDER_PATH` | `/provider` | Prefix for provider WS connections |
|
|
90
|
+
| `MCP_BROKER_CLIENT_PATH` | `/` | Prefix for raw WS clients |
|
|
91
|
+
| `MCP_BROKER_MCP_PATH` | `/mcp` | Suffix for Streamable HTTP |
|
|
92
|
+
| `MCP_BROKER_WWW_DIR` | (unset) | If set, serve this directory at `/` |
|
|
93
|
+
| `MCP_BROKER_BUNDLE_DIR` | (unset) | If set, serve this directory at `/bundle` |
|
|
94
|
+
| `MCP_BROKER_OPEN` | (unset) | `1` to auto-open the browser at the root URL on startup (requires `MCP_BROKER_WWW_DIR`) |
|
|
95
|
+
| `MCP_BROKER_TLS_CERT` | (unset) | Path to a PEM certificate. Enables HTTPS/WSS |
|
|
96
|
+
| `MCP_BROKER_TLS_KEY` | (unset) | Path to a PEM private key. Enables HTTPS/WSS |
|
|
97
|
+
| `MCP_BROKER_PROTOCOL` | auto | `http` forces plain, `https` forces TLS, unset auto-detects from cert+key |
|
|
98
|
+
| `MCP_BROKER_STDIO_PROVIDER` | (unset) | When set, bridge stdin/stdout JSON-RPC to this provider (Claude Desktop integration) |
|
|
99
|
+
|
|
100
|
+
## Programmatic API
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { WsTunnelBuilder } from "@cyanmycelium/mcp-broker";
|
|
104
|
+
|
|
105
|
+
const broker = new WsTunnelBuilder()
|
|
106
|
+
.withPort(3000)
|
|
107
|
+
.withHost("0.0.0.0")
|
|
108
|
+
.withProviderPath("/provider")
|
|
109
|
+
.withMcpPath("/mcp")
|
|
110
|
+
// Optional: bridge a local stdio MCP server as a provider.
|
|
111
|
+
.withStdioUpstream("my-server", "node", ["./my-server.js"])
|
|
112
|
+
// Optional: serve a dev harness at /
|
|
113
|
+
.withStaticMount("/", "/abs/path/to/www")
|
|
114
|
+
.build();
|
|
115
|
+
|
|
116
|
+
await broker.start();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
All builder methods are documented inline. The full options interface is `WsTunnelOptions`, also exported.
|
|
120
|
+
|
|
121
|
+
## TLS for local development
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
npm run gen-cert
|
|
125
|
+
# Writes ../certs/cert.pem and ../certs/key.pem (repo root)
|
|
126
|
+
|
|
127
|
+
$env:MCP_BROKER_TLS_CERT="../certs/cert.pem"
|
|
128
|
+
$env:MCP_BROKER_TLS_KEY="../certs/key.pem"
|
|
129
|
+
npm start
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The generated certificate covers `localhost`, `127.0.0.1`, `::1` for 365 days. Browsers will warn about an untrusted issuer on first visit. Click "Advanced → Proceed". MCP clients (Claude, Inspector) ignore certificate validation by default.
|
|
133
|
+
|
|
134
|
+
## Docker
|
|
135
|
+
|
|
136
|
+
A multi-stage `Dockerfile` ships with the package: build stage compiles TypeScript and copies grammar JSON, runtime stage carries only the compiled `dist/`, production `node_modules`, and runs as a non-root user.
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
# From the node/ directory
|
|
140
|
+
docker build -t cyanmycelium/mcp-broker:0.1.0 .
|
|
141
|
+
|
|
142
|
+
# Run on host port 3000
|
|
143
|
+
docker run --rm -p 3000:3000 cyanmycelium/mcp-broker:0.1.0
|
|
144
|
+
|
|
145
|
+
# With a custom locale and host port
|
|
146
|
+
docker run --rm -p 4000:4000 \
|
|
147
|
+
-e MCP_BROKER_PORT=4000 \
|
|
148
|
+
-e MCP_BROKER_LOCALE=fr-CA \
|
|
149
|
+
cyanmycelium/mcp-broker:0.1.0
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Mounting TLS material
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
# Generate localhost certs on the host first
|
|
156
|
+
npm run gen-cert # writes ../certs/cert.pem and ../certs/key.pem
|
|
157
|
+
|
|
158
|
+
docker run --rm -p 3000:3000 \
|
|
159
|
+
-v "$(pwd)/../certs:/certs:ro" \
|
|
160
|
+
-e MCP_BROKER_TLS_CERT=/certs/cert.pem \
|
|
161
|
+
-e MCP_BROKER_TLS_KEY=/certs/key.pem \
|
|
162
|
+
cyanmycelium/mcp-broker:0.1.0
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Mounting a static dev harness
|
|
166
|
+
|
|
167
|
+
```sh
|
|
168
|
+
docker run --rm -p 3000:3000 \
|
|
169
|
+
-v "$(pwd)/public:/www:ro" \
|
|
170
|
+
-e MCP_BROKER_WWW_DIR=/www \
|
|
171
|
+
cyanmycelium/mcp-broker:0.1.0
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Health check
|
|
175
|
+
|
|
176
|
+
The image declares a `HEALTHCHECK` that opens a TCP socket on `MCP_BROKER_PORT`. Orchestrators (Docker Compose, Kubernetes liveness probe) pick it up automatically.
|
|
177
|
+
|
|
178
|
+
### docker-compose snippet
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
services:
|
|
182
|
+
broker:
|
|
183
|
+
build: .
|
|
184
|
+
# Or pull a published image once available:
|
|
185
|
+
# image: ghcr.io/pandagaume/mcp-broker:0.1.0
|
|
186
|
+
ports:
|
|
187
|
+
- "3000:3000"
|
|
188
|
+
environment:
|
|
189
|
+
MCP_BROKER_PORT: "3000"
|
|
190
|
+
MCP_BROKER_LOCALE: "en"
|
|
191
|
+
restart: unless-stopped
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Claude Desktop integration
|
|
195
|
+
|
|
196
|
+
The broker can act as a stdio MCP server for Claude Desktop, bridging to any provider it manages:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"mcpServers": {
|
|
201
|
+
"broker": {
|
|
202
|
+
"command": "npx",
|
|
203
|
+
"args": ["-y", "@cyanmycelium/mcp-broker"],
|
|
204
|
+
"env": { "MCP_BROKER_STDIO_PROVIDER": "<your-provider-name>" }
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
In this mode all broker logging goes to stderr; stdout is reserved for the JSON-RPC stream Claude expects.
|
|
211
|
+
|
|
212
|
+
## What the broker does (and does not yet)
|
|
213
|
+
|
|
214
|
+
| Capability | Status |
|
|
215
|
+
|---|---|
|
|
216
|
+
| One named provider slot, multiple clients | ✅ |
|
|
217
|
+
| Provider transports: WS dedicated, WS multiplexed, stdio upstream | ✅ |
|
|
218
|
+
| Client transports: raw WS, Streamable HTTP (2025-03-26), legacy SSE, stdio bridge | ✅ |
|
|
219
|
+
| TLS via PEM files | ✅ |
|
|
220
|
+
| Static file serving (dev harness) | ✅ |
|
|
221
|
+
| Cross-provider tool aggregation (one client sees all providers' tools at once) | 🚧 v0.4 |
|
|
222
|
+
| Authentication / authorization | 🚧 v0.3 |
|
|
223
|
+
| Multi-tenant isolation | 🚧 v1.0 |
|
|
224
|
+
|
|
225
|
+
Full roadmap: [../docs/roadmap.md](../docs/roadmap.md).
|
|
226
|
+
|
|
227
|
+
## Development
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
npm install
|
|
231
|
+
npm run build # tsc -b
|
|
232
|
+
npm test # vitest run
|
|
233
|
+
npm run lint
|
|
234
|
+
npm start # node dist/bin.js
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Requires Node 20.11+.
|
|
238
|
+
|
|
239
|
+
## Releasing
|
|
240
|
+
|
|
241
|
+
The package is published to npm by [`.github/workflows/release-node.yml`](../.github/workflows/release-node.yml), triggered by tags of the form `node-v*`.
|
|
242
|
+
|
|
243
|
+
```sh
|
|
244
|
+
# from the node/ directory:
|
|
245
|
+
npm version patch # creates a "node-v0.1.1" tag (.npmrc sets the prefix)
|
|
246
|
+
git push --follow-tags
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The workflow runs lint, build, test, then `npm publish --access public --provenance` and creates a GitHub Release with auto-generated notes.
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
package/dist/bin.d.ts
ADDED