@mcpfold/adapters 1.0.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 +28 -0
- package/dist/all.d.ts +6 -0
- package/dist/all.d.ts.map +1 -0
- package/dist/all.js +26 -0
- package/dist/all.js.map +1 -0
- package/dist/claude-code.d.ts +9 -0
- package/dist/claude-code.d.ts.map +1 -0
- package/dist/claude-code.js +23 -0
- package/dist/claude-code.js.map +1 -0
- package/dist/claude-desktop.d.ts +10 -0
- package/dist/claude-desktop.d.ts.map +1 -0
- package/dist/claude-desktop.js +22 -0
- package/dist/claude-desktop.js.map +1 -0
- package/dist/cline.d.ts +11 -0
- package/dist/cline.d.ts.map +1 -0
- package/dist/cline.js +22 -0
- package/dist/cline.js.map +1 -0
- package/dist/cursor.d.ts +7 -0
- package/dist/cursor.d.ts.map +1 -0
- package/dist/cursor.js +20 -0
- package/dist/cursor.js.map +1 -0
- package/dist/gemini-cli.d.ts +6 -0
- package/dist/gemini-cli.d.ts.map +1 -0
- package/dist/gemini-cli.js +17 -0
- package/dist/gemini-cli.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +26 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +48 -0
- package/dist/paths.js.map +1 -0
- package/dist/registry.d.ts +13 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +31 -0
- package/dist/registry.js.map +1 -0
- package/dist/shared.d.ts +53 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +90 -0
- package/dist/shared.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vscode.d.ts +3 -0
- package/dist/vscode.d.ts.map +1 -0
- package/dist/vscode.js +115 -0
- package/dist/vscode.js.map +1 -0
- package/dist/windsurf.d.ts +3 -0
- package/dist/windsurf.d.ts.map +1 -0
- package/dist/windsurf.js +97 -0
- package/dist/windsurf.js.map +1 -0
- package/dist/zed.d.ts +10 -0
- package/dist/zed.d.ts.map +1 -0
- package/dist/zed.js +24 -0
- package/dist/zed.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mcpfold contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The MIT license above covers the open-source packages: packages/* (@mcpfold/core,
|
|
26
|
+
@mcpfold/adapters, @mcpfold/secrets, @mcpfold/proxy, @mcpfold/schema) and the `mcpfold`
|
|
27
|
+
CLI. The cloud layer (apps/web, services/edge) is commercial/closed and NOT covered by
|
|
28
|
+
this license.
|
package/dist/all.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientAdapter } from './types.js';
|
|
2
|
+
/** Every built-in adapter, in a stable order. */
|
|
3
|
+
export declare const ALL_ADAPTERS: readonly ClientAdapter[];
|
|
4
|
+
/** Register every built-in adapter into the shared registry. Idempotent. */
|
|
5
|
+
export declare function registerAll(): void;
|
|
6
|
+
//# sourceMappingURL=all.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../src/all.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,iDAAiD;AACjD,eAAO,MAAM,YAAY,EAAE,SAAS,aAAa,EAShD,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
package/dist/all.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { registerAdapter } from './registry.js';
|
|
2
|
+
import { cursorAdapter } from './cursor.js';
|
|
3
|
+
import { claudeDesktopAdapter } from './claude-desktop.js';
|
|
4
|
+
import { claudeCodeAdapter } from './claude-code.js';
|
|
5
|
+
import { vscodeAdapter } from './vscode.js';
|
|
6
|
+
import { windsurfAdapter } from './windsurf.js';
|
|
7
|
+
import { zedAdapter } from './zed.js';
|
|
8
|
+
import { clineAdapter } from './cline.js';
|
|
9
|
+
import { geminiCliAdapter } from './gemini-cli.js';
|
|
10
|
+
/** Every built-in adapter, in a stable order. */
|
|
11
|
+
export const ALL_ADAPTERS = [
|
|
12
|
+
claudeCodeAdapter,
|
|
13
|
+
claudeDesktopAdapter,
|
|
14
|
+
cursorAdapter,
|
|
15
|
+
vscodeAdapter,
|
|
16
|
+
windsurfAdapter,
|
|
17
|
+
zedAdapter,
|
|
18
|
+
clineAdapter,
|
|
19
|
+
geminiCliAdapter,
|
|
20
|
+
];
|
|
21
|
+
/** Register every built-in adapter into the shared registry. Idempotent. */
|
|
22
|
+
export function registerAll() {
|
|
23
|
+
for (const adapter of ALL_ADAPTERS)
|
|
24
|
+
registerAdapter(adapter);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=all.js.map
|
package/dist/all.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all.js","sourceRoot":"","sources":["../src/all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,iDAAiD;AACjD,MAAM,CAAC,MAAM,YAAY,GAA6B;IACpD,iBAAiB;IACjB,oBAAoB;IACpB,aAAa;IACb,aAAa;IACb,eAAe;IACf,UAAU;IACV,YAAY;IACZ,gBAAgB;CACjB,CAAC;AAEF,4EAA4E;AAC5E,MAAM,UAAU,WAAW;IACzB,KAAK,MAAM,OAAO,IAAI,YAAY;QAAE,eAAe,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code adapter (S2.4). Root key `mcpServers` with an explicit per-server `type`
|
|
3
|
+
* field (`stdio` | `http`). Changes are picked up by starting a **new session** (not an
|
|
4
|
+
* app restart), so needsRestart is false. Paths:
|
|
5
|
+
* - user: ~/.claude.json
|
|
6
|
+
* - project: <projectPath>/.mcp.json
|
|
7
|
+
*/
|
|
8
|
+
export declare const claudeCodeAdapter: import("./types.js").ClientAdapter;
|
|
9
|
+
//# sourceMappingURL=claude-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../src/claude-code.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,oCAU5B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createMcpServersAdapter } from './shared.js';
|
|
2
|
+
import { expandHome, joinFor, realOsContext } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code adapter (S2.4). Root key `mcpServers` with an explicit per-server `type`
|
|
5
|
+
* field (`stdio` | `http`). Changes are picked up by starting a **new session** (not an
|
|
6
|
+
* app restart), so needsRestart is false. Paths:
|
|
7
|
+
* - user: ~/.claude.json
|
|
8
|
+
* - project: <projectPath>/.mcp.json
|
|
9
|
+
*/
|
|
10
|
+
export const claudeCodeAdapter = createMcpServersAdapter({
|
|
11
|
+
id: 'claude-code',
|
|
12
|
+
secretStrategy: 'shim',
|
|
13
|
+
needsRestart: false,
|
|
14
|
+
includeType: true,
|
|
15
|
+
resolvePath(scope, projectPath, ctx = realOsContext()) {
|
|
16
|
+
if (scope === 'user')
|
|
17
|
+
return joinFor(ctx, ctx.home, '.claude.json');
|
|
18
|
+
if (!projectPath)
|
|
19
|
+
throw new Error('Claude Code project scope requires a project path.');
|
|
20
|
+
return joinFor(ctx, expandHome(projectPath, ctx.home), '.mcp.json');
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../src/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;IACvD,EAAE,EAAE,aAAa;IACjB,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,IAAI;IACjB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,MAAiB,aAAa,EAAE;QAC9D,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxF,OAAO,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;IACtE,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Desktop adapter (S2.3). Root key `mcpServers`, **user scope only** (no project),
|
|
3
|
+
* and the app must be **restarted** to pick up changes (needsRestart=true) — which `sync`
|
|
4
|
+
* surfaces to the user. Path per OS:
|
|
5
|
+
* - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
6
|
+
* - Windows: %APPDATA%\Claude\claude_desktop_config.json
|
|
7
|
+
* - Linux: ~/.config/Claude/claude_desktop_config.json
|
|
8
|
+
*/
|
|
9
|
+
export declare const claudeDesktopAdapter: import("./types.js").ClientAdapter;
|
|
10
|
+
//# sourceMappingURL=claude-desktop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-desktop.d.ts","sourceRoot":"","sources":["../src/claude-desktop.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,oCAU/B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createMcpServersAdapter } from './shared.js';
|
|
2
|
+
import { joinFor, realOsContext, userConfigDir } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Claude Desktop adapter (S2.3). Root key `mcpServers`, **user scope only** (no project),
|
|
5
|
+
* and the app must be **restarted** to pick up changes (needsRestart=true) — which `sync`
|
|
6
|
+
* surfaces to the user. Path per OS:
|
|
7
|
+
* - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
8
|
+
* - Windows: %APPDATA%\Claude\claude_desktop_config.json
|
|
9
|
+
* - Linux: ~/.config/Claude/claude_desktop_config.json
|
|
10
|
+
*/
|
|
11
|
+
export const claudeDesktopAdapter = createMcpServersAdapter({
|
|
12
|
+
id: 'claude-desktop',
|
|
13
|
+
secretStrategy: 'shim',
|
|
14
|
+
needsRestart: true,
|
|
15
|
+
resolvePath(scope, _projectPath, ctx = realOsContext()) {
|
|
16
|
+
if (scope !== 'user') {
|
|
17
|
+
throw new Error('Claude Desktop only supports user scope (no project/workspace config).');
|
|
18
|
+
}
|
|
19
|
+
return joinFor(ctx, userConfigDir(ctx), 'Claude', 'claude_desktop_config.json');
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=claude-desktop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-desktop.js","sourceRoot":"","sources":["../src/claude-desktop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGnE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;IAC1D,EAAE,EAAE,gBAAgB;IACpB,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,IAAI;IAClB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAiB,aAAa,EAAE;QAC/D,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,4BAA4B,CAAC,CAAC;IAClF,CAAC;CACF,CAAC,CAAC"}
|
package/dist/cline.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cline adapter (S14.1). Cline is a VS Code extension that stores its MCP servers under the `mcpServers`
|
|
3
|
+
* root key in the extension's global storage; it hot-reloads (no restart). User-scope path:
|
|
4
|
+
*
|
|
5
|
+
* <VS Code User dir>/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
|
|
6
|
+
*
|
|
7
|
+
* where the VS Code User dir is %APPDATA%/Code/User (win), ~/Library/Application Support/Code/User
|
|
8
|
+
* (mac), or $XDG_CONFIG_HOME/Code/User (linux). Cline has no project scope.
|
|
9
|
+
*/
|
|
10
|
+
export declare const clineAdapter: import("./types.js").ClientAdapter;
|
|
11
|
+
//# sourceMappingURL=cline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cline.d.ts","sourceRoot":"","sources":["../src/cline.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,oCAiBvB,CAAC"}
|
package/dist/cline.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createMcpServersAdapter } from './shared.js';
|
|
2
|
+
import { joinFor, realOsContext, userConfigDir } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Cline adapter (S14.1). Cline is a VS Code extension that stores its MCP servers under the `mcpServers`
|
|
5
|
+
* root key in the extension's global storage; it hot-reloads (no restart). User-scope path:
|
|
6
|
+
*
|
|
7
|
+
* <VS Code User dir>/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
|
|
8
|
+
*
|
|
9
|
+
* where the VS Code User dir is %APPDATA%/Code/User (win), ~/Library/Application Support/Code/User
|
|
10
|
+
* (mac), or $XDG_CONFIG_HOME/Code/User (linux). Cline has no project scope.
|
|
11
|
+
*/
|
|
12
|
+
export const clineAdapter = createMcpServersAdapter({
|
|
13
|
+
id: 'cline',
|
|
14
|
+
secretStrategy: 'shim',
|
|
15
|
+
needsRestart: false,
|
|
16
|
+
resolvePath(scope, _projectPath, ctx = realOsContext()) {
|
|
17
|
+
if (scope !== 'user')
|
|
18
|
+
throw new Error('Cline only supports user scope.');
|
|
19
|
+
return joinFor(ctx, userConfigDir(ctx), 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=cline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cline.js","sourceRoot":"","sources":["../src/cline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGnE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,uBAAuB,CAAC;IAClD,EAAE,EAAE,OAAO;IACX,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,KAAK;IACnB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAiB,aAAa,EAAE;QAC/D,IAAI,KAAK,KAAK,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACzE,OAAO,OAAO,CACZ,GAAG,EACH,aAAa,CAAC,GAAG,CAAC,EAClB,MAAM,EACN,MAAM,EACN,eAAe,EACf,wBAAwB,EACxB,UAAU,EACV,yBAAyB,CAC1B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/cursor.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor adapter (S2.2, spec §5). Root key `mcpServers`, hot-reload (no restart),
|
|
3
|
+
* default `shim` secret strategy. User config lives at `~/.cursor/mcp.json`; project
|
|
4
|
+
* config at `<projectPath>/.cursor/mcp.json`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const cursorAdapter: import("./types.js").ClientAdapter;
|
|
7
|
+
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,aAAa,oCASxB,CAAC"}
|
package/dist/cursor.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createMcpServersAdapter } from './shared.js';
|
|
2
|
+
import { expandHome, joinFor, realOsContext } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Cursor adapter (S2.2, spec §5). Root key `mcpServers`, hot-reload (no restart),
|
|
5
|
+
* default `shim` secret strategy. User config lives at `~/.cursor/mcp.json`; project
|
|
6
|
+
* config at `<projectPath>/.cursor/mcp.json`.
|
|
7
|
+
*/
|
|
8
|
+
export const cursorAdapter = createMcpServersAdapter({
|
|
9
|
+
id: 'cursor',
|
|
10
|
+
secretStrategy: 'shim',
|
|
11
|
+
needsRestart: false,
|
|
12
|
+
resolvePath(scope, projectPath, ctx = realOsContext()) {
|
|
13
|
+
if (scope === 'user')
|
|
14
|
+
return joinFor(ctx, ctx.home, '.cursor', 'mcp.json');
|
|
15
|
+
if (!projectPath)
|
|
16
|
+
throw new Error('Cursor project/workspace scope requires a project path.');
|
|
17
|
+
return joinFor(ctx, expandHome(projectPath, ctx.home), '.cursor', 'mcp.json');
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAC;IACnD,EAAE,EAAE,QAAQ;IACZ,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,KAAK;IACnB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,MAAiB,aAAa,EAAE;QAC9D,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAC3E,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7F,OAAO,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IAChF,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini CLI adapter (S14.1). The Gemini CLI reads MCP servers from the `mcpServers` root of
|
|
3
|
+
* `~/.gemini/settings.json` and picks them up on the next run (no restart). User scope only.
|
|
4
|
+
*/
|
|
5
|
+
export declare const geminiCliAdapter: import("./types.js").ClientAdapter;
|
|
6
|
+
//# sourceMappingURL=gemini-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-cli.d.ts","sourceRoot":"","sources":["../src/gemini-cli.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,oCAQ3B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createMcpServersAdapter } from './shared.js';
|
|
2
|
+
import { joinFor, realOsContext } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gemini CLI adapter (S14.1). The Gemini CLI reads MCP servers from the `mcpServers` root of
|
|
5
|
+
* `~/.gemini/settings.json` and picks them up on the next run (no restart). User scope only.
|
|
6
|
+
*/
|
|
7
|
+
export const geminiCliAdapter = createMcpServersAdapter({
|
|
8
|
+
id: 'gemini-cli',
|
|
9
|
+
secretStrategy: 'shim',
|
|
10
|
+
needsRestart: false,
|
|
11
|
+
resolvePath(scope, _projectPath, ctx = realOsContext()) {
|
|
12
|
+
if (scope !== 'user')
|
|
13
|
+
throw new Error('Gemini CLI only supports user scope.');
|
|
14
|
+
return joinFor(ctx, ctx.home, '.gemini', 'settings.json');
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=gemini-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-cli.js","sourceRoot":"","sources":["../src/gemini-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGpD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;IACtD,EAAE,EAAE,YAAY;IAChB,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,KAAK;IACnB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,MAAiB,aAAa,EAAE;QAC/D,IAAI,KAAK,KAAK,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC9E,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC;CACF,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcpfold/adapters — one module per client. This index exposes the adapter framework
|
|
3
|
+
* (interface, registry, shared helpers, path helpers). Concrete client adapters
|
|
4
|
+
* (S2.2–S2.7) register themselves here as they are implemented.
|
|
5
|
+
*/
|
|
6
|
+
export type { ClientAdapter, OsContext, RenderedFile, SecretStrategy } from './types.js';
|
|
7
|
+
export { expandHome, joinFor, pathFor, realOsContext, userConfigDir } from './paths.js';
|
|
8
|
+
export { createMcpServersAdapter, fromMcpServersShape, toMcpEntry, toMcpServersShape, type McpRemoteEntry, type McpServerEntry, type McpServersAdapterConfig, type McpStdioEntry, type ToEntryOptions, } from './shared.js';
|
|
9
|
+
export { clearAdapters, getAdapter, listAdapters, registerAdapter, requireAdapter, } from './registry.js';
|
|
10
|
+
export { cursorAdapter } from './cursor.js';
|
|
11
|
+
export { claudeDesktopAdapter } from './claude-desktop.js';
|
|
12
|
+
export { claudeCodeAdapter } from './claude-code.js';
|
|
13
|
+
export { vscodeAdapter } from './vscode.js';
|
|
14
|
+
export { windsurfAdapter } from './windsurf.js';
|
|
15
|
+
export { zedAdapter } from './zed.js';
|
|
16
|
+
export { clineAdapter } from './cline.js';
|
|
17
|
+
export { geminiCliAdapter } from './gemini-cli.js';
|
|
18
|
+
export { ALL_ADAPTERS, registerAll } from './all.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzF,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,aAAa,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcpfold/adapters — one module per client. This index exposes the adapter framework
|
|
3
|
+
* (interface, registry, shared helpers, path helpers). Concrete client adapters
|
|
4
|
+
* (S2.2–S2.7) register themselves here as they are implemented.
|
|
5
|
+
*/
|
|
6
|
+
export { expandHome, joinFor, pathFor, realOsContext, userConfigDir } from './paths.js';
|
|
7
|
+
export { createMcpServersAdapter, fromMcpServersShape, toMcpEntry, toMcpServersShape, } from './shared.js';
|
|
8
|
+
export { clearAdapters, getAdapter, listAdapters, registerAdapter, requireAdapter, } from './registry.js';
|
|
9
|
+
// Concrete client adapters (S2.2–S2.7)
|
|
10
|
+
export { cursorAdapter } from './cursor.js';
|
|
11
|
+
export { claudeDesktopAdapter } from './claude-desktop.js';
|
|
12
|
+
export { claudeCodeAdapter } from './claude-code.js';
|
|
13
|
+
export { vscodeAdapter } from './vscode.js';
|
|
14
|
+
export { windsurfAdapter } from './windsurf.js';
|
|
15
|
+
export { zedAdapter } from './zed.js';
|
|
16
|
+
export { clineAdapter } from './cline.js';
|
|
17
|
+
export { geminiCliAdapter } from './gemini-cli.js';
|
|
18
|
+
export { ALL_ADAPTERS, registerAll } from './all.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACV,iBAAiB,GAMlB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,aAAa,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import type { OsContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Cross-platform path helpers (S2.1). Every path-resolving function has explicit
|
|
5
|
+
* win32/darwin/linux behavior and is tested per-OS by injecting an {@link OsContext} —
|
|
6
|
+
* never assume `~` expands or that the host separator is correct.
|
|
7
|
+
*
|
|
8
|
+
* We use node's `path.win32` / `path.posix` sub-modules (not the ambient `path`) so a
|
|
9
|
+
* win32 path resolves correctly even when the tests run on a Linux CI runner.
|
|
10
|
+
*/
|
|
11
|
+
/** The real OS context for production use. */
|
|
12
|
+
export declare function realOsContext(): OsContext;
|
|
13
|
+
/** The path module matching a platform (backslashes for win32, forward slashes otherwise). */
|
|
14
|
+
export declare function pathFor(platform: NodeJS.Platform): typeof posix;
|
|
15
|
+
/** Expand a leading `~` to the given home directory. Only a leading `~` is expanded. */
|
|
16
|
+
export declare function expandHome(inputPath: string, home: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* The base directory a client stores user-scope app config under:
|
|
19
|
+
* - win32: %APPDATA% (fallback ~/AppData/Roaming)
|
|
20
|
+
* - darwin: ~/Library/Application Support
|
|
21
|
+
* - linux: $XDG_CONFIG_HOME (fallback ~/.config)
|
|
22
|
+
*/
|
|
23
|
+
export declare function userConfigDir(ctx: OsContext): string;
|
|
24
|
+
/** Join path segments using the separator appropriate for `ctx.platform`. */
|
|
25
|
+
export declare function joinFor(ctx: OsContext, ...segments: string[]): string;
|
|
26
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAS,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;GAOG;AAEH,8CAA8C;AAC9C,wBAAgB,aAAa,IAAI,SAAS,CAEzC;AAED,8FAA8F;AAC9F,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,KAAK,CAE/D;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CASpD;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAErE"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { posix, win32 } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Cross-platform path helpers (S2.1). Every path-resolving function has explicit
|
|
5
|
+
* win32/darwin/linux behavior and is tested per-OS by injecting an {@link OsContext} —
|
|
6
|
+
* never assume `~` expands or that the host separator is correct.
|
|
7
|
+
*
|
|
8
|
+
* We use node's `path.win32` / `path.posix` sub-modules (not the ambient `path`) so a
|
|
9
|
+
* win32 path resolves correctly even when the tests run on a Linux CI runner.
|
|
10
|
+
*/
|
|
11
|
+
/** The real OS context for production use. */
|
|
12
|
+
export function realOsContext() {
|
|
13
|
+
return { platform: process.platform, home: homedir(), env: process.env };
|
|
14
|
+
}
|
|
15
|
+
/** The path module matching a platform (backslashes for win32, forward slashes otherwise). */
|
|
16
|
+
export function pathFor(platform) {
|
|
17
|
+
return platform === 'win32' ? win32 : posix;
|
|
18
|
+
}
|
|
19
|
+
/** Expand a leading `~` to the given home directory. Only a leading `~` is expanded. */
|
|
20
|
+
export function expandHome(inputPath, home) {
|
|
21
|
+
if (inputPath === '~')
|
|
22
|
+
return home;
|
|
23
|
+
if (inputPath.startsWith('~/') || inputPath.startsWith('~\\')) {
|
|
24
|
+
return home + inputPath.slice(1);
|
|
25
|
+
}
|
|
26
|
+
return inputPath;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The base directory a client stores user-scope app config under:
|
|
30
|
+
* - win32: %APPDATA% (fallback ~/AppData/Roaming)
|
|
31
|
+
* - darwin: ~/Library/Application Support
|
|
32
|
+
* - linux: $XDG_CONFIG_HOME (fallback ~/.config)
|
|
33
|
+
*/
|
|
34
|
+
export function userConfigDir(ctx) {
|
|
35
|
+
const p = pathFor(ctx.platform);
|
|
36
|
+
if (ctx.platform === 'win32') {
|
|
37
|
+
return ctx.env.APPDATA ?? p.join(ctx.home, 'AppData', 'Roaming');
|
|
38
|
+
}
|
|
39
|
+
if (ctx.platform === 'darwin') {
|
|
40
|
+
return p.join(ctx.home, 'Library', 'Application Support');
|
|
41
|
+
}
|
|
42
|
+
return ctx.env.XDG_CONFIG_HOME ?? p.join(ctx.home, '.config');
|
|
43
|
+
}
|
|
44
|
+
/** Join path segments using the separator appropriate for `ctx.platform`. */
|
|
45
|
+
export function joinFor(ctx, ...segments) {
|
|
46
|
+
return pathFor(ctx.platform).join(...segments);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGzC;;;;;;;GAOG;AAEH,8CAA8C;AAC9C,MAAM,UAAU,aAAa;IAC3B,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;AAC3E,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,OAAO,CAAC,QAAyB;IAC/C,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3E,CAAC;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an adapter by its client id. */
|
|
4
|
+
export declare function registerAdapter(adapter: ClientAdapter): void;
|
|
5
|
+
/** Look up an adapter, or `undefined` if none is registered for the id. */
|
|
6
|
+
export declare function getAdapter(id: string): ClientAdapter | undefined;
|
|
7
|
+
/** Look up an adapter, throwing a descriptive error if it is missing. */
|
|
8
|
+
export declare function requireAdapter(id: ClientId): ClientAdapter;
|
|
9
|
+
/** All registered adapters, sorted by id for deterministic iteration. */
|
|
10
|
+
export declare function listAdapters(): ClientAdapter[];
|
|
11
|
+
/** Remove every registered adapter (test isolation). */
|
|
12
|
+
export declare function clearAdapters(): void;
|
|
13
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAShD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAE5D;AAED,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEhE;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,aAAa,CAO1D;AAED,yEAAyE;AACzE,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAE9C;AAED,wDAAwD;AACxD,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adapter registry (S2.1) — the single lookup the CLI uses to go from a client id to
|
|
3
|
+
* its adapter. Concrete adapters self-register (see each adapter module + registerAll).
|
|
4
|
+
*/
|
|
5
|
+
const registry = new Map();
|
|
6
|
+
/** Register (or replace) an adapter by its client id. */
|
|
7
|
+
export function registerAdapter(adapter) {
|
|
8
|
+
registry.set(adapter.id, adapter);
|
|
9
|
+
}
|
|
10
|
+
/** Look up an adapter, or `undefined` if none is registered for the id. */
|
|
11
|
+
export function getAdapter(id) {
|
|
12
|
+
return registry.get(id);
|
|
13
|
+
}
|
|
14
|
+
/** Look up an adapter, throwing a descriptive error if it is missing. */
|
|
15
|
+
export function requireAdapter(id) {
|
|
16
|
+
const adapter = registry.get(id);
|
|
17
|
+
if (!adapter) {
|
|
18
|
+
const known = [...registry.keys()].sort().join(', ') || '(none registered)';
|
|
19
|
+
throw new Error(`No adapter registered for client "${id}". Registered: ${known}.`);
|
|
20
|
+
}
|
|
21
|
+
return adapter;
|
|
22
|
+
}
|
|
23
|
+
/** All registered adapters, sorted by id for deterministic iteration. */
|
|
24
|
+
export function listAdapters() {
|
|
25
|
+
return [...registry.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
26
|
+
}
|
|
27
|
+
/** Remove every registered adapter (test isolation). */
|
|
28
|
+
export function clearAdapters() {
|
|
29
|
+
registry.clear();
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;AAElD,yDAAyD;AACzD,MAAM,UAAU,eAAe,CAAC,OAAsB;IACpD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAAC,EAAY;IACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,qCAAqC,EAAE,kBAAkB,KAAK,GAAG,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,YAAY;IAC1B,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,aAAa;IAC3B,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ClientId, type Config, type ResolvedServer } from '@mcpfold/core';
|
|
2
|
+
import type { ClientAdapter, OsContext, SecretStrategy } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Shared helpers for the many clients that use the `mcpServers`-style shape (Cursor,
|
|
5
|
+
* Claude Desktop, Claude Code, and — with a different root key — Zed). Each native entry
|
|
6
|
+
* is either a stdio launch (`command`/`args`/`env`) or a remote endpoint (`url`/`headers`).
|
|
7
|
+
*
|
|
8
|
+
* NOTE: secret injection (bearer token → Authorization header, or the shim launcher) is
|
|
9
|
+
* layered on at S4.6. At S2.1 render is purely structural: `auth.headers` (which may hold
|
|
10
|
+
* refs) pass through; the bearer `auth.token` is intentionally NOT written here.
|
|
11
|
+
*/
|
|
12
|
+
export interface McpStdioEntry {
|
|
13
|
+
type?: 'stdio';
|
|
14
|
+
command: string;
|
|
15
|
+
args?: string[];
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export interface McpRemoteEntry {
|
|
19
|
+
type?: 'http' | 'sse';
|
|
20
|
+
url: string;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export type McpServerEntry = McpStdioEntry | McpRemoteEntry;
|
|
24
|
+
export interface ToEntryOptions {
|
|
25
|
+
/** Emit an explicit `type` field (Claude Code does; others infer from command/url). */
|
|
26
|
+
includeType?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Map one resolved server to its native `mcpServers`-style entry. */
|
|
29
|
+
export declare function toMcpEntry(server: ResolvedServer, options?: ToEntryOptions): McpServerEntry;
|
|
30
|
+
/** Build the `{ [name]: entry }` map from resolved servers. */
|
|
31
|
+
export declare function toMcpServersShape(servers: ResolvedServer[], options?: ToEntryOptions): Record<string, McpServerEntry>;
|
|
32
|
+
/**
|
|
33
|
+
* Parse an `mcpServers`-style object back to a canonical partial (powers `import` + drift).
|
|
34
|
+
* Transport is inferred: `command` → stdio, `url` → http (or the explicit `type`).
|
|
35
|
+
*/
|
|
36
|
+
export declare function fromMcpServersShape(raw: unknown): Partial<Config>;
|
|
37
|
+
export interface McpServersAdapterConfig {
|
|
38
|
+
id: ClientId;
|
|
39
|
+
/** Native root key. Default `mcpServers`; VS Code uses `servers`, Zed `context_servers`. */
|
|
40
|
+
rootKey?: string;
|
|
41
|
+
secretStrategy?: SecretStrategy;
|
|
42
|
+
needsRestart?: boolean;
|
|
43
|
+
/** Emit an explicit per-server `type` field (Claude Code). */
|
|
44
|
+
includeType?: boolean;
|
|
45
|
+
/** Client-specific path resolution. */
|
|
46
|
+
resolvePath: (scope: Parameters<ClientAdapter['resolvePath']>[0], projectPath?: string, ctx?: OsContext) => string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build a {@link ClientAdapter} for an `mcpServers`-style client. Reused by Cursor,
|
|
50
|
+
* Claude Desktop, and Claude Code — each supplies only its path resolution and quirks.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createMcpServersAdapter(config: McpServersAdapterConfig): ClientAdapter;
|
|
53
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,cAAc,EAEpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzF;;;;;;;;GAQG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,cAAc,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,GAAE,cAAmB,GAAG,cAAc,CAY/F;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,OAAO,GAAE,cAAmB,GAC3B,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAIhC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBjE;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,QAAQ,CAAC;IACb,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uCAAuC;IACvC,WAAW,EAAE,CACX,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAClD,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,SAAS,KACZ,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,aAAa,CAyBtF"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { serialize, } from '@mcpfold/core';
|
|
2
|
+
import { realOsContext } from './paths.js';
|
|
3
|
+
/** Map one resolved server to its native `mcpServers`-style entry. */
|
|
4
|
+
export function toMcpEntry(server, options = {}) {
|
|
5
|
+
if (server.transport === 'stdio') {
|
|
6
|
+
const entry = { command: server.command ?? '' };
|
|
7
|
+
if (options.includeType)
|
|
8
|
+
entry.type = 'stdio';
|
|
9
|
+
if (server.args)
|
|
10
|
+
entry.args = server.args;
|
|
11
|
+
if (server.env)
|
|
12
|
+
entry.env = server.env;
|
|
13
|
+
return entry;
|
|
14
|
+
}
|
|
15
|
+
const entry = { url: server.url ?? '' };
|
|
16
|
+
if (options.includeType)
|
|
17
|
+
entry.type = server.transport === 'sse' ? 'sse' : 'http';
|
|
18
|
+
if (server.auth?.headers)
|
|
19
|
+
entry.headers = server.auth.headers;
|
|
20
|
+
return entry;
|
|
21
|
+
}
|
|
22
|
+
/** Build the `{ [name]: entry }` map from resolved servers. */
|
|
23
|
+
export function toMcpServersShape(servers, options = {}) {
|
|
24
|
+
const out = {};
|
|
25
|
+
for (const server of servers)
|
|
26
|
+
out[server.name] = toMcpEntry(server, options);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse an `mcpServers`-style object back to a canonical partial (powers `import` + drift).
|
|
31
|
+
* Transport is inferred: `command` → stdio, `url` → http (or the explicit `type`).
|
|
32
|
+
*/
|
|
33
|
+
export function fromMcpServersShape(raw) {
|
|
34
|
+
const servers = {};
|
|
35
|
+
if (raw && typeof raw === 'object') {
|
|
36
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
37
|
+
if (!value || typeof value !== 'object')
|
|
38
|
+
continue;
|
|
39
|
+
const entry = value;
|
|
40
|
+
if (typeof entry.command === 'string') {
|
|
41
|
+
const server = { transport: 'stdio', command: entry.command, tags: [] };
|
|
42
|
+
if (Array.isArray(entry.args))
|
|
43
|
+
server.args = entry.args;
|
|
44
|
+
if (entry.env && typeof entry.env === 'object') {
|
|
45
|
+
server.env = entry.env;
|
|
46
|
+
}
|
|
47
|
+
servers[name] = server;
|
|
48
|
+
}
|
|
49
|
+
else if (typeof entry.url === 'string') {
|
|
50
|
+
const explicitType = entry.type === 'sse' ? 'sse' : 'http';
|
|
51
|
+
const server = { transport: explicitType, url: entry.url, tags: [] };
|
|
52
|
+
if (entry.headers && typeof entry.headers === 'object') {
|
|
53
|
+
server.auth = { type: 'header', headers: entry.headers };
|
|
54
|
+
}
|
|
55
|
+
servers[name] = server;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { servers };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Build a {@link ClientAdapter} for an `mcpServers`-style client. Reused by Cursor,
|
|
63
|
+
* Claude Desktop, and Claude Code — each supplies only its path resolution and quirks.
|
|
64
|
+
*/
|
|
65
|
+
export function createMcpServersAdapter(config) {
|
|
66
|
+
const rootKey = config.rootKey ?? 'mcpServers';
|
|
67
|
+
const secretStrategy = config.secretStrategy ?? 'shim';
|
|
68
|
+
const needsRestart = config.needsRestart ?? false;
|
|
69
|
+
return {
|
|
70
|
+
id: config.id,
|
|
71
|
+
secretStrategy,
|
|
72
|
+
needsRestart,
|
|
73
|
+
resolvePath: config.resolvePath,
|
|
74
|
+
render(servers, ctx = realOsContext()) {
|
|
75
|
+
const shape = toMcpServersShape(servers, { includeType: config.includeType });
|
|
76
|
+
const scope = servers[0]?.scope ?? 'user';
|
|
77
|
+
const projectPath = servers[0]?.projectPath;
|
|
78
|
+
return {
|
|
79
|
+
path: config.resolvePath(scope, projectPath, ctx),
|
|
80
|
+
contents: serialize({ [rootKey]: shape }),
|
|
81
|
+
needsRestart,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
parse(contents) {
|
|
85
|
+
const raw = JSON.parse(contents);
|
|
86
|
+
return fromMcpServersShape(raw[rootKey]);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAKV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAgC3C,sEAAsE;AACtE,MAAM,UAAU,UAAU,CAAC,MAAsB,EAAE,UAA0B,EAAE;IAC7E,IAAI,MAAM,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,KAAK,GAAkB,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,WAAW;YAAE,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC;QAC9C,IAAI,MAAM,CAAC,IAAI;YAAE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QAC1C,IAAI,MAAM,CAAC,GAAG;YAAE,KAAK,C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AK,CAAC;IAElD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,cAAc;QACd,YAAY;QACZ,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,aAAa,EAAE;YACnC,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9E,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,MAAM,CAAC;YAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC;YAC5C,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,CAAC;gBACjD,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;gBACzC,YAAY;aACb,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,QAAQ;YACZ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA4B,CAAC;YAC5D,OAAO,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ClientId, Config, ResolvedServer, Scope } from '@mcpfold/core';
|
|
2
|
+
/**
|
|
3
|
+
* The adapter interface (S2.1, spec §5) — the heart of mcpfold's client portability.
|
|
4
|
+
*
|
|
5
|
+
* Every client is one small module implementing {@link ClientAdapter}. Adding a client is
|
|
6
|
+
* one PR with no engine changes. All the per-client format churn (root key, path, restart
|
|
7
|
+
* semantics, secret strategy) is quarantined here.
|
|
8
|
+
*/
|
|
9
|
+
/** How a client wants secrets handled (spec §6). */
|
|
10
|
+
export type SecretStrategy = 'inline' | 'native-input' | 'shim';
|
|
11
|
+
/** A native config file mcpfold would write for a client. */
|
|
12
|
+
export interface RenderedFile {
|
|
13
|
+
/** Absolute, OS-resolved path. */
|
|
14
|
+
path: string;
|
|
15
|
+
/** Serialized native config (deterministic — always via core `serialize()`). */
|
|
16
|
+
contents: string;
|
|
17
|
+
/** Whether the client must restart to pick up the change (Claude Desktop: yes). */
|
|
18
|
+
needsRestart: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Injectable OS context so path resolution is testable per-platform without touching the
|
|
22
|
+
* real environment. Adapters default to {@link realOsContext} in production.
|
|
23
|
+
*/
|
|
24
|
+
export interface OsContext {
|
|
25
|
+
platform: NodeJS.Platform;
|
|
26
|
+
home: string;
|
|
27
|
+
env: NodeJS.ProcessEnv;
|
|
28
|
+
}
|
|
29
|
+
export interface ClientAdapter {
|
|
30
|
+
/** The client id this adapter serves (matches the canonical profile `client`). */
|
|
31
|
+
readonly id: ClientId;
|
|
32
|
+
/** Default secret strategy for this client. */
|
|
33
|
+
readonly secretStrategy: SecretStrategy;
|
|
34
|
+
/** Whether writing this client's config requires a restart to take effect. */
|
|
35
|
+
readonly needsRestart: boolean;
|
|
36
|
+
/** Resolve the on-disk config path for a scope/project on a given OS. */
|
|
37
|
+
resolvePath(scope: Scope, projectPath?: string, ctx?: OsContext): string;
|
|
38
|
+
/** Render already-resolved (secret-ref-preserving) servers to a native file. */
|
|
39
|
+
render(servers: ResolvedServer[], ctx?: OsContext): RenderedFile;
|
|
40
|
+
/** Parse a native file back to a canonical partial. Powers `import` and drift detection. */
|
|
41
|
+
parse(contents: string): Partial<Config>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE7E;;;;;;GAMG;AAEH,oDAAoD;AACpD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,cAAc,GAAG,MAAM,CAAC;AAEhE,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAE/B,yEAAyE;IACzE,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAEzE,gFAAgF;IAChF,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,GAAG,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAEjE,4FAA4F;IAC5F,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1C"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/vscode.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vscode.d.ts","sourceRoot":"","sources":["../src/vscode.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,YAAY,CAAC;AAgFzE,eAAO,MAAM,aAAa,EAAE,aA4D3B,CAAC"}
|
package/dist/vscode.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { serialize, isSecretRef, } from '@mcpfold/core';
|
|
2
|
+
import { joinFor, realOsContext, userConfigDir } from './paths.js';
|
|
3
|
+
function inputId(serverName, key) {
|
|
4
|
+
return `${serverName}-${key}`.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
5
|
+
}
|
|
6
|
+
function toVscodeEntry(server) {
|
|
7
|
+
const inputs = [];
|
|
8
|
+
if (server.transport === 'stdio') {
|
|
9
|
+
const entry = { type: 'stdio', command: server.command ?? '' };
|
|
10
|
+
if (server.args)
|
|
11
|
+
entry.args = server.args;
|
|
12
|
+
if (server.env)
|
|
13
|
+
entry.env = server.env;
|
|
14
|
+
return { entry, inputs };
|
|
15
|
+
}
|
|
16
|
+
const entry = {
|
|
17
|
+
type: server.transport === 'sse' ? 'sse' : 'http',
|
|
18
|
+
url: server.url ?? '',
|
|
19
|
+
};
|
|
20
|
+
const headers = {};
|
|
21
|
+
// Bearer token → Authorization header backed by a prompted input.
|
|
22
|
+
if (server.auth?.type === 'bearer' && server.auth.token) {
|
|
23
|
+
const id = inputId(server.name, 'token');
|
|
24
|
+
headers.Authorization = `Bearer \${input:${id}}`;
|
|
25
|
+
inputs.push({
|
|
26
|
+
id,
|
|
27
|
+
type: 'promptString',
|
|
28
|
+
description: `Token for ${server.name}`,
|
|
29
|
+
password: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Explicit headers: secret refs become inputs; literals pass through.
|
|
33
|
+
for (const [name, value] of Object.entries(server.auth?.headers ?? {})) {
|
|
34
|
+
if (isSecretRef(value)) {
|
|
35
|
+
const id = inputId(server.name, name);
|
|
36
|
+
headers[name] = `\${input:${id}}`;
|
|
37
|
+
inputs.push({
|
|
38
|
+
id,
|
|
39
|
+
type: 'promptString',
|
|
40
|
+
description: `${name} for ${server.name}`,
|
|
41
|
+
password: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
headers[name] = value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (Object.keys(headers).length > 0)
|
|
49
|
+
entry.headers = headers;
|
|
50
|
+
return { entry, inputs };
|
|
51
|
+
}
|
|
52
|
+
export const vscodeAdapter = {
|
|
53
|
+
id: 'vscode',
|
|
54
|
+
secretStrategy: 'native-input',
|
|
55
|
+
needsRestart: false,
|
|
56
|
+
resolvePath(scope, projectPath, ctx = realOsContext()) {
|
|
57
|
+
if (scope === 'workspace' || scope === 'project') {
|
|
58
|
+
if (!projectPath)
|
|
59
|
+
throw new Error('VS Code workspace scope requires a project path.');
|
|
60
|
+
return joinFor(ctx, projectPath, '.vscode', 'mcp.json');
|
|
61
|
+
}
|
|
62
|
+
// User profile mcp.json (per OS).
|
|
63
|
+
return joinFor(ctx, userConfigDir(ctx), 'Code', 'User', 'mcp.json');
|
|
64
|
+
},
|
|
65
|
+
render(servers, ctx = realOsContext()) {
|
|
66
|
+
const serversObj = {};
|
|
67
|
+
const inputsById = new Map();
|
|
68
|
+
for (const server of servers) {
|
|
69
|
+
const { entry, inputs } = toVscodeEntry(server);
|
|
70
|
+
serversObj[server.name] = entry;
|
|
71
|
+
for (const input of inputs)
|
|
72
|
+
inputsById.set(input.id, input);
|
|
73
|
+
}
|
|
74
|
+
const inputs = [...inputsById.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
75
|
+
const scope = servers[0]?.scope ?? 'user';
|
|
76
|
+
const projectPath = servers[0]?.projectPath;
|
|
77
|
+
// NOTE the root key is "servers", not "mcpServers".
|
|
78
|
+
return {
|
|
79
|
+
path: this.resolvePath(scope, projectPath, ctx),
|
|
80
|
+
contents: serialize({ servers: serversObj, inputs }),
|
|
81
|
+
needsRestart: false,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
parse(contents) {
|
|
85
|
+
const raw = JSON.parse(contents);
|
|
86
|
+
const servers = {};
|
|
87
|
+
for (const [name, value] of Object.entries(raw.servers ?? {})) {
|
|
88
|
+
if (!value || typeof value !== 'object')
|
|
89
|
+
continue;
|
|
90
|
+
const entry = value;
|
|
91
|
+
if (entry.type === 'stdio' || typeof entry.command === 'string') {
|
|
92
|
+
const server = {
|
|
93
|
+
transport: 'stdio',
|
|
94
|
+
command: String(entry.command ?? ''),
|
|
95
|
+
tags: [],
|
|
96
|
+
};
|
|
97
|
+
if (Array.isArray(entry.args))
|
|
98
|
+
server.args = entry.args;
|
|
99
|
+
if (entry.env && typeof entry.env === 'object')
|
|
100
|
+
server.env = entry.env;
|
|
101
|
+
servers[name] = server;
|
|
102
|
+
}
|
|
103
|
+
else if (typeof entry.url === 'string') {
|
|
104
|
+
const t = entry.type === 'sse' ? 'sse' : 'http';
|
|
105
|
+
const server = { transport: t, url: entry.url, tags: [] };
|
|
106
|
+
if (entry.headers && typeof entry.headers === 'object') {
|
|
107
|
+
server.auth = { type: 'header', headers: entry.headers };
|
|
108
|
+
}
|
|
109
|
+
servers[name] = server;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { servers };
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=vscode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vscode.js","sourceRoot":"","sources":["../src/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,GAIZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA6BnE,SAAS,OAAO,CAAC,UAAkB,EAAE,GAAW;IAC9C,OAAO,GAAG,UAAU,IAAI,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,aAAa,CAAC,M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AAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windsurf.d.ts","sourceRoot":"","sources":["../src/windsurf.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAA2B,MAAM,YAAY,CAAC;AA6DzE,eAAO,MAAM,eAAe,EAAE,aAuD7B,CAAC"}
|
package/dist/windsurf.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { serialize } from '@mcpfold/core';
|
|
2
|
+
import { joinFor, realOsContext } from './paths.js';
|
|
3
|
+
function needsRemoteWrapper(server) {
|
|
4
|
+
const isRemote = server.transport === 'http' || server.transport === 'sse';
|
|
5
|
+
const hasAuth = Boolean(server.auth && server.auth.type !== 'none');
|
|
6
|
+
return isRemote && hasAuth;
|
|
7
|
+
}
|
|
8
|
+
function headerArgs(server) {
|
|
9
|
+
const args = [];
|
|
10
|
+
if (server.auth?.type === 'bearer' && server.auth.token) {
|
|
11
|
+
args.push('--header', `Authorization: Bearer ${server.auth.token}`);
|
|
12
|
+
}
|
|
13
|
+
for (const [name, value] of Object.entries(server.auth?.headers ?? {})) {
|
|
14
|
+
args.push('--header', `${name}: ${value}`);
|
|
15
|
+
}
|
|
16
|
+
return args;
|
|
17
|
+
}
|
|
18
|
+
function toWindsurfEntry(server) {
|
|
19
|
+
if (needsRemoteWrapper(server)) {
|
|
20
|
+
return {
|
|
21
|
+
command: 'npx',
|
|
22
|
+
args: ['-y', 'mcp-remote', server.url ?? '', ...headerArgs(server)],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (server.transport === 'stdio') {
|
|
26
|
+
const entry = { command: server.command ?? '' };
|
|
27
|
+
if (server.args)
|
|
28
|
+
entry.args = server.args;
|
|
29
|
+
if (server.env)
|
|
30
|
+
entry.env = server.env;
|
|
31
|
+
return entry;
|
|
32
|
+
}
|
|
33
|
+
const entry = { url: server.url ?? '' };
|
|
34
|
+
if (server.auth?.headers)
|
|
35
|
+
entry.headers = server.auth.headers;
|
|
36
|
+
return entry;
|
|
37
|
+
}
|
|
38
|
+
export const windsurfAdapter = {
|
|
39
|
+
id: 'windsurf',
|
|
40
|
+
secretStrategy: 'shim',
|
|
41
|
+
needsRestart: true,
|
|
42
|
+
resolvePath(_scope, _projectPath, ctx = realOsContext()) {
|
|
43
|
+
// Windsurf keeps MCP config under ~/.codeium/windsurf/mcp_config.json on every OS.
|
|
44
|
+
return joinFor(ctx, ctx.home, '.codeium', 'windsurf', 'mcp_config.json');
|
|
45
|
+
},
|
|
46
|
+
render(servers, ctx = realOsContext()) {
|
|
47
|
+
const mcpServers = {};
|
|
48
|
+
for (const server of servers)
|
|
49
|
+
mcpServers[server.name] = toWindsurfEntry(server);
|
|
50
|
+
return {
|
|
51
|
+
path: this.resolvePath('user', undefined, ctx),
|
|
52
|
+
contents: serialize({ mcpServers }),
|
|
53
|
+
needsRestart: true,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
parse(contents) {
|
|
57
|
+
const raw = JSON.parse(contents);
|
|
58
|
+
const servers = {};
|
|
59
|
+
for (const [name, value] of Object.entries(raw.mcpServers ?? {})) {
|
|
60
|
+
if (!value || typeof value !== 'object')
|
|
61
|
+
continue;
|
|
62
|
+
const entry = value;
|
|
63
|
+
const args = Array.isArray(entry.args) ? entry.args : [];
|
|
64
|
+
const remoteIdx = args.indexOf('mcp-remote');
|
|
65
|
+
if (entry.command === 'npx' && remoteIdx !== -1) {
|
|
66
|
+
// Reverse the mcp-remote wrapper back to a canonical http server.
|
|
67
|
+
const url = args[remoteIdx + 1] ?? '';
|
|
68
|
+
const headers = {};
|
|
69
|
+
for (let i = remoteIdx + 2; i < args.length - 1; i++) {
|
|
70
|
+
if (args[i] === '--header') {
|
|
71
|
+
const raw2 = args[i + 1] ?? '';
|
|
72
|
+
const sep = raw2.indexOf(':');
|
|
73
|
+
if (sep !== -1)
|
|
74
|
+
headers[raw2.slice(0, sep).trim()] = raw2.slice(sep + 1).trim();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const server = { transport: 'http', url, tags: [] };
|
|
78
|
+
if (Object.keys(headers).length > 0)
|
|
79
|
+
server.auth = { type: 'header', headers };
|
|
80
|
+
servers[name] = server;
|
|
81
|
+
}
|
|
82
|
+
else if (typeof entry.command === 'string') {
|
|
83
|
+
const server = { transport: 'stdio', command: entry.command, tags: [] };
|
|
84
|
+
if (args.length > 0)
|
|
85
|
+
server.args = args;
|
|
86
|
+
if (entry.env && typeof entry.env === 'object')
|
|
87
|
+
server.env = entry.env;
|
|
88
|
+
servers[name] = server;
|
|
89
|
+
}
|
|
90
|
+
else if (typeof entry.url === 'string') {
|
|
91
|
+
servers[name] = { transport: 'http', url: entry.url, tags: [] };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { servers };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=windsurf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windsurf.js","sourceRoot":"","sources":["../src/windsurf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuD,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA2BpD,SAAS,kBAAkB,CAAC,MAAsB;IAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,KAAK,MAAM,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,CAAC;IAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IACpE,OAAO,QAAQ,IAAI,OAAO,CAAC;AAC7B,CAAC;AAED,SAAS,UAAU,CAAC,MAAsB;IACxC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK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E,CAAC;gBAC7C,MAAM,MAAM,GAAiB,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBACtF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;oBAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;gBACxC,IAAI,KAAK,CAAC,GAAG,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;oBAC5C,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,GAA6B,CAAC;gBACnD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YACzB,CAAC;iBAAM,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC"}
|
package/dist/zed.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zed adapter (S2.7). Zed diverges on the **root key**: `context_servers`, not
|
|
3
|
+
* `mcpServers`. No restart (needsRestart=false), default `shim` strategy. Entry shape
|
|
4
|
+
* reuses the `mcpServers`-style stdio/remote entries under the Zed root key; Zed context
|
|
5
|
+
* servers are stdio-first. Settings path:
|
|
6
|
+
* - macOS/Linux: ~/.config/zed/settings.json
|
|
7
|
+
* - Windows: %APPDATA%\Zed\settings.json
|
|
8
|
+
*/
|
|
9
|
+
export declare const zedAdapter: import("./types.js").ClientAdapter;
|
|
10
|
+
//# sourceMappingURL=zed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zed.d.ts","sourceRoot":"","sources":["../src/zed.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,oCAYrB,CAAC"}
|
package/dist/zed.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createMcpServersAdapter } from './shared.js';
|
|
2
|
+
import { joinFor, realOsContext } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Zed adapter (S2.7). Zed diverges on the **root key**: `context_servers`, not
|
|
5
|
+
* `mcpServers`. No restart (needsRestart=false), default `shim` strategy. Entry shape
|
|
6
|
+
* reuses the `mcpServers`-style stdio/remote entries under the Zed root key; Zed context
|
|
7
|
+
* servers are stdio-first. Settings path:
|
|
8
|
+
* - macOS/Linux: ~/.config/zed/settings.json
|
|
9
|
+
* - Windows: %APPDATA%\Zed\settings.json
|
|
10
|
+
*/
|
|
11
|
+
export const zedAdapter = createMcpServersAdapter({
|
|
12
|
+
id: 'zed',
|
|
13
|
+
rootKey: 'context_servers',
|
|
14
|
+
secretStrategy: 'shim',
|
|
15
|
+
needsRestart: false,
|
|
16
|
+
resolvePath(_scope, _projectPath, ctx = realOsContext()) {
|
|
17
|
+
if (ctx.platform === 'win32') {
|
|
18
|
+
const appData = ctx.env.APPDATA ?? joinFor(ctx, ctx.home, 'AppData', 'Roaming');
|
|
19
|
+
return joinFor(ctx, appData, 'Zed', 'settings.json');
|
|
20
|
+
}
|
|
21
|
+
return joinFor(ctx, ctx.home, '.config', 'zed', 'settings.json');
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=zed.js.map
|
package/dist/zed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zed.js","sourceRoot":"","sources":["../src/zed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGpD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,uBAAuB,CAAC;IAChD,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,iBAAiB;IAC1B,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,KAAK;IACnB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,MAAiB,aAAa,EAAE;QAChE,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YAChF,OAAO,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;IACnE,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcpfold/adapters",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Client adapters: render canonical mcpfold config to each client's native format and back.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@mcpfold/core": "1.0.0"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/dj-pearson/MCPFold.git",
|
|
27
|
+
"directory": "packages/adapters"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://mcpfold.com",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/dj-pearson/MCPFold/issues"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.build.json",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"lint": "eslint . --max-warnings=0",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
38
|
+
}
|
|
39
|
+
}
|