@flagdeck/mcp-server 0.1.1 → 0.4.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 +100 -114
- package/dist/client.d.ts +85 -38
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +168 -140
- package/dist/client.js.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +148 -30
- package/dist/server.js.map +1 -1
- package/dist/setup.js +36 -28
- package/dist/setup.js.map +1 -1
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +437 -48
- package/dist/tools/index.js.map +1 -1
- package/dist/types.d.ts +73 -12
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
1
|
# @flagdeck/mcp-server
|
|
2
2
|
|
|
3
|
-
**Model Context Protocol (MCP) server for Flagdeck** - enables AI agents like Claude, Cursor, and
|
|
3
|
+
**Model Context Protocol (MCP) server for Flagdeck** - enables AI agents like Claude, Cursor, and VS Code to manage feature flags directly.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
[](https://cursor.com/install-mcp?name=flagdeck&config=eyJ0eXBlIjoic3RkaW8iLCJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBmbGFnZGVjay9tY3Atc2VydmVyIl0sImVudiI6eyJGTEFHREVDS19BUElfS0VZIjoiJHtGTEFHREVDS19BUElfS0VZfSJ9fQ==)
|
|
8
|
+
[](https://vscode.dev/redirect/mcp/install?name=flagdeck&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40flagdeck%2Fmcp-server%22%5D%2C%22env%22%3A%7B%22FLAGDECK_API_KEY%22%3A%22%24%7Binput%3Aflagdeck-api-key%7D%22%7D%7D&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22flagdeck-api-key%22%2C%22description%22%3A%22Your%20Flagdeck%20API%20key%22%2C%22password%22%3Atrue%7D%5D)
|
|
9
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=flagdeck&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40flagdeck%2Fmcp-server%22%5D%2C%22env%22%3A%7B%22FLAGDECK_API_KEY%22%3A%22%24%7Binput%3Aflagdeck-api-key%7D%22%7D%7D&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22flagdeck-api-key%22%2C%22description%22%3A%22Your%20Flagdeck%20API%20key%22%2C%22password%22%3Atrue%7D%5D&quality=insiders)
|
|
4
10
|
|
|
5
11
|
## What is This?
|
|
6
12
|
|
|
7
13
|
This is an MCP server that allows AI coding assistants to:
|
|
8
|
-
- ✅ Create, read, update, and delete feature flags
|
|
9
|
-
- ✅ Evaluate flags for specific users/contexts
|
|
10
|
-
- ✅ Manage projects and environments
|
|
11
|
-
- ✅ Use natural language to create/update flags ("Create a dark mode flag for premium users")
|
|
12
|
-
- ✅ All from within your editor or CLI
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
- Create, read, update, and delete feature flags
|
|
16
|
+
- Evaluate flags for specific users/contexts
|
|
17
|
+
- Manage projects and environments
|
|
18
|
+
- Manage flags in plain English — your coding agent maps requests to the structured flag tools
|
|
19
|
+
- All from within your editor or CLI
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install -g @flagdeck/mcp-server
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Configuration
|
|
21
|
+
## Quick Start
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
You'll need a [Flagdeck API key](https://flagdeck.com).
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export FLAGDECK_ENVIRONMENT=production # optional, defaults to production
|
|
31
|
-
```
|
|
25
|
+
> **Project binding.** Scope your key to a single project and the MCP binds to
|
|
26
|
+
> it automatically — you don't set `FLAGDECK_PROJECT_ID`, and the tools take no
|
|
27
|
+
> `projectId` argument. A key that spans multiple projects needs a `projectId`
|
|
28
|
+
> per call (or set `FLAGDECK_PROJECT_ID` as the working project).
|
|
32
29
|
|
|
33
|
-
###
|
|
30
|
+
### Claude Code (CLI)
|
|
34
31
|
|
|
35
32
|
```bash
|
|
36
|
-
flagdeck
|
|
33
|
+
claude mcp add --transport stdio flagdeck \
|
|
34
|
+
--env FLAGDECK_API_KEY=your-org-management-key \
|
|
35
|
+
-- npx -y @flagdeck/mcp-server
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
The server runs on stdio and communicates via the Model Context Protocol.
|
|
40
|
-
|
|
41
|
-
## Usage with AI Assistants
|
|
42
|
-
|
|
43
38
|
### Claude Desktop
|
|
44
39
|
|
|
45
|
-
Add to
|
|
40
|
+
Add to `claude_desktop_config.json`:
|
|
46
41
|
|
|
47
42
|
```json
|
|
48
43
|
{
|
|
49
44
|
"mcpServers": {
|
|
50
45
|
"flagdeck": {
|
|
51
|
-
"command": "
|
|
46
|
+
"command": "npx",
|
|
47
|
+
"args": ["-y", "@flagdeck/mcp-server"],
|
|
52
48
|
"env": {
|
|
53
|
-
"FLAGDECK_API_KEY": "your-
|
|
54
|
-
"FLAGDECK_API_URL": "https://api.flagdeck.com",
|
|
55
|
-
"FLAGDECK_PROJECT_ID": "your-project-id"
|
|
49
|
+
"FLAGDECK_API_KEY": "your-org-management-key"
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
```
|
|
61
55
|
|
|
62
|
-
Then in Claude
|
|
56
|
+
Then in Claude:
|
|
63
57
|
|
|
64
58
|
```
|
|
65
59
|
You: "Create a dark mode feature flag"
|
|
@@ -74,32 +68,34 @@ Claude: *uses evaluate_flag tool* Yes, it's enabled for that user.
|
|
|
74
68
|
|
|
75
69
|
### Cursor IDE
|
|
76
70
|
|
|
77
|
-
|
|
71
|
+
Click the button above, or add manually to `.cursor/mcp.json`:
|
|
78
72
|
|
|
79
73
|
```json
|
|
80
74
|
{
|
|
81
|
-
"
|
|
75
|
+
"mcpServers": {
|
|
82
76
|
"flagdeck": {
|
|
83
|
-
"command": "
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["-y", "@flagdeck/mcp-server"],
|
|
84
79
|
"env": {
|
|
85
|
-
"FLAGDECK_API_KEY": "your-
|
|
80
|
+
"FLAGDECK_API_KEY": "your-org-management-key"
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
```
|
|
91
86
|
|
|
92
|
-
### Windsurf
|
|
87
|
+
### VS Code / Windsurf
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
Click the VS Code button above, or add to your MCP config:
|
|
95
90
|
|
|
96
91
|
```json
|
|
97
92
|
{
|
|
98
93
|
"servers": {
|
|
99
94
|
"flagdeck": {
|
|
100
|
-
"command": "npx
|
|
95
|
+
"command": "npx",
|
|
96
|
+
"args": ["-y", "@flagdeck/mcp-server"],
|
|
101
97
|
"env": {
|
|
102
|
-
"FLAGDECK_API_KEY": "your-
|
|
98
|
+
"FLAGDECK_API_KEY": "your-org-management-key"
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
}
|
|
@@ -111,23 +107,29 @@ Add to Windsurf MCP configuration:
|
|
|
111
107
|
### Project & Environment Management
|
|
112
108
|
|
|
113
109
|
#### `list_projects`
|
|
110
|
+
|
|
114
111
|
List all projects accessible to your API key.
|
|
115
112
|
|
|
116
113
|
**Example:**
|
|
114
|
+
|
|
117
115
|
```
|
|
118
116
|
"Show me all my projects"
|
|
119
117
|
```
|
|
120
118
|
|
|
121
119
|
#### `get_project`
|
|
120
|
+
|
|
122
121
|
Get details of a specific project.
|
|
123
122
|
|
|
124
123
|
**Parameters:**
|
|
124
|
+
|
|
125
125
|
- `projectId` (optional): Project ID
|
|
126
126
|
|
|
127
127
|
#### `list_environments`
|
|
128
|
+
|
|
128
129
|
List all environments in a project.
|
|
129
130
|
|
|
130
131
|
**Parameters:**
|
|
132
|
+
|
|
131
133
|
- `projectId` (optional): Project ID
|
|
132
134
|
|
|
133
135
|
---
|
|
@@ -135,35 +137,43 @@ List all environments in a project.
|
|
|
135
137
|
### Flag Management
|
|
136
138
|
|
|
137
139
|
#### `list_flags`
|
|
140
|
+
|
|
138
141
|
List all feature flags in a project.
|
|
139
142
|
|
|
140
143
|
**Parameters:**
|
|
144
|
+
|
|
141
145
|
- `projectId` (optional): Project ID
|
|
142
146
|
- `status` (optional): Filter by status (active/inactive/archived)
|
|
143
147
|
- `search` (optional): Search by name or key
|
|
144
148
|
|
|
145
149
|
**Example:**
|
|
150
|
+
|
|
146
151
|
```
|
|
147
152
|
"Show me all active flags"
|
|
148
153
|
"List flags containing 'checkout'"
|
|
149
154
|
```
|
|
150
155
|
|
|
151
156
|
#### `get_flag`
|
|
157
|
+
|
|
152
158
|
Get details of a specific flag.
|
|
153
159
|
|
|
154
160
|
**Parameters:**
|
|
161
|
+
|
|
155
162
|
- `projectId` (optional): Project ID
|
|
156
163
|
- `flagId` OR `flagKey`: Flag identifier
|
|
157
164
|
|
|
158
165
|
**Example:**
|
|
166
|
+
|
|
159
167
|
```
|
|
160
168
|
"Show me the dark-mode flag"
|
|
161
169
|
```
|
|
162
170
|
|
|
163
171
|
#### `create_flag`
|
|
172
|
+
|
|
164
173
|
Create a new feature flag.
|
|
165
174
|
|
|
166
175
|
**Parameters:**
|
|
176
|
+
|
|
167
177
|
- `projectId` (optional): Project ID
|
|
168
178
|
- `key` (required): Unique flag key
|
|
169
179
|
- `name` (required): Human-readable name
|
|
@@ -174,42 +184,52 @@ Create a new feature flag.
|
|
|
174
184
|
- `rolloutPercentage` (optional): Rollout percentage (0-100)
|
|
175
185
|
|
|
176
186
|
**Example:**
|
|
187
|
+
|
|
177
188
|
```
|
|
178
189
|
"Create a flag called 'new-checkout' with 25% rollout"
|
|
179
190
|
```
|
|
180
191
|
|
|
181
192
|
#### `update_flag`
|
|
193
|
+
|
|
182
194
|
Update an existing flag.
|
|
183
195
|
|
|
184
196
|
**Parameters:**
|
|
197
|
+
|
|
185
198
|
- `projectId` (optional): Project ID
|
|
186
199
|
- `flagId` (required): Flag ID
|
|
187
200
|
- `name`, `description`, `status`, `defaultValue`, `targetingRules`, `rolloutPercentage` (all optional)
|
|
188
201
|
|
|
189
202
|
**Example:**
|
|
203
|
+
|
|
190
204
|
```
|
|
191
205
|
"Increase new-checkout rollout to 50%"
|
|
192
206
|
"Disable the dark-mode flag"
|
|
193
207
|
```
|
|
194
208
|
|
|
195
209
|
#### `delete_flag`
|
|
210
|
+
|
|
196
211
|
Permanently delete a flag.
|
|
197
212
|
|
|
198
213
|
**Parameters:**
|
|
214
|
+
|
|
199
215
|
- `projectId` (optional): Project ID
|
|
200
216
|
- `flagId` (required): Flag ID
|
|
201
217
|
|
|
202
218
|
#### `toggle_flag`
|
|
219
|
+
|
|
203
220
|
Toggle a flag between active and inactive.
|
|
204
221
|
|
|
205
222
|
**Parameters:**
|
|
223
|
+
|
|
206
224
|
- `projectId` (optional): Project ID
|
|
207
225
|
- `flagId` (required): Flag ID
|
|
208
226
|
|
|
209
227
|
#### `archive_flag`
|
|
228
|
+
|
|
210
229
|
Archive a flag (soft delete).
|
|
211
230
|
|
|
212
231
|
**Parameters:**
|
|
232
|
+
|
|
213
233
|
- `projectId` (optional): Project ID
|
|
214
234
|
- `flagId` (required): Flag ID
|
|
215
235
|
|
|
@@ -218,64 +238,35 @@ Archive a flag (soft delete).
|
|
|
218
238
|
### Flag Evaluation
|
|
219
239
|
|
|
220
240
|
#### `evaluate_flag`
|
|
241
|
+
|
|
221
242
|
Evaluate a flag for a specific user/context.
|
|
222
243
|
|
|
223
244
|
**Parameters:**
|
|
245
|
+
|
|
224
246
|
- `flagKey` (required): Flag key
|
|
225
247
|
- `context` (required): User context object
|
|
226
248
|
- `userId`, `email`, `plan`, `country`, etc.
|
|
227
249
|
- `environment` (optional): Environment name
|
|
228
250
|
|
|
229
251
|
**Example:**
|
|
252
|
+
|
|
230
253
|
```
|
|
231
254
|
"Check if dark-mode is enabled for user@example.com"
|
|
232
255
|
"Evaluate new-checkout for a user with plan=premium"
|
|
233
256
|
```
|
|
234
257
|
|
|
235
258
|
#### `evaluate_batch`
|
|
259
|
+
|
|
236
260
|
Evaluate multiple flags at once.
|
|
237
261
|
|
|
238
262
|
**Parameters:**
|
|
263
|
+
|
|
239
264
|
- `flagKeys` (required): Array of flag keys
|
|
240
265
|
- `context` (required): User context
|
|
241
266
|
- `environment` (optional): Environment name
|
|
242
267
|
|
|
243
268
|
---
|
|
244
269
|
|
|
245
|
-
### Natural Language AI Tools
|
|
246
|
-
|
|
247
|
-
#### `create_flag_natural_language`
|
|
248
|
-
Create a flag using natural language.
|
|
249
|
-
|
|
250
|
-
**Parameters:**
|
|
251
|
-
- `projectId` (optional): Project ID
|
|
252
|
-
- `input` (required): Natural language description
|
|
253
|
-
- `context` (optional): Additional context
|
|
254
|
-
|
|
255
|
-
**Examples:**
|
|
256
|
-
```
|
|
257
|
-
"Create a dark mode flag for premium users"
|
|
258
|
-
"Add a flag to roll out new checkout to 25% of users"
|
|
259
|
-
"Enable advanced analytics for users in US and CA"
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
#### `update_flag_natural_language`
|
|
263
|
-
Update a flag using natural language.
|
|
264
|
-
|
|
265
|
-
**Parameters:**
|
|
266
|
-
- `projectId` (optional): Project ID
|
|
267
|
-
- `input` (required): Natural language description
|
|
268
|
-
- `context` (optional): Should include `flagKey`
|
|
269
|
-
|
|
270
|
-
**Examples:**
|
|
271
|
-
```
|
|
272
|
-
"Disable the dark-mode flag"
|
|
273
|
-
"Increase new-checkout rollout to 75%"
|
|
274
|
-
"Archive the old-payment-flow flag"
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
---
|
|
278
|
-
|
|
279
270
|
## Examples
|
|
280
271
|
|
|
281
272
|
### Example 1: Create and Configure a Flag
|
|
@@ -284,7 +275,7 @@ Update a flag using natural language.
|
|
|
284
275
|
User: "Create a feature flag for beta users"
|
|
285
276
|
|
|
286
277
|
AI: I'll create a beta feature flag for you.
|
|
287
|
-
*uses
|
|
278
|
+
*uses create_flag tool*
|
|
288
279
|
|
|
289
280
|
Result: Created flag 'beta-features' with targeting rule for users with plan=beta
|
|
290
281
|
```
|
|
@@ -311,7 +302,7 @@ Result: Rollout increased to 25%
|
|
|
311
302
|
User: "Create a premium-analytics flag only for enterprise users"
|
|
312
303
|
|
|
313
304
|
AI: I'll create that with enterprise targeting.
|
|
314
|
-
*uses
|
|
305
|
+
*uses create_flag tool*
|
|
315
306
|
|
|
316
307
|
Result: Created flag with targeting rule: plan equals 'enterprise'
|
|
317
308
|
```
|
|
@@ -335,17 +326,9 @@ Result: {
|
|
|
335
326
|
|
|
336
327
|
## Advanced Usage
|
|
337
328
|
|
|
338
|
-
### Custom API Endpoint
|
|
339
|
-
|
|
340
|
-
If you're self-hosting Flagdeck:
|
|
341
|
-
|
|
342
|
-
```bash
|
|
343
|
-
export FLAGDECK_API_URL=https://your-flagdeck-instance.com
|
|
344
|
-
```
|
|
345
|
-
|
|
346
329
|
### Per-Request Project ID
|
|
347
330
|
|
|
348
|
-
|
|
331
|
+
Tools default to the project your API key belongs to. To act on a different project, name it in the request:
|
|
349
332
|
|
|
350
333
|
```
|
|
351
334
|
"List flags in project proj-123"
|
|
@@ -390,52 +373,55 @@ npm test
|
|
|
390
373
|
|
|
391
374
|
### Configuration
|
|
392
375
|
|
|
393
|
-
| Environment Variable
|
|
394
|
-
|
|
395
|
-
| `FLAGDECK_API_KEY`
|
|
396
|
-
| `
|
|
397
|
-
| `
|
|
398
|
-
| `FLAGDECK_ENVIRONMENT` | No | `production` | Default environment |
|
|
376
|
+
| Environment Variable | Required | Default | Description |
|
|
377
|
+
| ---------------------- | -------- | ------- | -------------------------------------------------------------------------------------- |
|
|
378
|
+
| `FLAGDECK_API_KEY` | Yes | - | Organization management API key (sent as `Authorization: Bearer`) |
|
|
379
|
+
| `FLAGDECK_PROJECT_ID` | No | - | Working project for a key that spans projects; unused for a single-project (bound) key |
|
|
380
|
+
| `FLAGDECK_ENVIRONMENT` | No | - | Default environment for the `evaluate_*` / `set_flag_targeting` tools |
|
|
399
381
|
|
|
400
382
|
### Tool Summary
|
|
401
383
|
|
|
402
|
-
| Tool
|
|
403
|
-
|
|
404
|
-
| `list_projects`
|
|
405
|
-
| `get_project`
|
|
406
|
-
| `list_environments` | List environments
|
|
407
|
-
| `list_flags`
|
|
408
|
-
| `get_flag`
|
|
409
|
-
| `create_flag`
|
|
410
|
-
| `update_flag`
|
|
411
|
-
| `delete_flag`
|
|
412
|
-
| `toggle_flag`
|
|
413
|
-
| `archive_flag`
|
|
414
|
-
| `evaluate_flag`
|
|
415
|
-
| `evaluate_batch`
|
|
416
|
-
| `create_flag_natural_language` | AI-powered flag creation | `input` |
|
|
417
|
-
| `update_flag_natural_language` | AI-powered flag update | `input` |
|
|
384
|
+
| Tool | Purpose | Required Params |
|
|
385
|
+
| ------------------- | ----------------------- | ------------------------------------------ |
|
|
386
|
+
| `list_projects` | List all projects | - |
|
|
387
|
+
| `get_project` | Get project details | - |
|
|
388
|
+
| `list_environments` | List environments | - |
|
|
389
|
+
| `list_flags` | List flags | - |
|
|
390
|
+
| `get_flag` | Get flag details | `flagId` or `flagKey` |
|
|
391
|
+
| `create_flag` | Create new flag | `key`, `name`, `valueType`, `defaultValue` |
|
|
392
|
+
| `update_flag` | Update flag | `flagId` |
|
|
393
|
+
| `delete_flag` | Delete flag | `flagId` |
|
|
394
|
+
| `toggle_flag` | Toggle flag status | `flagId` |
|
|
395
|
+
| `archive_flag` | Archive flag | `flagId` |
|
|
396
|
+
| `evaluate_flag` | Evaluate single flag | `flagKey`, `context` |
|
|
397
|
+
| `evaluate_batch` | Evaluate multiple flags | `flagKeys`, `context` |
|
|
418
398
|
|
|
419
399
|
---
|
|
420
400
|
|
|
421
401
|
## Troubleshooting
|
|
422
402
|
|
|
423
|
-
### "FLAGDECK_API_KEY is required"
|
|
403
|
+
### "FLAGDECK_API_KEY ... is required"
|
|
404
|
+
|
|
405
|
+
Set your organization management key (not an SDK key):
|
|
424
406
|
|
|
425
|
-
Set your API key:
|
|
426
407
|
```bash
|
|
427
|
-
export FLAGDECK_API_KEY=your-key
|
|
408
|
+
export FLAGDECK_API_KEY=your-org-management-key
|
|
409
|
+
# FLAGDECK_PROJECT_ID is only needed for a key that spans multiple projects
|
|
410
|
+
export FLAGDECK_ENVIRONMENT=development # optional
|
|
428
411
|
```
|
|
429
412
|
|
|
430
413
|
### "projectId is required"
|
|
431
414
|
|
|
432
|
-
|
|
415
|
+
Your key can access multiple projects, so the MCP can't pick one for you. Pass
|
|
416
|
+
`projectId` in the request, or set `FLAGDECK_PROJECT_ID` as the working project.
|
|
417
|
+
A key scoped to a single project binds automatically and never needs this.
|
|
433
418
|
|
|
434
419
|
### Connection Errors
|
|
435
420
|
|
|
436
|
-
Check that
|
|
421
|
+
Check that the Flagdeck API is reachable:
|
|
422
|
+
|
|
437
423
|
```bash
|
|
438
|
-
curl
|
|
424
|
+
curl https://api.flagdeck.com/health
|
|
439
425
|
```
|
|
440
426
|
|
|
441
427
|
### Tool Not Found
|
package/dist/client.d.ts
CHANGED
|
@@ -1,76 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flagdeck API Client
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Talks to the Flagdeck ORGANIZATION MANAGEMENT API (/v1), authenticated with an
|
|
5
|
+
* org management key (Authorization: Bearer). Management, reads and test-
|
|
6
|
+
* evaluation all go through /v1; the SDK evaluation plane (/sdk) is not used.
|
|
7
|
+
* The key's own scope decides the project: a single-project key binds the
|
|
8
|
+
* client to that project; a wildcard/multi key resolves the project per call.
|
|
4
9
|
*/
|
|
5
|
-
import { FlagdeckConfig, Flag, CreateFlagInput, UpdateFlagInput, EvaluationContext, EvaluationResult, Project, Environment } from './types.js';
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
import { FlagdeckConfig, Flag, CreateFlagInput, UpdateFlagInput, EvaluationContext, EvaluationResult, Project, Environment, CodeReferencesRequest, CodeReferencesResponse, FlagCodeReference, FlagCodeRefsSummary, Segment, SegmentInput } from './types.js';
|
|
11
|
+
export interface BoundProject {
|
|
12
|
+
id: string;
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
}
|
|
17
|
+
export interface KeyContext {
|
|
11
18
|
organizationId: string;
|
|
12
|
-
|
|
19
|
+
scopes: string[];
|
|
20
|
+
projectAccess: {
|
|
21
|
+
projectId: string;
|
|
22
|
+
}[];
|
|
23
|
+
/** The single project this key is bound to, or null when it spans projects. */
|
|
24
|
+
boundProjectId: string | null;
|
|
25
|
+
boundProject: BoundProject | null;
|
|
13
26
|
environmentKey?: string;
|
|
14
|
-
environmentName?: string;
|
|
15
27
|
}
|
|
16
28
|
export declare class FlagdeckClient {
|
|
17
29
|
private config;
|
|
18
30
|
private baseHeaders;
|
|
19
|
-
private
|
|
20
|
-
private
|
|
31
|
+
private configuredProjectId;
|
|
32
|
+
private boundProjectId;
|
|
33
|
+
private defaultEnvironment;
|
|
34
|
+
private keyContext;
|
|
21
35
|
constructor(config: FlagdeckConfig);
|
|
36
|
+
private proj;
|
|
37
|
+
private requireEnv;
|
|
22
38
|
/**
|
|
23
|
-
* Resolve
|
|
24
|
-
*
|
|
39
|
+
* Resolve this key's scope from the server. A key bound to exactly one project
|
|
40
|
+
* sets boundProjectId; a wildcard/multi key leaves it null, and project-scoped
|
|
41
|
+
* tools then require a projectId per call.
|
|
25
42
|
*/
|
|
26
|
-
initialize(): Promise<
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
initialize(): Promise<KeyContext>;
|
|
44
|
+
/** True when the key is bound to exactly one project. */
|
|
45
|
+
isBound(): boolean;
|
|
46
|
+
getBoundProjectId(): string | undefined;
|
|
47
|
+
getContext(): KeyContext | undefined;
|
|
29
48
|
private request;
|
|
30
49
|
listProjects(): Promise<Project[]>;
|
|
31
|
-
getProject(
|
|
32
|
-
listEnvironments(
|
|
33
|
-
getEnvironment(
|
|
34
|
-
listFlags(
|
|
50
|
+
getProject(projectId?: string): Promise<Project>;
|
|
51
|
+
listEnvironments(projectId?: string): Promise<Environment[]>;
|
|
52
|
+
getEnvironment(projectId: string | undefined, environmentKey: string): Promise<Environment>;
|
|
53
|
+
listFlags(projectId?: string, params?: {
|
|
35
54
|
status?: string;
|
|
36
55
|
search?: string;
|
|
37
56
|
}): Promise<Flag[]>;
|
|
38
|
-
getFlag(
|
|
39
|
-
getFlagByKey(
|
|
40
|
-
createFlag(
|
|
41
|
-
updateFlag(
|
|
42
|
-
deleteFlag(
|
|
43
|
-
toggleFlag(
|
|
44
|
-
archiveFlag(
|
|
45
|
-
setFlagTargeting(
|
|
57
|
+
getFlag(projectId: string | undefined, flagIdOrKey: string): Promise<Flag>;
|
|
58
|
+
getFlagByKey(projectId: string | undefined, flagKey: string): Promise<Flag>;
|
|
59
|
+
createFlag(projectId: string | undefined, input: CreateFlagInput): Promise<Flag>;
|
|
60
|
+
updateFlag(projectId: string | undefined, flagIdOrKey: string, input: UpdateFlagInput): Promise<Flag>;
|
|
61
|
+
deleteFlag(projectId: string | undefined, flagIdOrKey: string): Promise<void>;
|
|
62
|
+
toggleFlag(projectId: string | undefined, flagIdOrKey: string, reason?: string): Promise<Flag>;
|
|
63
|
+
archiveFlag(projectId: string | undefined, flagIdOrKey: string, reason?: string): Promise<Flag>;
|
|
64
|
+
setFlagTargeting(projectId: string | undefined, flagIdOrKey: string, input: {
|
|
65
|
+
environment?: string;
|
|
66
|
+
enabled?: boolean;
|
|
46
67
|
rolloutPercentage?: number;
|
|
47
68
|
rules?: Array<{
|
|
48
69
|
attribute: string;
|
|
49
70
|
operator: string;
|
|
50
71
|
value: any;
|
|
51
72
|
}>;
|
|
73
|
+
individualTargets?: Array<{
|
|
74
|
+
attribute?: string;
|
|
75
|
+
key: string;
|
|
76
|
+
value: any;
|
|
77
|
+
}>;
|
|
52
78
|
useTargeting?: boolean;
|
|
79
|
+
reason?: string;
|
|
53
80
|
}): Promise<Flag>;
|
|
54
|
-
|
|
81
|
+
setFlagSchedule(projectId: string | undefined, flagIdOrKey: string, input: {
|
|
82
|
+
environment?: string;
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
startDate?: string | null;
|
|
85
|
+
endDate?: string | null;
|
|
86
|
+
timezone?: string;
|
|
87
|
+
paused?: boolean;
|
|
88
|
+
reason?: string;
|
|
89
|
+
}): Promise<Flag>;
|
|
90
|
+
duplicateFlag(projectId: string | undefined, flagIdOrKey: string, customValues?: {
|
|
55
91
|
key?: string;
|
|
56
92
|
name?: string;
|
|
57
93
|
description?: string;
|
|
58
94
|
}): Promise<Flag>;
|
|
59
|
-
bulkArchive(
|
|
95
|
+
bulkArchive(projectId: string | undefined, flagIds: string[]): Promise<{
|
|
60
96
|
archived: number;
|
|
61
97
|
}>;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
listSegments(projectId?: string): Promise<Segment[]>;
|
|
99
|
+
getSegment(key: string, projectId?: string): Promise<Segment>;
|
|
100
|
+
createSegment(input: SegmentInput, projectId?: string): Promise<Segment>;
|
|
101
|
+
updateSegment(key: string, input: Partial<SegmentInput>, projectId?: string): Promise<Segment>;
|
|
102
|
+
deleteSegment(key: string, projectId?: string): Promise<void>;
|
|
103
|
+
evaluateFlag(flagKey: string, context: EvaluationContext, environment?: string, projectId?: string): Promise<EvaluationResult>;
|
|
104
|
+
evaluateBatch(flagKeys: string[], context: EvaluationContext, environment?: string, projectId?: string): Promise<Record<string, EvaluationResult>>;
|
|
105
|
+
reportCodeReferences(request: CodeReferencesRequest, projectId?: string): Promise<CodeReferencesResponse>;
|
|
106
|
+
getFlagCodeReferences(flagKey: string, projectId?: string): Promise<{
|
|
107
|
+
references: FlagCodeReference[];
|
|
108
|
+
summary: FlagCodeRefsSummary;
|
|
109
|
+
}>;
|
|
110
|
+
listWebhooks(projectId?: string): Promise<any[]>;
|
|
111
|
+
createWebhook(projectId: string | undefined, input: {
|
|
66
112
|
name: string;
|
|
67
113
|
url: string;
|
|
68
114
|
events: string[];
|
|
69
115
|
}): Promise<any>;
|
|
70
|
-
deleteWebhook(
|
|
71
|
-
toggleWebhook(
|
|
72
|
-
getFlagMetrics(
|
|
73
|
-
getProjectMetrics(
|
|
116
|
+
deleteWebhook(projectId: string | undefined, webhookId: string): Promise<void>;
|
|
117
|
+
toggleWebhook(projectId: string | undefined, webhookId: string): Promise<any>;
|
|
118
|
+
getFlagMetrics(projectId: string | undefined, flagIdOrKey: string): Promise<any>;
|
|
119
|
+
getProjectMetrics(projectId?: string): Promise<any>;
|
|
120
|
+
getFlagHealth(projectId?: string): Promise<any>;
|
|
74
121
|
healthCheck(): Promise<boolean>;
|
|
75
122
|
}
|
|
76
123
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,cAAc,EACd,IAAI,EACJ,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,OAAO,EACP,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,I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