@launchdarkly/mcp-server 0.2.3 → 0.2.4
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 +35 -474
- package/bin/mcp-server.js +5 -5
- package/bin/mcp-server.js.map +4 -4
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/mcp-server/mcp-server.js +1 -1
- package/dist/commonjs/mcp-server/server.js +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/mcp-server/mcp-server.js +1 -1
- package/dist/esm/mcp-server/server.js +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/lib/config.ts +2 -2
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +1 -1
package/README.md
CHANGED
|
@@ -9,81 +9,30 @@ The official [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) se
|
|
|
9
9
|
</a>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
<br /><br />
|
|
14
|
-
> [!IMPORTANT]
|
|
15
|
-
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/launchdarkly/mcp). Delete this section before > publishing to a package manager.
|
|
16
|
-
|
|
17
12
|
<!-- No Summary [summary] -->
|
|
18
13
|
|
|
19
14
|
<!-- Start Table of Contents [toc] -->
|
|
20
15
|
## Table of Contents
|
|
21
16
|
<!-- $toc-max-depth=2 -->
|
|
22
17
|
* [LaunchDarkly's Model Context Protocol (MCP) Server](#launchdarklys-model-context-protocol-mcp-server)
|
|
23
|
-
* [
|
|
18
|
+
* [Installation](#installation)
|
|
24
19
|
* [Requirements](#requirements)
|
|
25
|
-
* [SDK Example Usage](#sdk-example-usage)
|
|
26
|
-
* [Authentication](#authentication)
|
|
27
20
|
* [Available Resources and Operations](#available-resources-and-operations)
|
|
28
|
-
* [
|
|
29
|
-
* [Retries](#retries)
|
|
30
|
-
* [Error Handling](#error-handling)
|
|
31
|
-
* [Server Selection](#server-selection)
|
|
32
|
-
* [Custom HTTP Client](#custom-http-client)
|
|
33
|
-
* [Debugging](#debugging)
|
|
21
|
+
* [Available environments](#available-environments)
|
|
34
22
|
* [Development](#development)
|
|
35
23
|
* [Maturity](#maturity)
|
|
36
24
|
* [Contributions](#contributions)
|
|
37
25
|
|
|
38
26
|
<!-- End Table of Contents [toc] -->
|
|
39
27
|
|
|
40
|
-
<!--
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
|
|
44
|
-
|
|
45
|
-
### NPM
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm add @launchdarkly/mcp-server
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### PNPM
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
pnpm add @launchdarkly/mcp-server
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Bun
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
bun add @launchdarkly/mcp-server
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Yarn
|
|
28
|
+
<!-- No SDK Installation [installation] -->
|
|
29
|
+
## Installation
|
|
64
30
|
|
|
65
|
-
|
|
66
|
-
yarn add @launchdarkly/mcp-server zod
|
|
67
|
-
|
|
68
|
-
# Note that Yarn does not install peer dependencies automatically. You will need
|
|
69
|
-
# to install zod as shown above.
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
> [!NOTE]
|
|
73
|
-
> This package is published with CommonJS and ES Modules (ESM) support.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
### Model Context Protocol (MCP) Server
|
|
77
|
-
|
|
78
|
-
This SDK is also an installable MCP server where the various SDK methods are
|
|
79
|
-
exposed as tools that can be invoked by AI applications.
|
|
80
|
-
|
|
81
|
-
> Node.js v20 or greater is required to run the MCP server from npm.
|
|
31
|
+
This MCP server can be installed in any AI client that supports the MCP protocol. Refer to your AI client's instructions if it isn't listed here.
|
|
82
32
|
|
|
83
|
-
|
|
84
|
-
<summary>Claude installation steps</summary>
|
|
33
|
+
### Cursor installation steps
|
|
85
34
|
|
|
86
|
-
|
|
35
|
+
Create a `.cursor/mcp.json` file in your project root with the following content:
|
|
87
36
|
|
|
88
37
|
```json
|
|
89
38
|
{
|
|
@@ -92,21 +41,19 @@ Add the following server definition to your `claude_desktop_config.json` file:
|
|
|
92
41
|
"command": "npx",
|
|
93
42
|
"args": [
|
|
94
43
|
"-y", "--package", "@launchdarkly/mcp-server",
|
|
95
|
-
"--",
|
|
96
|
-
"
|
|
97
|
-
"--api-key", "..."
|
|
44
|
+
"--", "mcp", "start",
|
|
45
|
+
"--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
98
46
|
]
|
|
99
47
|
}
|
|
100
48
|
}
|
|
101
49
|
}
|
|
102
50
|
```
|
|
103
51
|
|
|
104
|
-
|
|
52
|
+
Specify your API key as found on LaunchDarkly's Authorization page.
|
|
105
53
|
|
|
106
|
-
|
|
107
|
-
<summary>Cursor installation steps</summary>
|
|
54
|
+
### Claude installation steps
|
|
108
55
|
|
|
109
|
-
|
|
56
|
+
Add the following server definition to your `claude_desktop_config.json` file:
|
|
110
57
|
|
|
111
58
|
```json
|
|
112
59
|
{
|
|
@@ -115,112 +62,35 @@ Create a `.cursor/mcp.json` file in your project root with the following content
|
|
|
115
62
|
"command": "npx",
|
|
116
63
|
"args": [
|
|
117
64
|
"-y", "--package", "@launchdarkly/mcp-server",
|
|
118
|
-
"--",
|
|
119
|
-
"
|
|
120
|
-
"--api-key", "..."
|
|
65
|
+
"--", "mcp", "start",
|
|
66
|
+
"--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
121
67
|
]
|
|
122
68
|
}
|
|
123
69
|
}
|
|
124
70
|
}
|
|
125
71
|
```
|
|
126
72
|
|
|
127
|
-
|
|
73
|
+
Specify your API key as found on LaunchDarkly's Authorization page.
|
|
128
74
|
|
|
129
|
-
|
|
75
|
+
### Standalone binary installation steps
|
|
76
|
+
|
|
77
|
+
You can also run the MCP server as a standalone binary with no additional dependencies. You must pull these binaries from available GitHub releases while specifying the appropriate `tag` value:
|
|
130
78
|
|
|
131
79
|
```bash
|
|
132
80
|
curl -L -o mcp-server \
|
|
133
|
-
https://github.com/
|
|
81
|
+
https://github.com/launchdarkly/mcp-server/releases/download/{tag}/mcp-server-bun-darwin-arm64 && \
|
|
134
82
|
chmod +x mcp-server
|
|
135
83
|
```
|
|
136
84
|
|
|
137
|
-
If the repo is a private repo you must add your Github PAT to download a release `-H "Authorization: Bearer {GITHUB_PAT}"`.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
```json
|
|
141
|
-
{
|
|
142
|
-
"mcpServers": {
|
|
143
|
-
"Todos": {
|
|
144
|
-
"command": "./DOWNLOAD/PATH/mcp-server",
|
|
145
|
-
"args": [
|
|
146
|
-
"start"
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
For a full list of server arguments, run:
|
|
154
|
-
|
|
155
|
-
```sh
|
|
156
|
-
npx -y --package @launchdarkly/mcp-server -- mcp start --help
|
|
157
|
-
```
|
|
158
|
-
<!-- End SDK Installation [installation] -->
|
|
159
|
-
|
|
160
85
|
<!-- Start Requirements [requirements] -->
|
|
161
86
|
## Requirements
|
|
162
87
|
|
|
163
88
|
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
164
89
|
<!-- End Requirements [requirements] -->
|
|
165
90
|
|
|
166
|
-
<!--
|
|
167
|
-
## SDK Example Usage
|
|
168
|
-
|
|
169
|
-
### Example
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
173
|
-
|
|
174
|
-
const launchDarkly = new LaunchDarkly({
|
|
175
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
async function run() {
|
|
179
|
-
const result = await launchDarkly.featureFlags.list({
|
|
180
|
-
projectKey: "<value>",
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// Handle the result
|
|
184
|
-
console.log(result);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
run();
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
<!-- End SDK Example Usage [usage] -->
|
|
191
|
-
|
|
192
|
-
<!-- Start Authentication [security] -->
|
|
193
|
-
## Authentication
|
|
194
|
-
|
|
195
|
-
### Per-Client Security Schemes
|
|
196
|
-
|
|
197
|
-
This SDK supports the following security scheme globally:
|
|
198
|
-
|
|
199
|
-
| Name | Type | Scheme | Environment Variable |
|
|
200
|
-
| -------- | ------ | ------- | ---------------------- |
|
|
201
|
-
| `apiKey` | apiKey | API key | `LAUNCHDARKLY_API_KEY` |
|
|
202
|
-
|
|
203
|
-
To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
|
|
204
|
-
```typescript
|
|
205
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
206
|
-
|
|
207
|
-
const launchDarkly = new LaunchDarkly({
|
|
208
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
async function run() {
|
|
212
|
-
const result = await launchDarkly.featureFlags.list({
|
|
213
|
-
projectKey: "<value>",
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Handle the result
|
|
217
|
-
console.log(result);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
run();
|
|
91
|
+
<!-- No SDK Example Usage [usage] -->
|
|
221
92
|
|
|
222
|
-
|
|
223
|
-
<!-- End Authentication [security] -->
|
|
93
|
+
<!-- No Authentication [security] -->
|
|
224
94
|
|
|
225
95
|
<!-- Start Available Resources and Operations [operations] -->
|
|
226
96
|
## Available Resources and Operations
|
|
@@ -252,338 +122,29 @@ run();
|
|
|
252
122
|
</details>
|
|
253
123
|
<!-- End Available Resources and Operations [operations] -->
|
|
254
124
|
|
|
255
|
-
<!--
|
|
256
|
-
## Standalone functions
|
|
257
|
-
|
|
258
|
-
All the methods listed above are available as standalone functions. These
|
|
259
|
-
functions are ideal for use in applications running in the browser, serverless
|
|
260
|
-
runtimes or other environments where application bundle size is a primary
|
|
261
|
-
concern. When using a bundler to build your application, all unused
|
|
262
|
-
functionality will be either excluded from the final bundle or tree-shaken away.
|
|
263
|
-
|
|
264
|
-
To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
265
|
-
|
|
266
|
-
<details>
|
|
267
|
-
|
|
268
|
-
<summary>Available standalone functions</summary>
|
|
269
|
-
|
|
270
|
-
- [`aiConfigsCreate`](docs/sdks/aiconfigs/README.md#create) - Create new AI Config
|
|
271
|
-
- [`aiConfigsCreateVariation`](docs/sdks/aiconfigs/README.md#createvariation) - Create AI Config variation
|
|
272
|
-
- [`aiConfigsDelete`](docs/sdks/aiconfigs/README.md#delete) - Delete AI Config
|
|
273
|
-
- [`aiConfigsDeleteVariation`](docs/sdks/aiconfigs/README.md#deletevariation) - Delete AI Config variation
|
|
274
|
-
- [`aiConfigsGet`](docs/sdks/aiconfigs/README.md#get) - Get AI Config
|
|
275
|
-
- [`aiConfigsGetVariation`](docs/sdks/aiconfigs/README.md#getvariation) - Get AI Config variation
|
|
276
|
-
- [`aiConfigsList`](docs/sdks/aiconfigs/README.md#list) - List AI Configs
|
|
277
|
-
- [`aiConfigsUpdate`](docs/sdks/aiconfigs/README.md#update) - Update AI Config
|
|
278
|
-
- [`aiConfigsUpdateVariation`](docs/sdks/aiconfigs/README.md#updatevariation) - Update AI Config variation
|
|
279
|
-
- [`featureFlagsCreate`](docs/sdks/featureflags/README.md#create) - Create a feature flag
|
|
280
|
-
- [`featureFlagsDelete`](docs/sdks/featureflags/README.md#delete) - Delete feature flag
|
|
281
|
-
- [`featureFlagsGet`](docs/sdks/featureflags/README.md#get) - Get feature flag
|
|
282
|
-
- [`featureFlagsList`](docs/sdks/featureflags/README.md#list) - List feature flags
|
|
283
|
-
- [`featureFlagsPatch`](docs/sdks/featureflags/README.md#patch) - Update feature flag
|
|
284
|
-
|
|
285
|
-
</details>
|
|
286
|
-
<!-- End Standalone functions [standalone-funcs] -->
|
|
287
|
-
|
|
288
|
-
<!-- Start Retries [retries] -->
|
|
289
|
-
## Retries
|
|
290
|
-
|
|
291
|
-
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
292
|
-
|
|
293
|
-
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
294
|
-
```typescript
|
|
295
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
296
|
-
|
|
297
|
-
const launchDarkly = new LaunchDarkly({
|
|
298
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
async function run() {
|
|
302
|
-
const result = await launchDarkly.featureFlags.list({
|
|
303
|
-
projectKey: "<value>",
|
|
304
|
-
}, {
|
|
305
|
-
retries: {
|
|
306
|
-
strategy: "backoff",
|
|
307
|
-
backoff: {
|
|
308
|
-
initialInterval: 1,
|
|
309
|
-
maxInterval: 50,
|
|
310
|
-
exponent: 1.1,
|
|
311
|
-
maxElapsedTime: 100,
|
|
312
|
-
},
|
|
313
|
-
retryConnectionErrors: false,
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
// Handle the result
|
|
318
|
-
console.log(result);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
run();
|
|
322
|
-
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
326
|
-
```typescript
|
|
327
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
328
|
-
|
|
329
|
-
const launchDarkly = new LaunchDarkly({
|
|
330
|
-
retryConfig: {
|
|
331
|
-
strategy: "backoff",
|
|
332
|
-
backoff: {
|
|
333
|
-
initialInterval: 1,
|
|
334
|
-
maxInterval: 50,
|
|
335
|
-
exponent: 1.1,
|
|
336
|
-
maxElapsedTime: 100,
|
|
337
|
-
},
|
|
338
|
-
retryConnectionErrors: false,
|
|
339
|
-
},
|
|
340
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
async function run() {
|
|
344
|
-
const result = await launchDarkly.featureFlags.list({
|
|
345
|
-
projectKey: "<value>",
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// Handle the result
|
|
349
|
-
console.log(result);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
run();
|
|
353
|
-
|
|
354
|
-
```
|
|
355
|
-
<!-- End Retries [retries] -->
|
|
356
|
-
|
|
357
|
-
<!-- Start Error Handling [errors] -->
|
|
358
|
-
## Error Handling
|
|
359
|
-
|
|
360
|
-
Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `list` method may throw the following errors:
|
|
361
|
-
|
|
362
|
-
| Error Type | Status Code | Content Type |
|
|
363
|
-
| ----------------------------- | ----------- | ---------------- |
|
|
364
|
-
| errors.InvalidRequestErrorRep | 400 | application/json |
|
|
365
|
-
| errors.UnauthorizedErrorRep | 401 | application/json |
|
|
366
|
-
| errors.ForbiddenErrorRep | 403 | application/json |
|
|
367
|
-
| errors.NotFoundErrorRep | 404 | application/json |
|
|
368
|
-
| errors.RateLimitedErrorRep | 429 | application/json |
|
|
369
|
-
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
370
|
-
|
|
371
|
-
If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
|
|
372
|
-
|
|
373
|
-
```typescript
|
|
374
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
375
|
-
import {
|
|
376
|
-
ForbiddenErrorRep,
|
|
377
|
-
InvalidRequestErrorRep,
|
|
378
|
-
NotFoundErrorRep,
|
|
379
|
-
RateLimitedErrorRep,
|
|
380
|
-
SDKValidationError,
|
|
381
|
-
UnauthorizedErrorRep,
|
|
382
|
-
} from "@launchdarkly/mcp-server/models/errors";
|
|
383
|
-
|
|
384
|
-
const launchDarkly = new LaunchDarkly({
|
|
385
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
async function run() {
|
|
389
|
-
let result;
|
|
390
|
-
try {
|
|
391
|
-
result = await launchDarkly.featureFlags.list({
|
|
392
|
-
projectKey: "<value>",
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// Handle the result
|
|
396
|
-
console.log(result);
|
|
397
|
-
} catch (err) {
|
|
398
|
-
switch (true) {
|
|
399
|
-
// The server response does not match the expected SDK schema
|
|
400
|
-
case (err instanceof SDKValidationError): {
|
|
401
|
-
// Pretty-print will provide a human-readable multi-line error message
|
|
402
|
-
console.error(err.pretty());
|
|
403
|
-
// Raw value may also be inspected
|
|
404
|
-
console.error(err.rawValue);
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
case (err instanceof InvalidRequestErrorRep): {
|
|
408
|
-
// Handle err.data$: InvalidRequestErrorRepData
|
|
409
|
-
console.error(err);
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
case (err instanceof UnauthorizedErrorRep): {
|
|
413
|
-
// Handle err.data$: UnauthorizedErrorRepData
|
|
414
|
-
console.error(err);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
case (err instanceof ForbiddenErrorRep): {
|
|
418
|
-
// Handle err.data$: ForbiddenErrorRepData
|
|
419
|
-
console.error(err);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
case (err instanceof NotFoundErrorRep): {
|
|
423
|
-
// Handle err.data$: NotFoundErrorRepData
|
|
424
|
-
console.error(err);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
case (err instanceof RateLimitedErrorRep): {
|
|
428
|
-
// Handle err.data$: RateLimitedErrorRepData
|
|
429
|
-
console.error(err);
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
default: {
|
|
433
|
-
// Other errors such as network errors, see HTTPClientErrors for more details
|
|
434
|
-
throw err;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
run();
|
|
441
|
-
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
|
|
445
|
-
|
|
446
|
-
In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
|
|
447
|
-
|
|
448
|
-
| HTTP Client Error | Description |
|
|
449
|
-
| ---------------------------------------------------- | ---------------------------------------------------- |
|
|
450
|
-
| RequestAbortedError | HTTP request was aborted by the client |
|
|
451
|
-
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
|
|
452
|
-
| ConnectionError | HTTP client was unable to make a request to a server |
|
|
453
|
-
| InvalidRequestError | Any input used to create a request is invalid |
|
|
454
|
-
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
455
|
-
<!-- End Error Handling [errors] -->
|
|
456
|
-
|
|
457
|
-
<!-- Start Server Selection [server] -->
|
|
458
|
-
## Server Selection
|
|
459
|
-
|
|
460
|
-
### Select Server by Index
|
|
461
|
-
|
|
462
|
-
You can override the default server globally by passing a server index to the `serverIdx: number` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
|
|
463
|
-
|
|
464
|
-
| # | Server | Description |
|
|
465
|
-
| --- | ------------------------------ | --------------- |
|
|
466
|
-
| 0 | `https://app.launchdarkly.com` | Default |
|
|
467
|
-
| 1 | `https://app.launchdarkly.us` | Federal |
|
|
468
|
-
| 2 | `https://app.launchdarkly.com` | Prod API server |
|
|
469
|
-
|
|
470
|
-
#### Example
|
|
125
|
+
<!-- No Standalone functions [standalone-funcs] -->
|
|
471
126
|
|
|
472
|
-
|
|
473
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
127
|
+
<!-- No Retries [retries] -->
|
|
474
128
|
|
|
475
|
-
|
|
476
|
-
serverIdx: 2,
|
|
477
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
478
|
-
});
|
|
129
|
+
<!-- No Error Handling [errors] -->
|
|
479
130
|
|
|
480
|
-
|
|
481
|
-
const result = await launchDarkly.featureFlags.list({
|
|
482
|
-
projectKey: "<value>",
|
|
483
|
-
});
|
|
131
|
+
<!-- No Server Selection [server] -->
|
|
484
132
|
|
|
485
|
-
|
|
486
|
-
console.log(result);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
run();
|
|
490
|
-
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### Override Server URL Per-Client
|
|
494
|
-
|
|
495
|
-
The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
|
|
496
|
-
```typescript
|
|
497
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
498
|
-
|
|
499
|
-
const launchDarkly = new LaunchDarkly({
|
|
500
|
-
serverURL: "https://app.launchdarkly.com",
|
|
501
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
async function run() {
|
|
505
|
-
const result = await launchDarkly.featureFlags.list({
|
|
506
|
-
projectKey: "<value>",
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
// Handle the result
|
|
510
|
-
console.log(result);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
run();
|
|
514
|
-
|
|
515
|
-
```
|
|
516
|
-
<!-- End Server Selection [server] -->
|
|
517
|
-
|
|
518
|
-
<!-- Start Custom HTTP Client [http-client] -->
|
|
519
|
-
## Custom HTTP Client
|
|
520
|
-
|
|
521
|
-
The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
|
|
522
|
-
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
|
|
523
|
-
client is a thin wrapper around `fetch` and provides the ability to attach hooks
|
|
524
|
-
around the request lifecycle that can be used to modify the request or handle
|
|
525
|
-
errors and response.
|
|
526
|
-
|
|
527
|
-
The `HTTPClient` constructor takes an optional `fetcher` argument that can be
|
|
528
|
-
used to integrate a third-party HTTP client or when writing tests to mock out
|
|
529
|
-
the HTTP client and feed in fixtures.
|
|
133
|
+
<!-- No Custom HTTP Client [http-client] -->
|
|
530
134
|
|
|
531
|
-
|
|
532
|
-
custom header and a timeout to requests and how to use the `"requestError"` hook
|
|
533
|
-
to log errors:
|
|
135
|
+
<!-- No Debugging [debug] -->
|
|
534
136
|
|
|
535
|
-
|
|
536
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
537
|
-
import { HTTPClient } from "@launchdarkly/mcp-server/lib/http";
|
|
538
|
-
|
|
539
|
-
const httpClient = new HTTPClient({
|
|
540
|
-
// fetcher takes a function that has the same signature as native `fetch`.
|
|
541
|
-
fetcher: (request) => {
|
|
542
|
-
return fetch(request);
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
httpClient.addHook("beforeRequest", (request) => {
|
|
547
|
-
const nextRequest = new Request(request, {
|
|
548
|
-
signal: request.signal || AbortSignal.timeout(5000)
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
nextRequest.headers.set("x-custom-header", "custom value");
|
|
552
|
-
|
|
553
|
-
return nextRequest;
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
httpClient.addHook("requestError", (error, request) => {
|
|
557
|
-
console.group("Request Error");
|
|
558
|
-
console.log("Reason:", `${error}`);
|
|
559
|
-
console.log("Endpoint:", `${request.method} ${request.url}`);
|
|
560
|
-
console.groupEnd();
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
const sdk = new LaunchDarkly({ httpClient });
|
|
564
|
-
```
|
|
565
|
-
<!-- End Custom HTTP Client [http-client] -->
|
|
566
|
-
|
|
567
|
-
<!-- Start Debugging [debug] -->
|
|
568
|
-
## Debugging
|
|
569
|
-
|
|
570
|
-
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
571
|
-
|
|
572
|
-
You can pass a logger that matches `console`'s interface as an SDK option.
|
|
573
|
-
|
|
574
|
-
> [!WARNING]
|
|
575
|
-
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
|
|
576
|
-
|
|
577
|
-
```typescript
|
|
578
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
137
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
579
138
|
|
|
580
|
-
|
|
581
|
-
```
|
|
139
|
+
## Available environments
|
|
582
140
|
|
|
583
|
-
|
|
584
|
-
<!-- End Debugging [debug] -->
|
|
141
|
+
Most customer accounts run on LaunchDarkly's commercial (default) environment. Customers on other environments can specify the `--server-url` argument to connect to the appropriate environment. For example, customers on LaunchDarkly's Federal environment should specify `--server-url https://app.launchdarkly.us` when starting their MCP server.
|
|
585
142
|
|
|
586
|
-
|
|
143
|
+
| # | Server URL | Environment |
|
|
144
|
+
| --- | --------------------------------- | -------------------- |
|
|
145
|
+
| 0 | `https://app.launchdarkly.com` | Commercial (Default) |
|
|
146
|
+
| 1 | `https://app.launchdarkly.us` | Federal |
|
|
147
|
+
| 2 | `https://app.eu.launchdarkly.com` | EU |
|
|
587
148
|
|
|
588
149
|
# Development
|
|
589
150
|
|
package/bin/mcp-server.js
CHANGED
|
@@ -34236,9 +34236,9 @@ var init_config = __esm(() => {
|
|
|
34236
34236
|
SDK_METADATA = {
|
|
34237
34237
|
language: "typescript",
|
|
34238
34238
|
openapiDocVersion: "2.0",
|
|
34239
|
-
sdkVersion: "0.2.
|
|
34239
|
+
sdkVersion: "0.2.4",
|
|
34240
34240
|
genVersion: "2.610.0",
|
|
34241
|
-
userAgent: "speakeasy-sdk/typescript 0.2.
|
|
34241
|
+
userAgent: "speakeasy-sdk/typescript 0.2.4 2.610.0 2.0 @launchdarkly/mcp-server"
|
|
34242
34242
|
};
|
|
34243
34243
|
});
|
|
34244
34244
|
|
|
@@ -40075,7 +40075,7 @@ var init_featureFlagsPatch2 = __esm(() => {
|
|
|
40075
40075
|
function createMCPServer(deps) {
|
|
40076
40076
|
const server = new McpServer({
|
|
40077
40077
|
name: "LaunchDarkly",
|
|
40078
|
-
version: "0.2.
|
|
40078
|
+
version: "0.2.4"
|
|
40079
40079
|
});
|
|
40080
40080
|
const client = new LaunchDarklyCore({
|
|
40081
40081
|
apiKey: deps.apiKey,
|
|
@@ -41317,7 +41317,7 @@ var routes = an({
|
|
|
41317
41317
|
var app = He(routes, {
|
|
41318
41318
|
name: "mcp",
|
|
41319
41319
|
versionInfo: {
|
|
41320
|
-
currentVersion: "0.2.
|
|
41320
|
+
currentVersion: "0.2.4"
|
|
41321
41321
|
}
|
|
41322
41322
|
});
|
|
41323
41323
|
zt(app, process3.argv.slice(2), buildContext(process3));
|
|
@@ -41325,5 +41325,5 @@ export {
|
|
|
41325
41325
|
app
|
|
41326
41326
|
};
|
|
41327
41327
|
|
|
41328
|
-
//# debugId=
|
|
41328
|
+
//# debugId=0E12A4802C200C7164756E2164756E21
|
|
41329
41329
|
//# sourceMappingURL=mcp-server.js.map
|