@openziti/ziti-mcp-server 0.9.0 → 0.11.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/README.md +62 -5
- package/dist/auth/identity-file-flow.d.ts +17 -0
- package/dist/auth/identity-file-flow.js +94 -0
- package/dist/auth/identity-file-flow.js.map +1 -0
- package/dist/clients/claude-code.d.ts +45 -0
- package/dist/clients/claude-code.js +81 -0
- package/dist/clients/claude-code.js.map +1 -0
- package/dist/clients/index.d.ts +6 -0
- package/dist/clients/index.js +8 -0
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/types.d.ts +5 -1
- package/dist/clients/warp.d.ts +27 -0
- package/dist/clients/warp.js +44 -0
- package/dist/clients/warp.js.map +1 -0
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +22 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/run.js +14 -0
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/session.js +21 -2
- package/dist/commands/session.js.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/server.js +3 -2
- package/dist/server.js.map +1 -1
- package/dist/utils/authenticated-client.js +93 -1
- package/dist/utils/authenticated-client.js.map +1 -1
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.js +30 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/fabric-authenticated-client.js +101 -1
- package/dist/utils/fabric-authenticated-client.js.map +1 -1
- package/dist/utils/keychain.d.ts +40 -1
- package/dist/utils/keychain.js +51 -0
- package/dist/utils/keychain.js.map +1 -1
- package/dist/utils/mtls-fetch.d.ts +25 -0
- package/dist/utils/mtls-fetch.js +49 -0
- package/dist/utils/mtls-fetch.js.map +1 -0
- package/dist/utils/types.d.ts +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<div align="center">
|
|
5
5
|
|
|
6
6
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
-
[](https://nodejs.org/)
|
|
8
8
|
[](https://www.npmjs.com/package/@openziti/ziti-mcp-server)
|
|
9
9
|
[](https://www.npmjs.com/package/@openziti/ziti-mcp-server)
|
|
10
10
|
|
|
@@ -38,7 +38,7 @@ The Ziti MCP Server integrates with LLMs and AI agents, allowing you to perform
|
|
|
38
38
|
|
|
39
39
|
**Prerequisites:**
|
|
40
40
|
|
|
41
|
-
- [Node.js
|
|
41
|
+
- [Node.js v20 or higher](https://nodejs.org/en/download)
|
|
42
42
|
- [Claude Desktop](https://claude.ai/download) or any other [MCP Client](https://modelcontextprotocol.io/clients)
|
|
43
43
|
- An IdP account with appropriate permissions ([Auth0](https://auth0.com/) can be used as the IdP)
|
|
44
44
|
- [OpenZiti](https://openziti.io/) network
|
|
@@ -51,6 +51,7 @@ Install Ziti MCP Server and configure it to work with your preferred MCP Client.
|
|
|
51
51
|
|
|
52
52
|
- `device-auth`: Interactive browser-based login (requires `--idp-audience`)
|
|
53
53
|
- `client-credentials`: Service account authentication (requires `--idp-client-secret`)
|
|
54
|
+
- `identity`: Certificate-based authentication using a Ziti identity JSON file (requires `--identity-file`)
|
|
54
55
|
|
|
55
56
|
The `--tools` parameter specifies which tools should be available (defaults to `*` if not provided).
|
|
56
57
|
|
|
@@ -97,6 +98,16 @@ npx @openziti/ziti-mcp-server init \
|
|
|
97
98
|
--tools 'list*,get*'
|
|
98
99
|
```
|
|
99
100
|
|
|
101
|
+
**Identity File Mode (mTLS Certificate)**
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx @openziti/ziti-mcp-server init \
|
|
105
|
+
--auth-mode identity \
|
|
106
|
+
--identity-file <path-to-identity.json>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
No IdP configuration is needed — authentication uses the client certificate from the Ziti identity file.
|
|
110
|
+
|
|
100
111
|
**Windsurf**
|
|
101
112
|
|
|
102
113
|
```bash
|
|
@@ -166,6 +177,34 @@ npx @openziti/ziti-mcp-server init \
|
|
|
166
177
|
--tools 'list*,get*' --read-only
|
|
167
178
|
```
|
|
168
179
|
|
|
180
|
+
**Claude Code**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npx @openziti/ziti-mcp-server init \
|
|
184
|
+
--auth-mode device-auth \
|
|
185
|
+
--client claude-code \
|
|
186
|
+
--ziti-controller-host <host> \
|
|
187
|
+
--idp-domain <domain> \
|
|
188
|
+
--idp-client-id <id> \
|
|
189
|
+
--idp-audience <audience>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The command will prompt you to choose between user scope (`~/.claude.json`) and project scope (`.mcp.json` in the current directory). The configuration automatically includes `defer_loading: true` to enable Claude Code's Tool Search, which loads tools on-demand instead of upfront for optimized context usage.
|
|
193
|
+
|
|
194
|
+
**Warp**
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npx @openziti/ziti-mcp-server init \
|
|
198
|
+
--auth-mode device-auth \
|
|
199
|
+
--client warp \
|
|
200
|
+
--ziti-controller-host <host> \
|
|
201
|
+
--idp-domain <domain> \
|
|
202
|
+
--idp-client-id <id> \
|
|
203
|
+
--idp-audience <audience>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Warp manages MCP server configurations through its UI rather than a local config file. The `init` command will print a JSON snippet that you can paste into Warp's MCP Settings (Settings > MCP Servers > +Add).
|
|
207
|
+
|
|
169
208
|
**Other MCP Clients**
|
|
170
209
|
|
|
171
210
|
To use Ziti MCP Server with any other MCP Client, you can manually add this configuration to the client and restart for changes to take effect:
|
|
@@ -221,7 +260,7 @@ The Ziti MCP Server uses the Ziti Management API and requires authentication to
|
|
|
221
260
|
|
|
222
261
|
### Initial Setup
|
|
223
262
|
|
|
224
|
-
The Ziti MCP Server supports
|
|
263
|
+
The Ziti MCP Server supports three authentication modes:
|
|
225
264
|
|
|
226
265
|
#### Device Auth Mode (Interactive Login)
|
|
227
266
|
|
|
@@ -252,6 +291,18 @@ npx @openziti/ziti-mcp-server init \
|
|
|
252
291
|
--idp-client-secret <your-client-secret>
|
|
253
292
|
```
|
|
254
293
|
|
|
294
|
+
#### Identity File Mode (mTLS Certificate)
|
|
295
|
+
|
|
296
|
+
Use this mode for certificate-based authentication with a Ziti identity JSON file. No IdP configuration is needed — authentication uses the client certificate embedded in the identity file:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
npx @openziti/ziti-mcp-server init \
|
|
300
|
+
--auth-mode identity \
|
|
301
|
+
--identity-file <path-to-identity.json>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
The identity file is a standard Ziti identity JSON file containing `ztAPI`, `id.cert`, `id.key`, and `id.ca` fields. The certificate material that will be used to establish authentication with the Ziti Controller is etracted from the identity file and is stored securely in the system keychain. Therefore, following a successful `init`, the identity file may be deleted from the system (for additional security, if desired).
|
|
305
|
+
|
|
255
306
|
> [!IMPORTANT]
|
|
256
307
|
>
|
|
257
308
|
> The `init` command needs to be run whenever:
|
|
@@ -283,7 +334,13 @@ This ensures your authentication tokens are properly removed from the system key
|
|
|
283
334
|
|
|
284
335
|
### Authentication Flow
|
|
285
336
|
|
|
286
|
-
The Ziti MCP server
|
|
337
|
+
The Ziti MCP server supports multiple authentication flows:
|
|
338
|
+
|
|
339
|
+
- **OAuth 2.0 device authorization flow** for interactive browser-based login with an IdP
|
|
340
|
+
- **Client credentials flow** for service accounts and automation
|
|
341
|
+
- **Identity file (mTLS)** for certificate-based authentication using a Ziti identity JSON file
|
|
342
|
+
|
|
343
|
+
In all modes, credentials are stored securely in your system's keychain and are never exposed in plain text.
|
|
287
344
|
|
|
288
345
|
<div align="center">
|
|
289
346
|
<img src="assets/auth-seq.jpg" alt="Authentication Sequence Diagram" width="800">
|
|
@@ -938,7 +995,7 @@ npm run start
|
|
|
938
995
|
```
|
|
939
996
|
|
|
940
997
|
> [!NOTE]
|
|
941
|
-
> This server requires [Node.js
|
|
998
|
+
> This server requires [Node.js v20 or higher](https://nodejs.org/en/download).
|
|
942
999
|
|
|
943
1000
|
## 🔒 Security
|
|
944
1001
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for identity file configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface IdentityFileConfig {
|
|
5
|
+
identityFile: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Request authorization using a Ziti identity file
|
|
9
|
+
*
|
|
10
|
+
* Reads a Ziti identity JSON file containing client certificates,
|
|
11
|
+
* validates its structure and PEM format, and stores the cert material
|
|
12
|
+
* in the system keychain.
|
|
13
|
+
*
|
|
14
|
+
* @param {IdentityFileConfig} config - Configuration containing the identity file path
|
|
15
|
+
* @returns {Promise<void>}
|
|
16
|
+
*/
|
|
17
|
+
export declare function requestIdentityFileAuthorization(config: IdentityFileConfig): Promise<void>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { cliOutput } from '../utils/terminal.js';
|
|
4
|
+
import { log, logError } from '../utils/logger.js';
|
|
5
|
+
import { keychain } from '../utils/keychain.js';
|
|
6
|
+
/**
|
|
7
|
+
* Strips the "pem:" prefix that Ziti identity files use on PEM fields.
|
|
8
|
+
* @param value - The raw string from the identity file
|
|
9
|
+
* @returns The PEM string without the prefix
|
|
10
|
+
*/
|
|
11
|
+
function stripPemPrefix(value) {
|
|
12
|
+
return value.startsWith('pem:') ? value.slice(4) : value;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Validates that a string contains PEM-encoded data (after stripping any "pem:" prefix)
|
|
16
|
+
* @param value - The string to validate
|
|
17
|
+
* @param fieldName - Name of the field for error messages
|
|
18
|
+
*/
|
|
19
|
+
function validatePem(value, fieldName) {
|
|
20
|
+
const pem = stripPemPrefix(value);
|
|
21
|
+
if (!pem.includes('-----BEGIN ') || !pem.includes('-----END ')) {
|
|
22
|
+
throw new Error(`Invalid PEM format for ${fieldName}: missing BEGIN/END markers`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validates the structure of a parsed identity file
|
|
27
|
+
* @param data - The parsed JSON data
|
|
28
|
+
*/
|
|
29
|
+
function validateIdentityFile(data) {
|
|
30
|
+
if (typeof data !== 'object' || data === null) {
|
|
31
|
+
throw new Error('Identity file must contain a JSON object');
|
|
32
|
+
}
|
|
33
|
+
const obj = data;
|
|
34
|
+
if (!obj.ztAPI || typeof obj.ztAPI !== 'string') {
|
|
35
|
+
throw new Error('Identity file missing required field: ztAPI');
|
|
36
|
+
}
|
|
37
|
+
if (!obj.id || typeof obj.id !== 'object' || obj.id === null) {
|
|
38
|
+
throw new Error('Identity file missing required field: id');
|
|
39
|
+
}
|
|
40
|
+
const id = obj.id;
|
|
41
|
+
for (const field of ['cert', 'key', 'ca']) {
|
|
42
|
+
if (!id[field] || typeof id[field] !== 'string') {
|
|
43
|
+
throw new Error(`Identity file missing required field: id.${field}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
validatePem(id.cert, 'id.cert');
|
|
47
|
+
validatePem(id.key, 'id.key');
|
|
48
|
+
validatePem(id.ca, 'id.ca');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Request authorization using a Ziti identity file
|
|
52
|
+
*
|
|
53
|
+
* Reads a Ziti identity JSON file containing client certificates,
|
|
54
|
+
* validates its structure and PEM format, and stores the cert material
|
|
55
|
+
* in the system keychain.
|
|
56
|
+
*
|
|
57
|
+
* @param {IdentityFileConfig} config - Configuration containing the identity file path
|
|
58
|
+
* @returns {Promise<void>}
|
|
59
|
+
*/
|
|
60
|
+
export async function requestIdentityFileAuthorization(config) {
|
|
61
|
+
log('Initiating identity file authentication...');
|
|
62
|
+
try {
|
|
63
|
+
// Read the identity file
|
|
64
|
+
log(`Reading identity file: ${config.identityFile}`);
|
|
65
|
+
const fileContent = fs.readFileSync(config.identityFile, 'utf-8');
|
|
66
|
+
// Parse and validate
|
|
67
|
+
let data;
|
|
68
|
+
try {
|
|
69
|
+
data = JSON.parse(fileContent);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
throw new Error(`Identity file is not valid JSON: ${config.identityFile}`);
|
|
73
|
+
}
|
|
74
|
+
validateIdentityFile(data);
|
|
75
|
+
// Extract controller host from ztAPI
|
|
76
|
+
const controllerHost = new URL(data.ztAPI).host;
|
|
77
|
+
log(`Extracted controller host: ${controllerHost}`);
|
|
78
|
+
// Store in keychain (strip "pem:" prefix that Ziti identity files use)
|
|
79
|
+
await keychain.setIdentityCert(stripPemPrefix(data.id.cert));
|
|
80
|
+
await keychain.setIdentityKey(stripPemPrefix(data.id.key));
|
|
81
|
+
await keychain.setIdentityCa(stripPemPrefix(data.id.ca));
|
|
82
|
+
await keychain.setZitiControllerHost(controllerHost);
|
|
83
|
+
cliOutput(`\n${chalk.green('✓')} Successfully loaded identity file for controller ${chalk.blue(controllerHost)}.\n`);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
logError('Identity file authentication error:', error);
|
|
87
|
+
cliOutput(`\n${chalk.red('✗')} Failed to load identity file.\n`);
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
cliOutput(` ${chalk.red(error.message)}\n`);
|
|
90
|
+
}
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=identity-file-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-file-flow.js","sourceRoot":"","sources":["../../src/auth/identity-file-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAqBhD;;;;GAIG;AACH,S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AAC,GAAG,CAAC,CAAC,CAAC;QAC3D,MAAM,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,QAAQ,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAErD,SAAS,CACP,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,qDAAqD,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAC1G,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QACvD,SAAS,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QACjE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,SAAS,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseClientManager } from './base.js';
|
|
2
|
+
import type { ServerConfig } from './types.js';
|
|
3
|
+
import type { ClientOptions } from '../utils/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration scope options for Claude Code.
|
|
6
|
+
*
|
|
7
|
+
* - `user` — written to ~/.claude.json; available across all projects.
|
|
8
|
+
* - `project` — written to .mcp.json in the current working directory; committed with the repo.
|
|
9
|
+
*/
|
|
10
|
+
export type ClaudeCodeScope = 'user' | 'project';
|
|
11
|
+
/**
|
|
12
|
+
* Client manager implementation for Claude Code.
|
|
13
|
+
*
|
|
14
|
+
* Supports both user-scoped (~/.claude.json) and project-scoped (.mcp.json) configuration.
|
|
15
|
+
* Claude Code requires a `"type": "stdio"` field on each MCP server entry.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://code.claude.com/docs/en/mcp | Claude Code MCP Documentation}
|
|
18
|
+
*/
|
|
19
|
+
export declare class ClaudeCodeClientManager extends BaseClientManager {
|
|
20
|
+
private selectedScope;
|
|
21
|
+
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Prompts for configuration scope, then delegates to the base configure flow.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Client configuration options.
|
|
26
|
+
*/
|
|
27
|
+
configure(options: ClientOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the config file path for the selected scope.
|
|
30
|
+
*
|
|
31
|
+
* - User scope: ~/.claude.json
|
|
32
|
+
* - Project scope: .mcp.json in the current working directory
|
|
33
|
+
*
|
|
34
|
+
* @returns The absolute path to the configuration file.
|
|
35
|
+
*/
|
|
36
|
+
getConfigPath(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Extends the base server config with the `type: "stdio"` field required by Claude Code.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Client configuration options.
|
|
41
|
+
* @returns A ServerConfig with the stdio transport type set.
|
|
42
|
+
*/
|
|
43
|
+
protected createServerConfig(options: ClientOptions): ServerConfig;
|
|
44
|
+
private promptForScope;
|
|
45
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as os from 'os';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { BaseClientManager } from './base.js';
|
|
5
|
+
import { log } from '../utils/logger.js';
|
|
6
|
+
import { cliOutput, promptForChoice } from '../utils/terminal.js';
|
|
7
|
+
/**
|
|
8
|
+
* Client manager implementation for Claude Code.
|
|
9
|
+
*
|
|
10
|
+
* Supports both user-scoped (~/.claude.json) and project-scoped (.mcp.json) configuration.
|
|
11
|
+
* Claude Code requires a `"type": "stdio"` field on each MCP server entry.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://code.claude.com/docs/en/mcp | Claude Code MCP Documentation}
|
|
14
|
+
*/
|
|
15
|
+
export class ClaudeCodeClientManager extends BaseClientManager {
|
|
16
|
+
selectedScope = 'user';
|
|
17
|
+
constructor() {
|
|
18
|
+
super({
|
|
19
|
+
clientType: 'claude-code',
|
|
20
|
+
displayName: 'Claude Code',
|
|
21
|
+
capabilities: ['tools'],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Prompts for configuration scope, then delegates to the base configure flow.
|
|
26
|
+
*
|
|
27
|
+
* @param options - Client configuration options.
|
|
28
|
+
*/
|
|
29
|
+
async configure(options) {
|
|
30
|
+
this.selectedScope = await this.promptForScope();
|
|
31
|
+
const configPath = this.getConfigPath();
|
|
32
|
+
const config = this.readConfig(configPath);
|
|
33
|
+
const mcpServers = config.mcpServers || {};
|
|
34
|
+
const serverConfig = this.createServerConfig(options);
|
|
35
|
+
mcpServers['ziti'] = serverConfig;
|
|
36
|
+
config.mcpServers = mcpServers;
|
|
37
|
+
this.writeConfig(configPath, config);
|
|
38
|
+
log(`Updated ${this.displayName} config file at: ${configPath}`);
|
|
39
|
+
const scopeLabel = this.selectedScope === 'user'
|
|
40
|
+
? `user scope (${configPath})`
|
|
41
|
+
: `project scope (${configPath})`;
|
|
42
|
+
cliOutput(`\n${chalk.green('✓')} OpenZiti MCP server configured for Claude Code at ${scopeLabel}.\n` +
|
|
43
|
+
`${chalk.yellow('Start a new Claude Code session')} in this project to apply changes.\n`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the config file path for the selected scope.
|
|
47
|
+
*
|
|
48
|
+
* - User scope: ~/.claude.json
|
|
49
|
+
* - Project scope: .mcp.json in the current working directory
|
|
50
|
+
*
|
|
51
|
+
* @returns The absolute path to the configuration file.
|
|
52
|
+
*/
|
|
53
|
+
getConfigPath() {
|
|
54
|
+
if (this.selectedScope === 'user') {
|
|
55
|
+
return path.join(os.homedir(), '.claude.json');
|
|
56
|
+
}
|
|
57
|
+
return path.join(process.cwd(), '.mcp.json');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Extends the base server config with the `type: "stdio"` field required by Claude Code.
|
|
61
|
+
*
|
|
62
|
+
* @param options - Client configuration options.
|
|
63
|
+
* @returns A ServerConfig with the stdio transport type set.
|
|
64
|
+
*/
|
|
65
|
+
createServerConfig(options) {
|
|
66
|
+
return { ...super.createServerConfig(options), type: 'stdio', defer_loading: true };
|
|
67
|
+
}
|
|
68
|
+
async promptForScope() {
|
|
69
|
+
return promptForChoice('Where would you like to configure the OpenZiti MCP server for Claude Code?', [
|
|
70
|
+
{
|
|
71
|
+
label: 'User — available across all your projects (~/.claude.json)',
|
|
72
|
+
value: 'user',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: 'Project — this project only (.mcp.json in current directory)',
|
|
76
|
+
value: 'project',
|
|
77
|
+
},
|
|
78
|
+
], 'user');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/clients/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAUlE;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IACpD,aAAa,GAAoB,MAAM,CAAC;IAEhD;QACE,KAAK,CAAC;YACJ,UAAU,EAAE,aAAa;YACzB,WAAW,EAAE,aAAa;YAC1B,YAAY,EAAE,CAAC,OAAO,CAAC;SACxB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,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C,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACtF,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,OAAO,eAAe,CACpB,4EAA4E,EAC5E;YACE;gBACE,KAAK,EAAE,4DAA4D;gBACnE,KAAK,EAAE,MAAe;aACvB;YACD;gBACE,KAAK,EAAE,8DAA8D;gBACrE,KAAK,EAAE,SAAkB;aAC1B;SACF,EACD,MAAM,CACP,CAAC;IACJ,CAAC;CACF"}
|
package/dist/clients/index.d.ts
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* @module clients
|
|
7
7
|
*/
|
|
8
8
|
import { ClaudeClientManager } from './claude.js';
|
|
9
|
+
import { ClaudeCodeClientManager } from './claude-code.js';
|
|
9
10
|
import { CursorClientManager } from './cursor.js';
|
|
10
11
|
import { WindsurfClientManager } from './windsurf.js';
|
|
11
12
|
import { VSCodeClientManager } from './vscode.js';
|
|
13
|
+
import { WarpClientManager } from './warp.js';
|
|
12
14
|
/**
|
|
13
15
|
* Namespace object containing initialized client managers.
|
|
14
16
|
*
|
|
@@ -18,16 +20,20 @@ import { VSCodeClientManager } from './vscode.js';
|
|
|
18
20
|
* @property {CursorClientManager} cursor - Manager for Cursor code editor.
|
|
19
21
|
* @property {WindsurfClientManager} windsurf - Manager for Windsurf editor.
|
|
20
22
|
* @property {VSCodeClientManager} vscode - Manager for Visual Studio Code.
|
|
23
|
+
* @property {WarpClientManager} warp - Manager for Warp terminal.
|
|
21
24
|
*
|
|
22
25
|
* @see {@link https://claude.ai/download | Claude Desktop}
|
|
23
26
|
* @see {@link https://www.cursor.com/ | Cursor Code Editor}
|
|
24
27
|
* @see {@link https://windsurf.com/editor | Windsurf Editor}
|
|
25
28
|
* @see {@link https://code.visualstudio.com/ | Visual Studio Code}
|
|
29
|
+
* @see {@link https://www.warp.dev/ | Warp Terminal}
|
|
26
30
|
*/
|
|
27
31
|
export declare const clients: {
|
|
28
32
|
claude: ClaudeClientManager;
|
|
33
|
+
'claude-code': ClaudeCodeClientManager;
|
|
29
34
|
cursor: CursorClientManager;
|
|
30
35
|
windsurf: WindsurfClientManager;
|
|
31
36
|
vscode: VSCodeClientManager;
|
|
37
|
+
warp: WarpClientManager;
|
|
32
38
|
};
|
|
33
39
|
export type { ClientType, ClientManager, ClientConfig, ServerConfig } from './types.js';
|
package/dist/clients/index.js
CHANGED
|
@@ -7,14 +7,18 @@
|
|
|
7
7
|
*/
|
|
8
8
|
// Import client classes
|
|
9
9
|
import { ClaudeClientManager } from './claude.js';
|
|
10
|
+
import { ClaudeCodeClientManager } from './claude-code.js';
|
|
10
11
|
import { CursorClientManager } from './cursor.js';
|
|
11
12
|
import { WindsurfClientManager } from './windsurf.js';
|
|
12
13
|
import { VSCodeClientManager } from './vscode.js';
|
|
14
|
+
import { WarpClientManager } from './warp.js';
|
|
13
15
|
// Create client manager instances
|
|
14
16
|
const claude = new ClaudeClientManager();
|
|
17
|
+
const claudeCode = new ClaudeCodeClientManager();
|
|
15
18
|
const cursor = new CursorClientManager();
|
|
16
19
|
const windsurf = new WindsurfClientManager();
|
|
17
20
|
const vscode = new VSCodeClientManager();
|
|
21
|
+
const warp = new WarpClientManager();
|
|
18
22
|
/**
|
|
19
23
|
* Namespace object containing initialized client managers.
|
|
20
24
|
*
|
|
@@ -24,16 +28,20 @@ const vscode = new VSCodeClientManager();
|
|
|
24
28
|
* @property {CursorClientManager} cursor - Manager for Cursor code editor.
|
|
25
29
|
* @property {WindsurfClientManager} windsurf - Manager for Windsurf editor.
|
|
26
30
|
* @property {VSCodeClientManager} vscode - Manager for Visual Studio Code.
|
|
31
|
+
* @property {WarpClientManager} warp - Manager for Warp terminal.
|
|
27
32
|
*
|
|
28
33
|
* @see {@link https://claude.ai/download | Claude Desktop}
|
|
29
34
|
* @see {@link https://www.cursor.com/ | Cursor Code Editor}
|
|
30
35
|
* @see {@link https://windsurf.com/editor | Windsurf Editor}
|
|
31
36
|
* @see {@link https://code.visualstudio.com/ | Visual Studio Code}
|
|
37
|
+
* @see {@link https://www.warp.dev/ | Warp Terminal}
|
|
32
38
|
*/
|
|
33
39
|
export const clients = {
|
|
34
40
|
claude,
|
|
41
|
+
'claude-code': claudeCode,
|
|
35
42
|
cursor,
|
|
36
43
|
windsurf,
|
|
37
44
|
vscode,
|
|
45
|
+
warp,
|
|
38
46
|
};
|
|
39
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAwB;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAwB;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,kCAAkC;AAClC,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;AACzC,MAAM,UAAU,GAAG,IAAI,uBAAuB,EAAE,CAAC;AACjD,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;AACzC,MAAM,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAC7C,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;AACzC,MAAM,IAAI,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM;IACN,aAAa,EAAE,UAAU;IACzB,MAAM;IACN,QAAQ;IACR,MAAM;IACN,IAAI;CACL,CAAC"}
|
package/dist/clients/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ClientOptions } from '../utils/types.js';
|
|
|
4
4
|
*
|
|
5
5
|
* Represents the set of known MCP client applications supported by this project.
|
|
6
6
|
*/
|
|
7
|
-
export type ClientType = 'claude' | 'cursor' | 'windsurf' | 'vscode';
|
|
7
|
+
export type ClientType = 'claude' | 'claude-code' | 'cursor' | 'windsurf' | 'vscode' | 'warp';
|
|
8
8
|
/**
|
|
9
9
|
* MCP server configuration object used in client configuration files.
|
|
10
10
|
*
|
|
@@ -19,6 +19,10 @@ export interface ServerConfig {
|
|
|
19
19
|
env?: Record<string, string>;
|
|
20
20
|
/** Optional list of capabilities supported by the client integration. */
|
|
21
21
|
capabilities?: string[];
|
|
22
|
+
/** Transport type; required by some clients (e.g. Claude Code requires "stdio"). */
|
|
23
|
+
type?: string;
|
|
24
|
+
/** When true, tools are loaded on-demand via Tool Search instead of upfront. */
|
|
25
|
+
defer_loading?: boolean;
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Generic client configuration format shared across different MCP clients.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseClientManager } from './base.js';
|
|
2
|
+
import type { ClientOptions } from '../utils/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Client manager implementation for Warp.
|
|
5
|
+
*
|
|
6
|
+
* Warp stores MCP server configurations in the cloud (Warp Drive) and manages
|
|
7
|
+
* them through the Warp UI, so this manager outputs the JSON snippet for the
|
|
8
|
+
* user to paste into Warp's MCP Settings rather than writing a local config file.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://docs.warp.dev/agent-platform/capabilities/mcp | Warp MCP Documentation}
|
|
11
|
+
*/
|
|
12
|
+
export declare class WarpClientManager extends BaseClientManager {
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Not applicable for Warp — configuration is managed through the Warp UI.
|
|
16
|
+
*
|
|
17
|
+
* @returns An empty string since Warp has no local configuration file.
|
|
18
|
+
*/
|
|
19
|
+
getConfigPath(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Outputs the MCP server configuration as a JSON snippet for the user to
|
|
22
|
+
* paste into Warp's MCP Settings UI (Settings > MCP Servers > +Add).
|
|
23
|
+
*
|
|
24
|
+
* @param options - Client configuration options such as enabled tools and read-only mode.
|
|
25
|
+
*/
|
|
26
|
+
configure(options: ClientOptions): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { BaseClientManager } from './base.js';
|
|
3
|
+
import { cliOutput } from '../utils/terminal.js';
|
|
4
|
+
import { MCP_SERVER_NAME } from '../utils/constants.js';
|
|
5
|
+
import { log } from '../utils/logger.js';
|
|
6
|
+
/**
|
|
7
|
+
* Client manager implementation for Warp.
|
|
8
|
+
*
|
|
9
|
+
* Warp stores MCP server configurations in the cloud (Warp Drive) and manages
|
|
10
|
+
* them through the Warp UI, so this manager outputs the JSON snippet for the
|
|
11
|
+
* user to paste into Warp's MCP Settings rather than writing a local config file.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://docs.warp.dev/agent-platform/capabilities/mcp | Warp MCP Documentation}
|
|
14
|
+
*/
|
|
15
|
+
export class WarpClientManager extends BaseClientManager {
|
|
16
|
+
constructor() {
|
|
17
|
+
super({
|
|
18
|
+
clientType: 'warp',
|
|
19
|
+
displayName: 'Warp',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Not applicable for Warp — configuration is managed through the Warp UI.
|
|
24
|
+
*
|
|
25
|
+
* @returns An empty string since Warp has no local configuration file.
|
|
26
|
+
*/
|
|
27
|
+
getConfigPath() {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Outputs the MCP server configuration as a JSON snippet for the user to
|
|
32
|
+
* paste into Warp's MCP Settings UI (Settings > MCP Servers > +Add).
|
|
33
|
+
*
|
|
34
|
+
* @param options - Client configuration options such as enabled tools and read-only mode.
|
|
35
|
+
*/
|
|
36
|
+
async configure(options) {
|
|
37
|
+
const serverConfig = this.createServerConfig(options);
|
|
38
|
+
const configSnippet = JSON.stringify({ [MCP_SERVER_NAME]: serverConfig }, null, 2);
|
|
39
|
+
log('Generated Warp MCP configuration snippet');
|
|
40
|
+
cliOutput(`\n${chalk.green('✓')} Copy the following JSON and paste it into Warp's MCP Settings` +
|
|
41
|
+
` (${chalk.yellow('Settings > MCP Servers > +Add')}):\n\n${configSnippet}\n`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=warp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warp.js","sourceRoot":"","sources":["../../src/clients/warp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAGzC;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IACtD;QACE,KAAK,CAAC;YACJ,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,aAAa;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,OAAsB;QACpC,MAAM,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEtD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEnF,GAAG,CAAC,0CAA0C,CAAC,CAAC;QAEhD,SAAS,CACP,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,gEAAgE;YACnF,KAAK,KAAK,CAAC,MAAM,CAAC,+BAA+B,CAAC,SAAS,aAAa,IAAI,CAC/E,CAAC;IACJ,CAAC;CACF"}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ClientType } from '../clients/types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Supported authentication modes
|
|
4
4
|
*/
|
|
5
|
-
export type AuthMode = 'device-auth' | 'client-credentials';
|
|
5
|
+
export type AuthMode = 'device-auth' | 'client-credentials' | 'identity';
|
|
6
6
|
/**
|
|
7
7
|
* Command options for the init command
|
|
8
8
|
*/
|
|
@@ -18,6 +18,7 @@ export interface InitOptions {
|
|
|
18
18
|
idpClientId?: string;
|
|
19
19
|
idpClientSecret?: string;
|
|
20
20
|
idpAudience?: string;
|
|
21
|
+
identityFile?: string;
|
|
21
22
|
}
|
|
22
23
|
declare const init: (options: InitOptions) => Promise<void>;
|
|
23
24
|
export default init;
|
package/dist/commands/init.js
CHANGED
|
@@ -2,6 +2,7 @@ import { clients } from '../clients/index.js';
|
|
|
2
2
|
import { log, logError } from '../utils/logger.js';
|
|
3
3
|
import { requestAuthorization } from '../auth/device-auth-flow.js';
|
|
4
4
|
import { requestClientCredentialsAuthorization } from '../auth/client-credentials-flow.js';
|
|
5
|
+
import { requestIdentityFileAuthorization } from '../auth/identity-file-flow.js';
|
|
5
6
|
import { promptForScopeSelection } from '../utils/terminal.js';
|
|
6
7
|
import { getAllScopes } from '../utils/scopes.js';
|
|
7
8
|
import { Glob } from '../utils/glob.js';
|
|
@@ -77,12 +78,22 @@ async function configureClient(clientType, options) {
|
|
|
77
78
|
* and returns a typed object with guaranteed values
|
|
78
79
|
*/
|
|
79
80
|
function validateAuthModeParams(options) {
|
|
80
|
-
const { authMode, zitiControllerHost, idpDomain, idpClientId, idpClientSecret, idpAudience } = options;
|
|
81
|
+
const { authMode, zitiControllerHost, idpDomain, idpClientId, idpClientSecret, idpAudience, identityFile, } = options;
|
|
81
82
|
// Validate auth mode value
|
|
82
|
-
if (!['device-auth', 'client-credentials'].includes(authMode)) {
|
|
83
|
-
throw new Error(`Invalid --auth-mode value: "${authMode}". Must be "device-auth"
|
|
83
|
+
if (!['device-auth', 'client-credentials', 'identity'].includes(authMode)) {
|
|
84
|
+
throw new Error(`Invalid --auth-mode value: "${authMode}". Must be "device-auth", "client-credentials", or "identity".`);
|
|
84
85
|
}
|
|
85
|
-
//
|
|
86
|
+
// Identity mode has its own validation — no IdP params needed
|
|
87
|
+
if (authMode === 'identity') {
|
|
88
|
+
if (!identityFile) {
|
|
89
|
+
throw new Error('--identity-file is required for identity auth mode');
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
authMode,
|
|
93
|
+
identityFile,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Common required parameters for device-auth and client-credentials modes
|
|
86
97
|
if (!zitiControllerHost) {
|
|
87
98
|
throw new Error('--ziti-controller-host is required');
|
|
88
99
|
}
|
|
@@ -132,7 +143,13 @@ const init = async (options) => {
|
|
|
132
143
|
trackEvent.trackInit(options.client);
|
|
133
144
|
// Validate required parameters for the auth mode
|
|
134
145
|
const validatedParams = validateAuthModeParams(options);
|
|
135
|
-
if (validatedParams.authMode === '
|
|
146
|
+
if (validatedParams.authMode === 'identity') {
|
|
147
|
+
log('Using identity file for authentication');
|
|
148
|
+
await requestIdentityFileAuthorization({
|
|
149
|
+
identityFile: validatedParams.identityFile,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
else if (validatedParams.authMode === 'client-credentials') {
|
|
136
153
|
log('Using client credentials flow for authentication');
|
|
137
154
|
await requestClientCredentialsAuthorization({
|
|
138
155
|
zitiControllerHost: validatedParams.zitiControllerHost,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACx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