@launchdarkly/mcp-server 0.2.2 → 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/.devcontainer/README.md +1 -1
- package/README.md +38 -481
- package/bin/mcp-server.js +6 -6
- package/bin/mcp-server.js.map +4 -4
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- 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 +3 -3
- package/dist/esm/lib/config.js +3 -3
- 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 +2 -2
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +1 -1
package/.devcontainer/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
<div align="center">
|
|
3
|
-
<a href="https://codespaces.new/launchdarkly
|
|
3
|
+
<a href="https://codespaces.new/launchdarkly/mcp-server.git/tree/main"><img src="https://github.com/codespaces/badge.svg" /></a>
|
|
4
4
|
</div>
|
|
5
5
|
<br>
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LaunchDarkly's Model Context Protocol (MCP) Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for [LaunchDarkly](https://launchdarkly.com/).
|
|
4
4
|
|
|
5
5
|
<div align="left">
|
|
6
6
|
<a href="https://www.speakeasy.com/?utm_source=@launchdarkly/mcp-server&utm_campaign=typescript"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
|
|
@@ -9,85 +9,30 @@ Developer-friendly & type-safe Typescript SDK specifically catered to leverage *
|
|
|
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
|
-
* [
|
|
23
|
-
* [
|
|
17
|
+
* [LaunchDarkly's Model Context Protocol (MCP) Server](#launchdarklys-model-context-protocol-mcp-server)
|
|
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
|
-
> [!TIP]
|
|
44
|
-
> To finish publishing your SDK to npm and others you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
|
|
28
|
+
<!-- No SDK Installation [installation] -->
|
|
29
|
+
## Installation
|
|
45
30
|
|
|
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.
|
|
46
32
|
|
|
47
|
-
|
|
33
|
+
### Cursor installation steps
|
|
48
34
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm add https://github.com/launchdarkly-labs/mcp-server
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### PNPM
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
pnpm add https://github.com/launchdarkly-labs/mcp-server
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Bun
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
bun add https://github.com/launchdarkly-labs/mcp-server
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Yarn
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
yarn add https://github.com/launchdarkly-labs/mcp-server zod
|
|
71
|
-
|
|
72
|
-
# Note that Yarn does not install peer dependencies automatically. You will need
|
|
73
|
-
# to install zod as shown above.
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
> [!NOTE]
|
|
77
|
-
> This package is published with CommonJS and ES Modules (ESM) support.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
### Model Context Protocol (MCP) Server
|
|
81
|
-
|
|
82
|
-
This SDK is also an installable MCP server where the various SDK methods are
|
|
83
|
-
exposed as tools that can be invoked by AI applications.
|
|
84
|
-
|
|
85
|
-
> Node.js v20 or greater is required to run the MCP server from npm.
|
|
86
|
-
|
|
87
|
-
<details>
|
|
88
|
-
<summary>Claude installation steps</summary>
|
|
89
|
-
|
|
90
|
-
Add the following server definition to your `claude_desktop_config.json` file:
|
|
35
|
+
Create a `.cursor/mcp.json` file in your project root with the following content:
|
|
91
36
|
|
|
92
37
|
```json
|
|
93
38
|
{
|
|
@@ -96,21 +41,19 @@ Add the following server definition to your `claude_desktop_config.json` file:
|
|
|
96
41
|
"command": "npx",
|
|
97
42
|
"args": [
|
|
98
43
|
"-y", "--package", "@launchdarkly/mcp-server",
|
|
99
|
-
"--",
|
|
100
|
-
"
|
|
101
|
-
"--api-key", "..."
|
|
44
|
+
"--", "mcp", "start",
|
|
45
|
+
"--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
102
46
|
]
|
|
103
47
|
}
|
|
104
48
|
}
|
|
105
49
|
}
|
|
106
50
|
```
|
|
107
51
|
|
|
108
|
-
|
|
52
|
+
Specify your API key as found on LaunchDarkly's Authorization page.
|
|
109
53
|
|
|
110
|
-
|
|
111
|
-
<summary>Cursor installation steps</summary>
|
|
54
|
+
### Claude installation steps
|
|
112
55
|
|
|
113
|
-
|
|
56
|
+
Add the following server definition to your `claude_desktop_config.json` file:
|
|
114
57
|
|
|
115
58
|
```json
|
|
116
59
|
{
|
|
@@ -119,112 +62,35 @@ Create a `.cursor/mcp.json` file in your project root with the following content
|
|
|
119
62
|
"command": "npx",
|
|
120
63
|
"args": [
|
|
121
64
|
"-y", "--package", "@launchdarkly/mcp-server",
|
|
122
|
-
"--",
|
|
123
|
-
"
|
|
124
|
-
"--api-key", "..."
|
|
65
|
+
"--", "mcp", "start",
|
|
66
|
+
"--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
125
67
|
]
|
|
126
68
|
}
|
|
127
69
|
}
|
|
128
70
|
}
|
|
129
71
|
```
|
|
130
72
|
|
|
131
|
-
|
|
73
|
+
Specify your API key as found on LaunchDarkly's Authorization page.
|
|
74
|
+
|
|
75
|
+
### Standalone binary installation steps
|
|
132
76
|
|
|
133
|
-
You can also run MCP
|
|
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:
|
|
134
78
|
|
|
135
79
|
```bash
|
|
136
80
|
curl -L -o mcp-server \
|
|
137
|
-
https://github.com/
|
|
81
|
+
https://github.com/launchdarkly/mcp-server/releases/download/{tag}/mcp-server-bun-darwin-arm64 && \
|
|
138
82
|
chmod +x mcp-server
|
|
139
83
|
```
|
|
140
84
|
|
|
141
|
-
If the repo is a private repo you must add your Github PAT to download a release `-H "Authorization: Bearer {GITHUB_PAT}"`.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
{
|
|
146
|
-
"mcpServers": {
|
|
147
|
-
"Todos": {
|
|
148
|
-
"command": "./DOWNLOAD/PATH/mcp-server",
|
|
149
|
-
"args": [
|
|
150
|
-
"start"
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
For a full list of server arguments, run:
|
|
158
|
-
|
|
159
|
-
```sh
|
|
160
|
-
npx -y --package @launchdarkly/mcp-server -- mcp start --help
|
|
161
|
-
```
|
|
162
|
-
<!-- End SDK Installation [installation] -->
|
|
163
|
-
|
|
164
85
|
<!-- Start Requirements [requirements] -->
|
|
165
86
|
## Requirements
|
|
166
87
|
|
|
167
88
|
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
168
89
|
<!-- End Requirements [requirements] -->
|
|
169
90
|
|
|
170
|
-
<!--
|
|
171
|
-
## SDK Example Usage
|
|
172
|
-
|
|
173
|
-
### Example
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
177
|
-
|
|
178
|
-
const launchDarkly = new LaunchDarkly({
|
|
179
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
async function run() {
|
|
183
|
-
const result = await launchDarkly.featureFlags.list({
|
|
184
|
-
projectKey: "<value>",
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// Handle the result
|
|
188
|
-
console.log(result);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
run();
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
<!-- End SDK Example Usage [usage] -->
|
|
195
|
-
|
|
196
|
-
<!-- Start Authentication [security] -->
|
|
197
|
-
## Authentication
|
|
198
|
-
|
|
199
|
-
### Per-Client Security Schemes
|
|
200
|
-
|
|
201
|
-
This SDK supports the following security scheme globally:
|
|
202
|
-
|
|
203
|
-
| Name | Type | Scheme | Environment Variable |
|
|
204
|
-
| -------- | ------ | ------- | ---------------------- |
|
|
205
|
-
| `apiKey` | apiKey | API key | `LAUNCHDARKLY_API_KEY` |
|
|
206
|
-
|
|
207
|
-
To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
|
|
208
|
-
```typescript
|
|
209
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
210
|
-
|
|
211
|
-
const launchDarkly = new LaunchDarkly({
|
|
212
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
async function run() {
|
|
216
|
-
const result = await launchDarkly.featureFlags.list({
|
|
217
|
-
projectKey: "<value>",
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// Handle the result
|
|
221
|
-
console.log(result);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
run();
|
|
91
|
+
<!-- No SDK Example Usage [usage] -->
|
|
225
92
|
|
|
226
|
-
|
|
227
|
-
<!-- End Authentication [security] -->
|
|
93
|
+
<!-- No Authentication [security] -->
|
|
228
94
|
|
|
229
95
|
<!-- Start Available Resources and Operations [operations] -->
|
|
230
96
|
## Available Resources and Operations
|
|
@@ -256,338 +122,29 @@ run();
|
|
|
256
122
|
</details>
|
|
257
123
|
<!-- End Available Resources and Operations [operations] -->
|
|
258
124
|
|
|
259
|
-
<!--
|
|
260
|
-
## Standalone functions
|
|
125
|
+
<!-- No Standalone functions [standalone-funcs] -->
|
|
261
126
|
|
|
262
|
-
|
|
263
|
-
functions are ideal for use in applications running in the browser, serverless
|
|
264
|
-
runtimes or other environments where application bundle size is a primary
|
|
265
|
-
concern. When using a bundler to build your application, all unused
|
|
266
|
-
functionality will be either excluded from the final bundle or tree-shaken away.
|
|
127
|
+
<!-- No Retries [retries] -->
|
|
267
128
|
|
|
268
|
-
|
|
129
|
+
<!-- No Error Handling [errors] -->
|
|
269
130
|
|
|
270
|
-
|
|
131
|
+
<!-- No Server Selection [server] -->
|
|
271
132
|
|
|
272
|
-
|
|
133
|
+
<!-- No Custom HTTP Client [http-client] -->
|
|
273
134
|
|
|
274
|
-
|
|
275
|
-
- [`aiConfigsCreateVariation`](docs/sdks/aiconfigs/README.md#createvariation) - Create AI Config variation
|
|
276
|
-
- [`aiConfigsDelete`](docs/sdks/aiconfigs/README.md#delete) - Delete AI Config
|
|
277
|
-
- [`aiConfigsDeleteVariation`](docs/sdks/aiconfigs/README.md#deletevariation) - Delete AI Config variation
|
|
278
|
-
- [`aiConfigsGet`](docs/sdks/aiconfigs/README.md#get) - Get AI Config
|
|
279
|
-
- [`aiConfigsGetVariation`](docs/sdks/aiconfigs/README.md#getvariation) - Get AI Config variation
|
|
280
|
-
- [`aiConfigsList`](docs/sdks/aiconfigs/README.md#list) - List AI Configs
|
|
281
|
-
- [`aiConfigsUpdate`](docs/sdks/aiconfigs/README.md#update) - Update AI Config
|
|
282
|
-
- [`aiConfigsUpdateVariation`](docs/sdks/aiconfigs/README.md#updatevariation) - Update AI Config variation
|
|
283
|
-
- [`featureFlagsCreate`](docs/sdks/featureflags/README.md#create) - Create a feature flag
|
|
284
|
-
- [`featureFlagsDelete`](docs/sdks/featureflags/README.md#delete) - Delete feature flag
|
|
285
|
-
- [`featureFlagsGet`](docs/sdks/featureflags/README.md#get) - Get feature flag
|
|
286
|
-
- [`featureFlagsList`](docs/sdks/featureflags/README.md#list) - List feature flags
|
|
287
|
-
- [`featureFlagsPatch`](docs/sdks/featureflags/README.md#patch) - Update feature flag
|
|
288
|
-
|
|
289
|
-
</details>
|
|
290
|
-
<!-- End Standalone functions [standalone-funcs] -->
|
|
291
|
-
|
|
292
|
-
<!-- Start Retries [retries] -->
|
|
293
|
-
## Retries
|
|
294
|
-
|
|
295
|
-
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.
|
|
296
|
-
|
|
297
|
-
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
298
|
-
```typescript
|
|
299
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
300
|
-
|
|
301
|
-
const launchDarkly = new LaunchDarkly({
|
|
302
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
async function run() {
|
|
306
|
-
const result = await launchDarkly.featureFlags.list({
|
|
307
|
-
projectKey: "<value>",
|
|
308
|
-
}, {
|
|
309
|
-
retries: {
|
|
310
|
-
strategy: "backoff",
|
|
311
|
-
backoff: {
|
|
312
|
-
initialInterval: 1,
|
|
313
|
-
maxInterval: 50,
|
|
314
|
-
exponent: 1.1,
|
|
315
|
-
maxElapsedTime: 100,
|
|
316
|
-
},
|
|
317
|
-
retryConnectionErrors: false,
|
|
318
|
-
},
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// Handle the result
|
|
322
|
-
console.log(result);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
run();
|
|
326
|
-
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
330
|
-
```typescript
|
|
331
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
332
|
-
|
|
333
|
-
const launchDarkly = new LaunchDarkly({
|
|
334
|
-
retryConfig: {
|
|
335
|
-
strategy: "backoff",
|
|
336
|
-
backoff: {
|
|
337
|
-
initialInterval: 1,
|
|
338
|
-
maxInterval: 50,
|
|
339
|
-
exponent: 1.1,
|
|
340
|
-
maxElapsedTime: 100,
|
|
341
|
-
},
|
|
342
|
-
retryConnectionErrors: false,
|
|
343
|
-
},
|
|
344
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
async function run() {
|
|
348
|
-
const result = await launchDarkly.featureFlags.list({
|
|
349
|
-
projectKey: "<value>",
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// Handle the result
|
|
353
|
-
console.log(result);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
run();
|
|
357
|
-
|
|
358
|
-
```
|
|
359
|
-
<!-- End Retries [retries] -->
|
|
360
|
-
|
|
361
|
-
<!-- Start Error Handling [errors] -->
|
|
362
|
-
## Error Handling
|
|
363
|
-
|
|
364
|
-
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:
|
|
365
|
-
|
|
366
|
-
| Error Type | Status Code | Content Type |
|
|
367
|
-
| ----------------------------- | ----------- | ---------------- |
|
|
368
|
-
| errors.InvalidRequestErrorRep | 400 | application/json |
|
|
369
|
-
| errors.UnauthorizedErrorRep | 401 | application/json |
|
|
370
|
-
| errors.ForbiddenErrorRep | 403 | application/json |
|
|
371
|
-
| errors.NotFoundErrorRep | 404 | application/json |
|
|
372
|
-
| errors.RateLimitedErrorRep | 429 | application/json |
|
|
373
|
-
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
374
|
-
|
|
375
|
-
If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
|
|
376
|
-
|
|
377
|
-
```typescript
|
|
378
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
379
|
-
import {
|
|
380
|
-
ForbiddenErrorRep,
|
|
381
|
-
InvalidRequestErrorRep,
|
|
382
|
-
NotFoundErrorRep,
|
|
383
|
-
RateLimitedErrorRep,
|
|
384
|
-
SDKValidationError,
|
|
385
|
-
UnauthorizedErrorRep,
|
|
386
|
-
} from "@launchdarkly/mcp-server/models/errors";
|
|
387
|
-
|
|
388
|
-
const launchDarkly = new LaunchDarkly({
|
|
389
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
async function run() {
|
|
393
|
-
let result;
|
|
394
|
-
try {
|
|
395
|
-
result = await launchDarkly.featureFlags.list({
|
|
396
|
-
projectKey: "<value>",
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
// Handle the result
|
|
400
|
-
console.log(result);
|
|
401
|
-
} catch (err) {
|
|
402
|
-
switch (true) {
|
|
403
|
-
// The server response does not match the expected SDK schema
|
|
404
|
-
case (err instanceof SDKValidationError): {
|
|
405
|
-
// Pretty-print will provide a human-readable multi-line error message
|
|
406
|
-
console.error(err.pretty());
|
|
407
|
-
// Raw value may also be inspected
|
|
408
|
-
console.error(err.rawValue);
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
case (err instanceof InvalidRequestErrorRep): {
|
|
412
|
-
// Handle err.data$: InvalidRequestErrorRepData
|
|
413
|
-
console.error(err);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
case (err instanceof UnauthorizedErrorRep): {
|
|
417
|
-
// Handle err.data$: UnauthorizedErrorRepData
|
|
418
|
-
console.error(err);
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
case (err instanceof ForbiddenErrorRep): {
|
|
422
|
-
// Handle err.data$: ForbiddenErrorRepData
|
|
423
|
-
console.error(err);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
case (err instanceof NotFoundErrorRep): {
|
|
427
|
-
// Handle err.data$: NotFoundErrorRepData
|
|
428
|
-
console.error(err);
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
case (err instanceof RateLimitedErrorRep): {
|
|
432
|
-
// Handle err.data$: RateLimitedErrorRepData
|
|
433
|
-
console.error(err);
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
default: {
|
|
437
|
-
// Other errors such as network errors, see HTTPClientErrors for more details
|
|
438
|
-
throw err;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
run();
|
|
445
|
-
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
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.
|
|
449
|
-
|
|
450
|
-
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:
|
|
451
|
-
|
|
452
|
-
| HTTP Client Error | Description |
|
|
453
|
-
| ---------------------------------------------------- | ---------------------------------------------------- |
|
|
454
|
-
| RequestAbortedError | HTTP request was aborted by the client |
|
|
455
|
-
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
|
|
456
|
-
| ConnectionError | HTTP client was unable to make a request to a server |
|
|
457
|
-
| InvalidRequestError | Any input used to create a request is invalid |
|
|
458
|
-
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
459
|
-
<!-- End Error Handling [errors] -->
|
|
460
|
-
|
|
461
|
-
<!-- Start Server Selection [server] -->
|
|
462
|
-
## Server Selection
|
|
463
|
-
|
|
464
|
-
### Select Server by Index
|
|
465
|
-
|
|
466
|
-
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:
|
|
467
|
-
|
|
468
|
-
| # | Server | Description |
|
|
469
|
-
| --- | ------------------------------ | --------------- |
|
|
470
|
-
| 0 | `https://app.launchdarkly.com` | Default |
|
|
471
|
-
| 1 | `https://app.launchdarkly.us` | Federal |
|
|
472
|
-
| 2 | `https://app.launchdarkly.com` | Prod API server |
|
|
473
|
-
|
|
474
|
-
#### Example
|
|
475
|
-
|
|
476
|
-
```typescript
|
|
477
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
478
|
-
|
|
479
|
-
const launchDarkly = new LaunchDarkly({
|
|
480
|
-
serverIdx: 2,
|
|
481
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
async function run() {
|
|
485
|
-
const result = await launchDarkly.featureFlags.list({
|
|
486
|
-
projectKey: "<value>",
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
// Handle the result
|
|
490
|
-
console.log(result);
|
|
491
|
-
}
|
|
135
|
+
<!-- No Debugging [debug] -->
|
|
492
136
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
### Override Server URL Per-Client
|
|
498
|
-
|
|
499
|
-
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:
|
|
500
|
-
```typescript
|
|
501
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
502
|
-
|
|
503
|
-
const launchDarkly = new LaunchDarkly({
|
|
504
|
-
serverURL: "https://app.launchdarkly.com",
|
|
505
|
-
apiKey: process.env["LAUNCHDARKLY_API_KEY"] ?? "",
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
async function run() {
|
|
509
|
-
const result = await launchDarkly.featureFlags.list({
|
|
510
|
-
projectKey: "<value>",
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
// Handle the result
|
|
514
|
-
console.log(result);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
run();
|
|
518
|
-
|
|
519
|
-
```
|
|
520
|
-
<!-- End Server Selection [server] -->
|
|
521
|
-
|
|
522
|
-
<!-- Start Custom HTTP Client [http-client] -->
|
|
523
|
-
## Custom HTTP Client
|
|
524
|
-
|
|
525
|
-
The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
|
|
526
|
-
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
|
|
527
|
-
client is a thin wrapper around `fetch` and provides the ability to attach hooks
|
|
528
|
-
around the request lifecycle that can be used to modify the request or handle
|
|
529
|
-
errors and response.
|
|
530
|
-
|
|
531
|
-
The `HTTPClient` constructor takes an optional `fetcher` argument that can be
|
|
532
|
-
used to integrate a third-party HTTP client or when writing tests to mock out
|
|
533
|
-
the HTTP client and feed in fixtures.
|
|
534
|
-
|
|
535
|
-
The following example shows how to use the `"beforeRequest"` hook to to add a
|
|
536
|
-
custom header and a timeout to requests and how to use the `"requestError"` hook
|
|
537
|
-
to log errors:
|
|
538
|
-
|
|
539
|
-
```typescript
|
|
540
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
541
|
-
import { HTTPClient } from "@launchdarkly/mcp-server/lib/http";
|
|
542
|
-
|
|
543
|
-
const httpClient = new HTTPClient({
|
|
544
|
-
// fetcher takes a function that has the same signature as native `fetch`.
|
|
545
|
-
fetcher: (request) => {
|
|
546
|
-
return fetch(request);
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
httpClient.addHook("beforeRequest", (request) => {
|
|
551
|
-
const nextRequest = new Request(request, {
|
|
552
|
-
signal: request.signal || AbortSignal.timeout(5000)
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
nextRequest.headers.set("x-custom-header", "custom value");
|
|
556
|
-
|
|
557
|
-
return nextRequest;
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
httpClient.addHook("requestError", (error, request) => {
|
|
561
|
-
console.group("Request Error");
|
|
562
|
-
console.log("Reason:", `${error}`);
|
|
563
|
-
console.log("Endpoint:", `${request.method} ${request.url}`);
|
|
564
|
-
console.groupEnd();
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
const sdk = new LaunchDarkly({ httpClient });
|
|
568
|
-
```
|
|
569
|
-
<!-- End Custom HTTP Client [http-client] -->
|
|
570
|
-
|
|
571
|
-
<!-- Start Debugging [debug] -->
|
|
572
|
-
## Debugging
|
|
573
|
-
|
|
574
|
-
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
575
|
-
|
|
576
|
-
You can pass a logger that matches `console`'s interface as an SDK option.
|
|
577
|
-
|
|
578
|
-
> [!WARNING]
|
|
579
|
-
> 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.
|
|
580
|
-
|
|
581
|
-
```typescript
|
|
582
|
-
import { LaunchDarkly } from "@launchdarkly/mcp-server";
|
|
137
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
583
138
|
|
|
584
|
-
|
|
585
|
-
```
|
|
139
|
+
## Available environments
|
|
586
140
|
|
|
587
|
-
|
|
588
|
-
<!-- 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.
|
|
589
142
|
|
|
590
|
-
|
|
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 |
|
|
591
148
|
|
|
592
149
|
# Development
|
|
593
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.
|
|
34240
|
-
genVersion: "2.
|
|
34241
|
-
userAgent: "speakeasy-sdk/typescript 0.2.
|
|
34239
|
+
sdkVersion: "0.2.4",
|
|
34240
|
+
genVersion: "2.610.0",
|
|
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
|