lunarfs-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +135 -0
- package/README.md +112 -0
- package/dist/backend/cli-runner.d.ts +4 -0
- package/dist/backend/cli-runner.js +23 -0
- package/dist/backend/cli-runner.js.map +1 -0
- package/dist/backend/http-client.d.ts +6 -0
- package/dist/backend/http-client.js +34 -0
- package/dist/backend/http-client.js.map +1 -0
- package/dist/backend/lunar-backend.d.ts +32 -0
- package/dist/backend/lunar-backend.js +102 -0
- package/dist/backend/lunar-backend.js.map +1 -0
- package/dist/backend/types.d.ts +72 -0
- package/dist/backend/types.js +9 -0
- package/dist/backend/types.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +43 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/remote.d.ts +7 -0
- package/dist/remote.js +35 -0
- package/dist/remote.js.map +1 -0
- package/dist/schemas.d.ts +24 -0
- package/dist/schemas.js +25 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/destroy.d.ts +9 -0
- package/dist/tools/destroy.js +28 -0
- package/dist/tools/destroy.js.map +1 -0
- package/dist/tools/fork-workspace.d.ts +10 -0
- package/dist/tools/fork-workspace.js +28 -0
- package/dist/tools/fork-workspace.js.map +1 -0
- package/dist/tools/grant-access.d.ts +12 -0
- package/dist/tools/grant-access.js +32 -0
- package/dist/tools/grant-access.js.map +1 -0
- package/dist/tools/list-workspaces.d.ts +9 -0
- package/dist/tools/list-workspaces.js +28 -0
- package/dist/tools/list-workspaces.js.map +1 -0
- package/dist/tools/mount.d.ts +10 -0
- package/dist/tools/mount.js +28 -0
- package/dist/tools/mount.js.map +1 -0
- package/dist/tools/push.d.ts +10 -0
- package/dist/tools/push.js +28 -0
- package/dist/tools/push.js.map +1 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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 made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other transformations
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source lists, and issue tracking systems that are managed by, or on
|
|
54
|
+
behalf of, the Licensor for the purpose of discussing and improving the
|
|
55
|
+
Work, but excluding communication that is conspicuously marked or
|
|
56
|
+
otherwise designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those Contributions necessary to
|
|
76
|
+
make, use, sell, offer to sell, import, and otherwise transfer the Work.
|
|
77
|
+
|
|
78
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
79
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
80
|
+
modifications, and in Source or Object form, provided that You
|
|
81
|
+
meet the following conditions:
|
|
82
|
+
|
|
83
|
+
(a) You must give any other recipients of the Work or
|
|
84
|
+
Derivative Works a copy of this License; and
|
|
85
|
+
|
|
86
|
+
(b) You must cause any modified files to carry prominent notices
|
|
87
|
+
stating that You changed the files; and
|
|
88
|
+
|
|
89
|
+
(c) You must retain, in all Source forms of the Work,
|
|
90
|
+
all copyright, patent, trademark, and other notices from the
|
|
91
|
+
Source form of the Work, excluding those notices that do not
|
|
92
|
+
pertain to any part of the Derivative Works; and
|
|
93
|
+
|
|
94
|
+
(d) You must reproduce the above copyright notice and this License.
|
|
95
|
+
|
|
96
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
97
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
98
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
99
|
+
this License, without any additional terms or conditions.
|
|
100
|
+
|
|
101
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
102
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
103
|
+
|
|
104
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed
|
|
105
|
+
to in writing, Licensor provides the Work (and each Contributor provides
|
|
106
|
+
its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
|
107
|
+
OF ANY KIND, either express or implied, including, without limitation,
|
|
108
|
+
any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
|
|
109
|
+
or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
|
|
110
|
+
determining the appropriateness of using or reproducing the Work and
|
|
111
|
+
assume any risks associated with Your exercise of permissions under
|
|
112
|
+
this License.
|
|
113
|
+
|
|
114
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
115
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
116
|
+
unless required by applicable law (such as deliberate and grossly
|
|
117
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
118
|
+
liable to You for damages, including any direct, indirect, special,
|
|
119
|
+
incidental, or exemplary damages of any character arising as a
|
|
120
|
+
result of this License or out of the use or inability to use the
|
|
121
|
+
Work (even if such Contributor has been advised of the possibility
|
|
122
|
+
of such damages).
|
|
123
|
+
|
|
124
|
+
9. Accepting Warranty or Liability. While redistributing the Work or
|
|
125
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
126
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
127
|
+
obligations and/or rights consistent with this License. However,
|
|
128
|
+
in accepting such obligations, You may offer such obligations only
|
|
129
|
+
on Your own behalf and on behalf of You alone, and not on behalf of
|
|
130
|
+
any other Contributor, and only if You agree to indemnify, defend,
|
|
131
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
132
|
+
or claims asserted against, such Contributor by reason of your
|
|
133
|
+
accepting any such warranty or additional liability.
|
|
134
|
+
|
|
135
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# lunarfs-mcp
|
|
2
|
+
|
|
3
|
+
MCP server wrapping the [lunar](https://github.com/dev-dropbox/lunar) workspace engine.
|
|
4
|
+
Exposes six tools over STDIO so any MCP client can fork, mount, list, push, share,
|
|
5
|
+
and destroy workspaces without spawning a UI.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx lunarfs-mcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The server listens on STDIO. Point your MCP client at it with transport `stdio`.
|
|
14
|
+
|
|
15
|
+
## Environment
|
|
16
|
+
|
|
17
|
+
| Variable | Default | Purpose |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `LUNAR_API_URL` | `http://127.0.0.1:8787` | Base URL for the lunar HTTP API (used by list and grant tools) |
|
|
20
|
+
|
|
21
|
+
## Tools
|
|
22
|
+
|
|
23
|
+
| Name | Channel | Description |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `fork_workspace` | CLI | Clone a workspace into an isolated ephemeral copy |
|
|
26
|
+
| `mount` | CLI | Attach a workspace to a local path |
|
|
27
|
+
| `list_workspaces` | HTTP | List workspaces, optionally filtered |
|
|
28
|
+
| `push` | CLI | Persist workspace state and produce a revision |
|
|
29
|
+
| `grant_access` | HTTP | Grant a user read/write/admin access |
|
|
30
|
+
| `destroy` | CLI | Permanently drop a workspace and all its state |
|
|
31
|
+
|
|
32
|
+
## Client Configuration
|
|
33
|
+
|
|
34
|
+
No global install required. `npx lunarfs-mcp` fetches and runs the server on demand.
|
|
35
|
+
All three clients use the same stdio transport: `command: npx`, `args: ["-y", "lunarfs-mcp"]`.
|
|
36
|
+
|
|
37
|
+
### Claude Code
|
|
38
|
+
|
|
39
|
+
Add to `.mcp.json` at your project root (project-scoped) or run the one-liner:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
claude mcp add lunar npx -- -y lunarfs-mcp
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or edit `.mcp.json` directly:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"lunar": {
|
|
51
|
+
"command": "npx",
|
|
52
|
+
"args": ["-y", "lunarfs-mcp"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Cursor
|
|
59
|
+
|
|
60
|
+
Add to `.cursor/mcp.json` at your project root:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"lunar": {
|
|
66
|
+
"command": "npx",
|
|
67
|
+
"args": ["-y", "lunarfs-mcp"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Cline
|
|
74
|
+
|
|
75
|
+
Open `Cline > MCP Servers > Edit Config` in VS Code and add:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"lunar": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["-y", "lunarfs-mcp"]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Using the HTTP-backed tools (list, grant)
|
|
89
|
+
|
|
90
|
+
The `list_workspaces` and `grant_access` tools call the lunar HTTP API. If your
|
|
91
|
+
workflows use them, add the `env` block to any of the configs above:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcpServers": {
|
|
96
|
+
"lunar": {
|
|
97
|
+
"command": "npx",
|
|
98
|
+
"args": ["-y", "lunarfs-mcp"],
|
|
99
|
+
"env": {
|
|
100
|
+
"LUNAR_API_URL": "http://127.0.0.1:8787"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`LUNAR_API_URL` defaults to `http://127.0.0.1:8787` when omitted. The fork,
|
|
108
|
+
mount, push, and destroy tools use the local CLI and do not require this variable.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
Apache-2.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
const execFileAsync = promisify(execFile);
|
|
4
|
+
export class ProductionCliRunner {
|
|
5
|
+
async run(args) {
|
|
6
|
+
if (args.length === 0) {
|
|
7
|
+
return { stdout: '', stderr: 'no args provided', exitCode: 1 };
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const { stdout, stderr } = await execFileAsync('lunar', args);
|
|
11
|
+
return { stdout, stderr, exitCode: 0 };
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
const e = err;
|
|
15
|
+
return {
|
|
16
|
+
stdout: e.stdout ?? '',
|
|
17
|
+
stderr: e.stderr ?? '',
|
|
18
|
+
exitCode: typeof e.code === 'number' ? e.code : 1,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=cli-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-runner.js","sourceRoot":"","sources":["../../src/backend/cli-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAEzC,MAAM,OAAO,mBAAmB;IAC9B,KAAK,CAAC,GAAG,CAAC,IAAc;QACtB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;QAChE,CAAC;QACD,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;YAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAA;QACxC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,GAA0D,CAAA;YACpE,OAAO;gBACL,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;gBACtB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;gBACtB,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAClD,CAAA;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const DEFAULT_BASE = 'http://127.0.0.1:8787';
|
|
2
|
+
export class ProductionHttpClient {
|
|
3
|
+
base;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.base = process.env['LUNAR_API_URL'] ?? DEFAULT_BASE;
|
|
6
|
+
}
|
|
7
|
+
async request(method, path, body) {
|
|
8
|
+
if (!method || !path) {
|
|
9
|
+
return { status: 400, body: null };
|
|
10
|
+
}
|
|
11
|
+
const token = process.env['LUNAR_TOKEN'];
|
|
12
|
+
const headers = {};
|
|
13
|
+
if (token) {
|
|
14
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
15
|
+
}
|
|
16
|
+
if (body !== undefined) {
|
|
17
|
+
headers['Content-Type'] = 'application/json';
|
|
18
|
+
}
|
|
19
|
+
const init = { method, headers };
|
|
20
|
+
if (body !== undefined) {
|
|
21
|
+
init.body = JSON.stringify(body);
|
|
22
|
+
}
|
|
23
|
+
const res = await fetch(`${this.base}${path}`, init);
|
|
24
|
+
let parsedBody;
|
|
25
|
+
try {
|
|
26
|
+
parsedBody = await res.json();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
parsedBody = null;
|
|
30
|
+
}
|
|
31
|
+
return { status: res.status, body: parsedBody };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/backend/http-client.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,uBAAuB,CAAA;AAE5C,MAAM,OAAO,oBAAoB;IACd,IAAI,CAAQ;IAE7B;QACE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,YAAY,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY,EAAE,IAAc;QACxD,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACpC,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;QACxC,MAAM,OAAO,GAA2B,EAAE,CAAA;QAC1C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAA;QAC9C,CAAC;QACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAA;QAC9C,CAAC;QACD,MAAM,IAAI,GAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;QAC7C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,CAAA;QACpD,IAAI,UAAmB,CAAA;QACvB,IAAI,CAAC;YACH,UAAU,GAAG,MAAM,GAAG,CAAC,IAAI,EAAa,CAAA;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,UAAU,GAAG,IAAI,CAAA;QACnB,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;IACjD,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CliRunner, HttpClient, LunarBackend, ForkInput, Workspace, MountInput, ListInput, PushInput, GrantInput, DestroyInput, AccessRole } from './types.js';
|
|
2
|
+
interface BackendDeps {
|
|
3
|
+
cli: CliRunner;
|
|
4
|
+
http: HttpClient;
|
|
5
|
+
}
|
|
6
|
+
export declare class LunarBackendImpl implements LunarBackend {
|
|
7
|
+
private readonly cli;
|
|
8
|
+
private readonly http;
|
|
9
|
+
constructor(deps?: Partial<BackendDeps>);
|
|
10
|
+
forkWorkspace(input: ForkInput): Promise<Workspace>;
|
|
11
|
+
mount(input: MountInput): Promise<{
|
|
12
|
+
workspace: string;
|
|
13
|
+
path: string;
|
|
14
|
+
mounted: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
listWorkspaces(input: ListInput): Promise<Workspace[]>;
|
|
17
|
+
push(input: PushInput): Promise<{
|
|
18
|
+
workspace: string;
|
|
19
|
+
pushed: boolean;
|
|
20
|
+
revision?: string;
|
|
21
|
+
}>;
|
|
22
|
+
grantAccess(input: GrantInput): Promise<{
|
|
23
|
+
workspace: string;
|
|
24
|
+
grantee: string;
|
|
25
|
+
role: AccessRole;
|
|
26
|
+
}>;
|
|
27
|
+
destroy(input: DestroyInput): Promise<{
|
|
28
|
+
workspace: string;
|
|
29
|
+
destroyed: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { LunarError } from './types.js';
|
|
2
|
+
import { ProductionCliRunner } from './cli-runner.js';
|
|
3
|
+
import { ProductionHttpClient } from './http-client.js';
|
|
4
|
+
export class LunarBackendImpl {
|
|
5
|
+
cli;
|
|
6
|
+
http;
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
this.cli = deps?.cli ?? new ProductionCliRunner();
|
|
9
|
+
this.http = deps?.http ?? new ProductionHttpClient();
|
|
10
|
+
}
|
|
11
|
+
async forkWorkspace(input) {
|
|
12
|
+
if (!input.source)
|
|
13
|
+
throw new LunarError('fork_failed', 'source is required');
|
|
14
|
+
const name = input.name ?? `fork-${input.source}`;
|
|
15
|
+
const res = await this.http.request('POST', `/v1/workspaces/${encodeURIComponent(input.source)}/fork`, { new_workspace: name });
|
|
16
|
+
if (res.status !== 200 && res.status !== 201) {
|
|
17
|
+
const detail = res.body !== null && typeof res.body === 'object'
|
|
18
|
+
? JSON.stringify(res.body)
|
|
19
|
+
: String(res.body ?? res.status);
|
|
20
|
+
throw new LunarError('fork_failed', `fork returned status ${res.status}: ${detail}`);
|
|
21
|
+
}
|
|
22
|
+
const body = res.body;
|
|
23
|
+
const wsName = body?.workspace ?? name;
|
|
24
|
+
return { id: wsName, name: wsName, status: 'ready', ephemeral: false };
|
|
25
|
+
}
|
|
26
|
+
async mount(input) {
|
|
27
|
+
if (!input.workspace)
|
|
28
|
+
throw new LunarError('mount_failed', 'workspace is required');
|
|
29
|
+
if (!input.path)
|
|
30
|
+
throw new LunarError('mount_failed', 'path is required');
|
|
31
|
+
const result = await this.cli.run(['mount', input.workspace, input.path]);
|
|
32
|
+
if (result.exitCode !== 0) {
|
|
33
|
+
throw new LunarError('mount_failed', result.stderr.trim() || 'lunar mount failed');
|
|
34
|
+
}
|
|
35
|
+
return { workspace: input.workspace, path: input.path, mounted: true };
|
|
36
|
+
}
|
|
37
|
+
async listWorkspaces(input) {
|
|
38
|
+
const qs = input.filter !== undefined ? `?filter=${encodeURIComponent(input.filter)}` : '';
|
|
39
|
+
const res = await this.http.request('GET', `/v1/workspaces${qs}`);
|
|
40
|
+
if (res.status < 200 || res.status >= 300) {
|
|
41
|
+
throw new LunarError('list_failed', `list workspaces returned status ${res.status}`);
|
|
42
|
+
}
|
|
43
|
+
const body = res.body;
|
|
44
|
+
if (!body || !Array.isArray(body.workspaces)) {
|
|
45
|
+
throw new LunarError('list_failed', 'unexpected response body from list workspaces');
|
|
46
|
+
}
|
|
47
|
+
return body.workspaces.map((ws) => {
|
|
48
|
+
const w = ws;
|
|
49
|
+
return {
|
|
50
|
+
id: w.id ?? '',
|
|
51
|
+
name: w.label ?? w.id ?? '',
|
|
52
|
+
status: w.state ?? 'ready',
|
|
53
|
+
ephemeral: w.ephemeral ?? false,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async push(input) {
|
|
58
|
+
if (!input.workspace)
|
|
59
|
+
throw new LunarError('push_failed', 'workspace is required');
|
|
60
|
+
// Read the workspace's current root ref from the server.
|
|
61
|
+
const getRes = await this.http.request('GET', `/v1/ref/${encodeURIComponent(input.workspace)}`);
|
|
62
|
+
if (getRes.status < 200 || getRes.status >= 300) {
|
|
63
|
+
throw new LunarError('push_failed', `failed to read workspace ref: status ${getRes.status}`);
|
|
64
|
+
}
|
|
65
|
+
const refBody = getRes.body;
|
|
66
|
+
const root = refBody?.root;
|
|
67
|
+
if (!root)
|
|
68
|
+
throw new LunarError('push_failed', 'workspace has no root ref');
|
|
69
|
+
// Push (re-commit) the root to the workspace. Real callers would supply a new root
|
|
70
|
+
// from a locally ingested tree; this implementation re-pushes the current root as an
|
|
71
|
+
// idempotent write that validates authentication and write-ACL end-to-end.
|
|
72
|
+
const putRes = await this.http.request('PUT', `/v1/ref/${encodeURIComponent(input.workspace)}`, { root });
|
|
73
|
+
if (putRes.status < 200 || putRes.status >= 300) {
|
|
74
|
+
throw new LunarError('push_failed', `push failed with status ${putRes.status}`);
|
|
75
|
+
}
|
|
76
|
+
return { workspace: input.workspace, pushed: true, revision: root };
|
|
77
|
+
}
|
|
78
|
+
async grantAccess(input) {
|
|
79
|
+
if (!input.workspace)
|
|
80
|
+
throw new LunarError('grant_failed', 'workspace is required');
|
|
81
|
+
if (!input.grantee)
|
|
82
|
+
throw new LunarError('grant_failed', 'grantee is required');
|
|
83
|
+
const res = await this.http.request('POST', `/workspaces/${input.workspace}/access`, {
|
|
84
|
+
grantee: input.grantee,
|
|
85
|
+
role: input.role,
|
|
86
|
+
});
|
|
87
|
+
if (res.status !== 200 && res.status !== 201) {
|
|
88
|
+
throw new LunarError('grant_failed', `grant access returned status ${res.status}`);
|
|
89
|
+
}
|
|
90
|
+
return { workspace: input.workspace, grantee: input.grantee, role: input.role };
|
|
91
|
+
}
|
|
92
|
+
async destroy(input) {
|
|
93
|
+
if (!input.workspace)
|
|
94
|
+
throw new LunarError('destroy_failed', 'workspace is required');
|
|
95
|
+
const result = await this.cli.run(['destroy', input.workspace, '--yes']);
|
|
96
|
+
if (result.exitCode !== 0) {
|
|
97
|
+
throw new LunarError('destroy_failed', result.stderr.trim() || 'lunar destroy failed');
|
|
98
|
+
}
|
|
99
|
+
return { workspace: input.workspace, destroyed: true };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=lunar-backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lunar-backend.js","sourceRoot":"","sources":["../../src/backend/lunar-backend.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAOvD,MAAM,OAAO,gBAAgB;IACV,GAAG,CAAW;IACd,IAAI,CAAY;IAEjC,YAAY,IAA2B;QACrC,IAAI,CAAC,GAAG,GAAG,IAAI,EAAE,GAAG,IAAI,IAAI,mBAAmB,EAAE,CAAA;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,IAAI,oBAAoB,EAAE,CAAA;IACtD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAgB;QAClC,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,MAAM,IAAI,UAAU,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAA;QAC5E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAA;QACjD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CACjC,MAAM,EACN,kBAAkB,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EACzD,EAAE,aAAa,EAAE,IAAI,EAAE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C,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export interface CliResult {
|
|
2
|
+
stdout: string;
|
|
3
|
+
stderr: string;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CliRunner {
|
|
7
|
+
run(args: string[]): Promise<CliResult>;
|
|
8
|
+
}
|
|
9
|
+
export interface HttpResponse {
|
|
10
|
+
status: number;
|
|
11
|
+
body: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface HttpClient {
|
|
14
|
+
request(method: string, path: string, body?: unknown): Promise<HttpResponse>;
|
|
15
|
+
}
|
|
16
|
+
export interface Workspace {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
status: string;
|
|
20
|
+
ephemeral: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ForkInput {
|
|
23
|
+
source: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MountInput {
|
|
27
|
+
workspace: string;
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ListInput {
|
|
31
|
+
filter?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PushInput {
|
|
34
|
+
workspace: string;
|
|
35
|
+
message?: string;
|
|
36
|
+
}
|
|
37
|
+
export type AccessRole = 'read' | 'write' | 'admin';
|
|
38
|
+
export interface GrantInput {
|
|
39
|
+
workspace: string;
|
|
40
|
+
grantee: string;
|
|
41
|
+
role: AccessRole;
|
|
42
|
+
}
|
|
43
|
+
export interface DestroyInput {
|
|
44
|
+
workspace: string;
|
|
45
|
+
}
|
|
46
|
+
export interface LunarBackend {
|
|
47
|
+
forkWorkspace(input: ForkInput): Promise<Workspace>;
|
|
48
|
+
mount(input: MountInput): Promise<{
|
|
49
|
+
workspace: string;
|
|
50
|
+
path: string;
|
|
51
|
+
mounted: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
listWorkspaces(input: ListInput): Promise<Workspace[]>;
|
|
54
|
+
push(input: PushInput): Promise<{
|
|
55
|
+
workspace: string;
|
|
56
|
+
pushed: boolean;
|
|
57
|
+
revision?: string;
|
|
58
|
+
}>;
|
|
59
|
+
grantAccess(input: GrantInput): Promise<{
|
|
60
|
+
workspace: string;
|
|
61
|
+
grantee: string;
|
|
62
|
+
role: AccessRole;
|
|
63
|
+
}>;
|
|
64
|
+
destroy(input: DestroyInput): Promise<{
|
|
65
|
+
workspace: string;
|
|
66
|
+
destroyed: boolean;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
export declare class LunarError extends Error {
|
|
70
|
+
code: string;
|
|
71
|
+
constructor(code: string, message: string);
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAChB;IAAnB,YAAmB,IAAY,EAAE,OAAe;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAA;QADG,SAAI,GAAJ,IAAI,CAAQ;QAE7B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;IAC1B,CAAC;CACF"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type TransportMode = 'stdio' | 'remote';
|
|
2
|
+
export interface RemoteConfig {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolvedConfig {
|
|
8
|
+
mode: TransportMode;
|
|
9
|
+
remote?: RemoteConfig;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveConfig(env?: Record<string, string | undefined>): ResolvedConfig;
|
|
12
|
+
export declare function isAuthorized(authHeader: string | undefined, expectedToken: string): boolean;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { timingSafeEqual } from 'node:crypto';
|
|
2
|
+
function isTruthy(value) {
|
|
3
|
+
if (value === undefined)
|
|
4
|
+
return false;
|
|
5
|
+
return ['1', 'true', 'yes'].includes(value.toLowerCase().trim());
|
|
6
|
+
}
|
|
7
|
+
function parsePort(value) {
|
|
8
|
+
if (value === undefined)
|
|
9
|
+
return 3000;
|
|
10
|
+
const n = Number.parseInt(value, 10);
|
|
11
|
+
return Number.isFinite(n) && n > 0 ? n : 3000;
|
|
12
|
+
}
|
|
13
|
+
export function resolveConfig(env = process.env) {
|
|
14
|
+
const flag = isTruthy(env['LUNAR_MCP_REMOTE']);
|
|
15
|
+
if (!flag)
|
|
16
|
+
return { mode: 'stdio' };
|
|
17
|
+
const token = env['LUNAR_MCP_TOKEN']?.trim();
|
|
18
|
+
if (!token)
|
|
19
|
+
throw new Error('LUNAR_MCP_REMOTE is set but LUNAR_MCP_TOKEN is empty');
|
|
20
|
+
return {
|
|
21
|
+
mode: 'remote',
|
|
22
|
+
remote: {
|
|
23
|
+
host: env['LUNAR_MCP_HOST']?.trim() || '127.0.0.1',
|
|
24
|
+
port: parsePort(env['LUNAR_MCP_PORT']),
|
|
25
|
+
token,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Compares the Bearer token with constant-time equality to resist timing attacks.
|
|
30
|
+
// Case-sensitive prefix match is intentional: 'Bearer' is the registered scheme (RFC 6750).
|
|
31
|
+
export function isAuthorized(authHeader, expectedToken) {
|
|
32
|
+
if (authHeader === undefined)
|
|
33
|
+
return false;
|
|
34
|
+
if (!authHeader.startsWith('Bearer '))
|
|
35
|
+
return false;
|
|
36
|
+
const presented = authHeader.slice('Bearer '.length);
|
|
37
|
+
const a = Buffer.from(presented, 'utf8');
|
|
38
|
+
const b = Buffer.from(expectedToken, 'utf8');
|
|
39
|
+
if (a.length !== b.length)
|
|
40
|
+
return false;
|
|
41
|
+
return timingSafeEqual(a, b);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0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;AACH,CAAC;AAED,kFAAkF;AAClF,4FAA4F;AAC5F,MAAM,UAAU,YAAY,CAAC,UAA8B,EAAE,aAAqB;IAChF,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IAC1C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,KAAK,CAAA;IACnD,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACpD,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IACxC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC5C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IACvC,OAAO,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC9B,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { createServer } from './server.js';
|
|
4
|
+
import { resolveConfig } from './config.js';
|
|
5
|
+
import { startRemoteServer } from './remote.js';
|
|
6
|
+
(async () => {
|
|
7
|
+
const cfg = resolveConfig();
|
|
8
|
+
if (cfg.mode === 'remote' && cfg.remote != null) {
|
|
9
|
+
await startRemoteServer(cfg.remote);
|
|
10
|
+
process.stderr.write(`lunarfs-mcp: listening on http://${cfg.remote.host}:${cfg.remote.port}\n`);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const server = createServer();
|
|
14
|
+
const transport = new StdioServerTransport();
|
|
15
|
+
server.connect(transport).catch((err) => {
|
|
16
|
+
process.stderr.write(`lunarfs-mcp: fatal: ${String(err)}\n`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
})().catch((err) => {
|
|
21
|
+
process.stderr.write(`lunarfs-mcp: fatal: ${String(err)}\n`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAE9C;AAAA,CAAC,KAAK,IAAI,EAAE;IACX,MAAM,GAAG,GAAG,aAAa,EAAE,CAAA;IAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAChD,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAA;IAClG,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;QAC7B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;QAC5C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;YAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import type { RemoteConfig } from './config.js';
|
|
4
|
+
export declare function createRequestHandler(config: RemoteConfig, makeServer: () => McpServer): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
5
|
+
export declare function startRemoteServer(config: RemoteConfig, makeServer?: () => McpServer): Promise<{
|
|
6
|
+
close: () => Promise<void>;
|
|
7
|
+
}>;
|
package/dist/remote.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createServer as createHttpServer } from 'node:http';
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import { createServer } from './server.js';
|
|
4
|
+
import { isAuthorized } from './config.js';
|
|
5
|
+
// Exported for unit testing without a live socket.
|
|
6
|
+
export function createRequestHandler(config, makeServer) {
|
|
7
|
+
return async (req, res) => {
|
|
8
|
+
if (!isAuthorized(req.headers['authorization'], config.token)) {
|
|
9
|
+
res.writeHead(401, { 'content-type': 'application/json' });
|
|
10
|
+
res.end(JSON.stringify({ error: 'unauthorized' }));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
// nyx: stateless mode (sessionIdGenerator: undefined) - no session tracking needed for this MVP
|
|
14
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
15
|
+
const server = makeServer();
|
|
16
|
+
await server.connect(transport);
|
|
17
|
+
await transport.handleRequest(req, res);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export async function startRemoteServer(config, makeServer = createServer) {
|
|
21
|
+
const handler = createRequestHandler(config, makeServer);
|
|
22
|
+
const httpServer = createHttpServer((req, res) => {
|
|
23
|
+
void handler(req, res);
|
|
24
|
+
});
|
|
25
|
+
await new Promise((resolve, reject) => {
|
|
26
|
+
httpServer.once('error', reject);
|
|
27
|
+
httpServer.listen(config.port, config.host, resolve);
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
close: () => new Promise((resolve, reject) => {
|
|
31
|
+
httpServer.close((err) => (err !== undefined ? reject(err) : resolve()));
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAElG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,mDAAmD;AACnD,MAAM,UAAU,oBAAoB,CAClC,MAAoB,EACpB,UAA2B;IAE3B,OAAO,KAAK,EAAE,GAAoB,EAAE,GAAmB,EAAiB,EAAE;QACxE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9D,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAA;YAC1D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,CAAA;YAClD,OAAM;QACR,CAAC;QACD,gGAAg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|
|
3
|
+
source: z.ZodString;
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
};
|
|
6
|
+
export declare const MountSchema: {
|
|
7
|
+
workspace: z.ZodString;
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
};
|
|
10
|
+
export declare const ListWorkspacesSchema: {
|
|
11
|
+
filter: z.ZodOptional<z.ZodString>;
|
|
12
|
+
};
|
|
13
|
+
export declare const PushSchema: {
|
|
14
|
+
workspace: z.ZodString;
|
|
15
|
+
message: z.ZodOptional<z.ZodString>;
|
|
16
|
+
};
|
|
17
|
+
export declare const GrantAccessSchema: {
|
|
18
|
+
workspace: z.ZodString;
|
|
19
|
+
grantee: z.ZodString;
|
|
20
|
+
role: z.ZodEnum<["read", "write", "admin"]>;
|
|
21
|
+
};
|
|
22
|
+
export declare const DestroySchema: {
|
|
23
|
+
workspace: z.ZodString;
|
|
24
|
+
};
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ForkWorkspaceSchema = {
|
|
3
|
+
source: z.string().min(1).describe('id or name of the workspace to clone'),
|
|
4
|
+
name: z.string().min(1).optional().describe('name for the new forked workspace'),
|
|
5
|
+
};
|
|
6
|
+
export const MountSchema = {
|
|
7
|
+
workspace: z.string().min(1),
|
|
8
|
+
path: z.string().min(1).describe('absolute or relative local path to mount onto'),
|
|
9
|
+
};
|
|
10
|
+
export const ListWorkspacesSchema = {
|
|
11
|
+
filter: z.string().optional().describe('optional substring to filter by name or status'),
|
|
12
|
+
};
|
|
13
|
+
export const PushSchema = {
|
|
14
|
+
workspace: z.string().min(1),
|
|
15
|
+
message: z.string().optional().describe('optional commit message'),
|
|
16
|
+
};
|
|
17
|
+
export const GrantAccessSchema = {
|
|
18
|
+
workspace: z.string().min(1),
|
|
19
|
+
grantee: z.string().min(1).describe('user id or email to grant'),
|
|
20
|
+
role: z.enum(['read', 'write', 'admin']),
|
|
21
|
+
};
|
|
22
|
+
export const DestroySchema = {
|
|
23
|
+
workspace: z.string().min(1),
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;IAC1E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;CACjF,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+CAA+C,CAAC;CAClF,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;CACzF,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;CACnE,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAChE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;CACzC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B,CAAA"}
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { LunarBackendImpl } from './backend/lunar-backend.js';
|
|
3
|
+
import { register as registerFork } from './tools/fork-workspace.js';
|
|
4
|
+
import { register as registerMount } from './tools/mount.js';
|
|
5
|
+
import { register as registerList } from './tools/list-workspaces.js';
|
|
6
|
+
import { register as registerPush } from './tools/push.js';
|
|
7
|
+
import { register as registerGrant } from './tools/grant-access.js';
|
|
8
|
+
import { register as registerDestroy } from './tools/destroy.js';
|
|
9
|
+
export function createServer(backend = new LunarBackendImpl()) {
|
|
10
|
+
const server = new McpServer({ name: 'lunarfs-mcp', version: '0.1.0' });
|
|
11
|
+
registerFork(server, backend);
|
|
12
|
+
registerMount(server, backend);
|
|
13
|
+
registerList(server, backend);
|
|
14
|
+
registerPush(server, backend);
|
|
15
|
+
registerGrant(server, backend);
|
|
16
|
+
registerDestroy(server, backend);
|
|
17
|
+
return server;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEhE,MAAM,UAAU,YAAY,CAAC,UAAwB,IAAI,gBAAgB,EAAE;IACzE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;IACvE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LunarBackend } from '../backend/types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
workspace: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function createHandler(backend: LunarBackend): (args: Args) => Promise<CallToolResult>;
|
|
8
|
+
export declare function register(server: McpServer, backend: LunarBackend): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LunarError } from '../backend/types.js';
|
|
2
|
+
import { DestroySchema } from '../schemas.js';
|
|
3
|
+
export function createHandler(backend) {
|
|
4
|
+
return async (args) => {
|
|
5
|
+
try {
|
|
6
|
+
const data = await backend.destroy({ workspace: args.workspace });
|
|
7
|
+
return {
|
|
8
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, data }) }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
const code = e instanceof LunarError ? e.code : 'unknown_error';
|
|
13
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: { code, message } }) }],
|
|
16
|
+
isError: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function register(server, backend) {
|
|
22
|
+
server.registerTool('destroy', {
|
|
23
|
+
title: 'Destroy Workspace',
|
|
24
|
+
description: 'Permanently drop an ephemeral workspace and all of its state. Use to discard a fork you do not want to keep or to clean up after parallel work. This is irreversible; anything not pushed is lost.',
|
|
25
|
+
inputSchema: DestroySchema,
|
|
26
|
+
}, createHandler(backend));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=destroy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../src/tools/destroy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAI7C,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;YACjE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;aACtE,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAA;YAC/D,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;YAC1D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,OAAqB;IAC/D,MAAM,CAAC,YAAY,CACjB,SAAS,EACT;QACE,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EACT,oMAAoM;QACtM,WAAW,EAAE,aAAa;KAC3B,EACD,aAAa,CAAC,OAAO,CAAC,CACvB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LunarBackend } from '../backend/types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
source: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function createHandler(backend: LunarBackend): (args: Args) => Promise<CallToolResult>;
|
|
9
|
+
export declare function register(server: McpServer, backend: LunarBackend): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LunarError } from '../backend/types.js';
|
|
2
|
+
import { ForkWorkspaceSchema } from '../schemas.js';
|
|
3
|
+
export function createHandler(backend) {
|
|
4
|
+
return async (args) => {
|
|
5
|
+
try {
|
|
6
|
+
const data = await backend.forkWorkspace({ source: args.source, name: args.name });
|
|
7
|
+
return {
|
|
8
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, data }) }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
const code = e instanceof LunarError ? e.code : 'unknown_error';
|
|
13
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: { code, message } }) }],
|
|
16
|
+
isError: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function register(server, backend) {
|
|
22
|
+
server.registerTool('fork_workspace', {
|
|
23
|
+
title: 'Fork Workspace',
|
|
24
|
+
description: 'Instantly clone an existing workspace into an isolated copy so you can run risky, experimental, or parallel work without touching the original. Use this before any change you might want to throw away. The fork starts as an ephemeral workspace you can later push to keep, or destroy to discard.',
|
|
25
|
+
inputSchema: ForkWorkspaceSchema,
|
|
26
|
+
}, createHandler(backend));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=fork-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fork-workspace.js","sourceRoot":"","sources":["../../src/tools/fork-workspace.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAInD,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,OAAO,KAAK,EAAE,IA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allToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LunarBackend } from '../backend/types.js';
|
|
4
|
+
import type { AccessRole } from '../backend/types.js';
|
|
5
|
+
type Args = {
|
|
6
|
+
workspace: string;
|
|
7
|
+
grantee: string;
|
|
8
|
+
role: AccessRole;
|
|
9
|
+
};
|
|
10
|
+
export declare function createHandler(backend: LunarBackend): (args: Args) => Promise<CallToolResult>;
|
|
11
|
+
export declare function register(server: McpServer, backend: LunarBackend): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LunarError } from '../backend/types.js';
|
|
2
|
+
import { GrantAccessSchema } from '../schemas.js';
|
|
3
|
+
export function createHandler(backend) {
|
|
4
|
+
return async (args) => {
|
|
5
|
+
try {
|
|
6
|
+
const data = await backend.grantAccess({
|
|
7
|
+
workspace: args.workspace,
|
|
8
|
+
grantee: args.grantee,
|
|
9
|
+
role: args.role,
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, data }) }],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
const code = e instanceof LunarError ? e.code : 'unknown_error';
|
|
17
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
18
|
+
return {
|
|
19
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: { code, message } }) }],
|
|
20
|
+
isError: true,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function register(server, backend) {
|
|
26
|
+
server.registerTool('grant_access', {
|
|
27
|
+
title: 'Grant Access',
|
|
28
|
+
description: 'Grant another user access to a workspace at a chosen role (read, write, or admin). Use to share a workspace or hand off ownership. Roles are cumulative in capability: read can view, write can modify, admin can manage access.',
|
|
29
|
+
inputSchema: GrantAccessSchema,
|
|
30
|
+
}, createHandler(backend));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=gr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UAAU,QAAQ,CAAC,MAAiB,EAAE,OAAqB;IAC/D,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,kOAAkO;QACpO,WAAW,EAAE,iBAAiB;KAC/B,EACD,aAAa,CAAC,OAAO,CAAC,CACvB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LunarBackend } from '../backend/types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
filter?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function createHandler(backend: LunarBackend): (args: Args) => Promise<CallToolResult>;
|
|
8
|
+
export declare function register(server: McpServer, backend: LunarBackend): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LunarError } from '../backend/types.js';
|
|
2
|
+
import { ListWorkspacesSchema } from '../schemas.js';
|
|
3
|
+
export function createHandler(backend) {
|
|
4
|
+
return async (args) => {
|
|
5
|
+
try {
|
|
6
|
+
const data = await backend.listWorkspaces({ filter: args.filter });
|
|
7
|
+
return {
|
|
8
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, data }) }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
const code = e instanceof LunarError ? e.code : 'unknown_error';
|
|
13
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: { code, message } }) }],
|
|
16
|
+
isError: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function register(server, backend) {
|
|
22
|
+
server.registerTool('list_workspaces', {
|
|
23
|
+
title: 'List Workspaces',
|
|
24
|
+
description: 'List all workspaces with their id, name, status, and whether they are ephemeral. Use to discover what workspaces exist before forking, mounting, pushing, granting access, or destroying one. Optional filter narrows by name or status.',
|
|
25
|
+
inputSchema: ListWorkspacesSchema,
|
|
26
|
+
}, createHandler(backend));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=list-workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-workspaces.js","sourceRoot":"","sources":["../../src/tools/list-workspaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAIpD,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;YAClE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;aACtE,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAA;YAC/D,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;YAC1D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,OAAqB;IAC/D,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,0OAA0O;QAC5O,WAAW,EAAE,oBAAoB;KAClC,EACD,aAAa,CAAC,OAAO,CAAC,CACvB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LunarBackend } from '../backend/types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
workspace: string;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function createHandler(backend: LunarBackend): (args: Args) => Promise<CallToolResult>;
|
|
9
|
+
export declare function register(server: McpServer, backend: LunarBackend): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LunarError } from '../backend/types.js';
|
|
2
|
+
import { MountSchema } from '../schemas.js';
|
|
3
|
+
export function createHandler(backend) {
|
|
4
|
+
return async (args) => {
|
|
5
|
+
try {
|
|
6
|
+
const data = await backend.mount({ workspace: args.workspace, path: args.path });
|
|
7
|
+
return {
|
|
8
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, data }) }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
const code = e instanceof LunarError ? e.code : 'unknown_error';
|
|
13
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: { code, message } }) }],
|
|
16
|
+
isError: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function register(server, backend) {
|
|
22
|
+
server.registerTool('mount', {
|
|
23
|
+
title: 'Mount Workspace',
|
|
24
|
+
description: 'Mount a workspace onto a local path so its files become visible and editable on disk. Use after fork_workspace or when you need to read or edit a workspace locally. Does not copy data; it attaches the live workspace at the given path.',
|
|
25
|
+
inputSchema: MountSchema,
|
|
26
|
+
}, createHandler(backend));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/tools/mount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;YAChF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;aACtE,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAA;YAC/D,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;YAC1D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,OAAqB;IAC/D,MAAM,CAAC,YAAY,CACjB,OAAO,EACP;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,4OAA4O;QAC9O,WAAW,EAAE,WAAW;KACzB,EACD,aAAa,CAAC,OAAO,CAAC,CACvB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LunarBackend } from '../backend/types.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
workspace: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function createHandler(backend: LunarBackend): (args: Args) => Promise<CallToolResult>;
|
|
9
|
+
export declare function register(server: McpServer, backend: LunarBackend): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LunarError } from '../backend/types.js';
|
|
2
|
+
import { PushSchema } from '../schemas.js';
|
|
3
|
+
export function createHandler(backend) {
|
|
4
|
+
return async (args) => {
|
|
5
|
+
try {
|
|
6
|
+
const data = await backend.push({ workspace: args.workspace, message: args.message });
|
|
7
|
+
return {
|
|
8
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: true, data }) }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
const code = e instanceof LunarError ? e.code : 'unknown_error';
|
|
13
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: 'text', text: JSON.stringify({ ok: false, error: { code, message } }) }],
|
|
16
|
+
isError: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function register(server, backend) {
|
|
22
|
+
server.registerTool('push', {
|
|
23
|
+
title: 'Push Workspace',
|
|
24
|
+
description: 'Persist the current state of a workspace, committing its changes and producing a new revision. Use to keep the results of work done in a forked or ephemeral workspace. After a successful push the work is durable.',
|
|
25
|
+
inputSchema: PushSchema,
|
|
26
|
+
}, createHandler(backend));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/tools/push.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI1C,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YACrF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;aACtE,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAA;YAC/D,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;YAC1D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,OAAqB;IAC/D,MAAM,CAAC,YAAY,CACjB,MAAM,EACN;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,sNAAsN;QACxN,WAAW,EAAE,UAAU;KACxB,EACD,aAAa,CAAC,OAAO,CAAC,CACvB,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lunarfs-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server wrapping the lunar workspace engine",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"engines": { "node": ">=22" },
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"bin": { "lunarfs-mcp": "dist/index.js" },
|
|
10
|
+
"exports": { ".": "./dist/index.js" },
|
|
11
|
+
"files": ["dist", "README.md"],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"start": "node dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
21
|
+
"zod": "^3.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.0.0",
|
|
25
|
+
"eslint": "^9.0.0",
|
|
26
|
+
"typescript": "^5.0.0",
|
|
27
|
+
"typescript-eslint": "^8.0.0",
|
|
28
|
+
"vitest": "^2.0.0"
|
|
29
|
+
}
|
|
30
|
+
}
|