@flagdeck/mcp-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +468 -0
- package/dist/client.d.ts +76 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +243 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +236 -0
- package/dist/server.js.map +1 -0
- package/dist/setup.d.ts +7 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +144 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/index.d.ts +28 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +428 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Flagdeck
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
# @flagdeck/mcp-server
|
|
2
|
+
|
|
3
|
+
**Model Context Protocol (MCP) server for Flagdeck** - enables AI agents like Claude, Cursor, and Windsurf to manage feature flags directly.
|
|
4
|
+
|
|
5
|
+
## What is This?
|
|
6
|
+
|
|
7
|
+
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
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @flagdeck/mcp-server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Configuration
|
|
23
|
+
|
|
24
|
+
Set up your environment variables:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
export FLAGDECK_API_KEY=your-api-key
|
|
28
|
+
export FLAGDECK_API_URL=https://api.flagdeck.com # optional, defaults to http://localhost:3008
|
|
29
|
+
export FLAGDECK_PROJECT_ID=your-project-id # optional, can be provided per-request
|
|
30
|
+
export FLAGDECK_ENVIRONMENT=production # optional, defaults to production
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Running the Server
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
flagdeck-mcp
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The server runs on stdio and communicates via the Model Context Protocol.
|
|
40
|
+
|
|
41
|
+
## Usage with AI Assistants
|
|
42
|
+
|
|
43
|
+
### Claude Desktop
|
|
44
|
+
|
|
45
|
+
Add to your `claude_desktop_config.json`:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"flagdeck": {
|
|
51
|
+
"command": "flagdeck-mcp",
|
|
52
|
+
"env": {
|
|
53
|
+
"FLAGDECK_API_KEY": "your-api-key",
|
|
54
|
+
"FLAGDECK_API_URL": "https://api.flagdeck.com",
|
|
55
|
+
"FLAGDECK_PROJECT_ID": "your-project-id"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then in Claude Desktop:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
You: "Create a dark mode feature flag"
|
|
66
|
+
Claude: *uses create_flag tool* Done! I've created the dark-mode flag.
|
|
67
|
+
|
|
68
|
+
You: "Roll it out to 25% of users"
|
|
69
|
+
Claude: *uses update_flag tool* Updated! Now rolling out to 25% of users.
|
|
70
|
+
|
|
71
|
+
You: "Check if it's enabled for user@example.com"
|
|
72
|
+
Claude: *uses evaluate_flag tool* Yes, it's enabled for that user.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Cursor IDE
|
|
76
|
+
|
|
77
|
+
Add to `.cursor/mcp.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"servers": {
|
|
82
|
+
"flagdeck": {
|
|
83
|
+
"command": "flagdeck-mcp",
|
|
84
|
+
"env": {
|
|
85
|
+
"FLAGDECK_API_KEY": "your-api-key"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Windsurf
|
|
93
|
+
|
|
94
|
+
Add to Windsurf MCP configuration:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"servers": {
|
|
99
|
+
"flagdeck": {
|
|
100
|
+
"command": "npx @flagdeck/mcp-server",
|
|
101
|
+
"env": {
|
|
102
|
+
"FLAGDECK_API_KEY": "your-api-key"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Available Tools
|
|
110
|
+
|
|
111
|
+
### Project & Environment Management
|
|
112
|
+
|
|
113
|
+
#### `list_projects`
|
|
114
|
+
List all projects accessible to your API key.
|
|
115
|
+
|
|
116
|
+
**Example:**
|
|
117
|
+
```
|
|
118
|
+
"Show me all my projects"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### `get_project`
|
|
122
|
+
Get details of a specific project.
|
|
123
|
+
|
|
124
|
+
**Parameters:**
|
|
125
|
+
- `projectId` (optional): Project ID
|
|
126
|
+
|
|
127
|
+
#### `list_environments`
|
|
128
|
+
List all environments in a project.
|
|
129
|
+
|
|
130
|
+
**Parameters:**
|
|
131
|
+
- `projectId` (optional): Project ID
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### Flag Management
|
|
136
|
+
|
|
137
|
+
#### `list_flags`
|
|
138
|
+
List all feature flags in a project.
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
- `projectId` (optional): Project ID
|
|
142
|
+
- `status` (optional): Filter by status (active/inactive/archived)
|
|
143
|
+
- `search` (optional): Search by name or key
|
|
144
|
+
|
|
145
|
+
**Example:**
|
|
146
|
+
```
|
|
147
|
+
"Show me all active flags"
|
|
148
|
+
"List flags containing 'checkout'"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### `get_flag`
|
|
152
|
+
Get details of a specific flag.
|
|
153
|
+
|
|
154
|
+
**Parameters:**
|
|
155
|
+
- `projectId` (optional): Project ID
|
|
156
|
+
- `flagId` OR `flagKey`: Flag identifier
|
|
157
|
+
|
|
158
|
+
**Example:**
|
|
159
|
+
```
|
|
160
|
+
"Show me the dark-mode flag"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### `create_flag`
|
|
164
|
+
Create a new feature flag.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
- `projectId` (optional): Project ID
|
|
168
|
+
- `key` (required): Unique flag key
|
|
169
|
+
- `name` (required): Human-readable name
|
|
170
|
+
- `description` (optional): Description
|
|
171
|
+
- `valueType` (required): boolean | string | number | json
|
|
172
|
+
- `defaultValue` (required): Default value
|
|
173
|
+
- `targetingRules` (optional): Array of targeting rules
|
|
174
|
+
- `rolloutPercentage` (optional): Rollout percentage (0-100)
|
|
175
|
+
|
|
176
|
+
**Example:**
|
|
177
|
+
```
|
|
178
|
+
"Create a flag called 'new-checkout' with 25% rollout"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### `update_flag`
|
|
182
|
+
Update an existing flag.
|
|
183
|
+
|
|
184
|
+
**Parameters:**
|
|
185
|
+
- `projectId` (optional): Project ID
|
|
186
|
+
- `flagId` (required): Flag ID
|
|
187
|
+
- `name`, `description`, `status`, `defaultValue`, `targetingRules`, `rolloutPercentage` (all optional)
|
|
188
|
+
|
|
189
|
+
**Example:**
|
|
190
|
+
```
|
|
191
|
+
"Increase new-checkout rollout to 50%"
|
|
192
|
+
"Disable the dark-mode flag"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### `delete_flag`
|
|
196
|
+
Permanently delete a flag.
|
|
197
|
+
|
|
198
|
+
**Parameters:**
|
|
199
|
+
- `projectId` (optional): Project ID
|
|
200
|
+
- `flagId` (required): Flag ID
|
|
201
|
+
|
|
202
|
+
#### `toggle_flag`
|
|
203
|
+
Toggle a flag between active and inactive.
|
|
204
|
+
|
|
205
|
+
**Parameters:**
|
|
206
|
+
- `projectId` (optional): Project ID
|
|
207
|
+
- `flagId` (required): Flag ID
|
|
208
|
+
|
|
209
|
+
#### `archive_flag`
|
|
210
|
+
Archive a flag (soft delete).
|
|
211
|
+
|
|
212
|
+
**Parameters:**
|
|
213
|
+
- `projectId` (optional): Project ID
|
|
214
|
+
- `flagId` (required): Flag ID
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### Flag Evaluation
|
|
219
|
+
|
|
220
|
+
#### `evaluate_flag`
|
|
221
|
+
Evaluate a flag for a specific user/context.
|
|
222
|
+
|
|
223
|
+
**Parameters:**
|
|
224
|
+
- `flagKey` (required): Flag key
|
|
225
|
+
- `context` (required): User context object
|
|
226
|
+
- `userId`, `email`, `plan`, `country`, etc.
|
|
227
|
+
- `environment` (optional): Environment name
|
|
228
|
+
|
|
229
|
+
**Example:**
|
|
230
|
+
```
|
|
231
|
+
"Check if dark-mode is enabled for user@example.com"
|
|
232
|
+
"Evaluate new-checkout for a user with plan=premium"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### `evaluate_batch`
|
|
236
|
+
Evaluate multiple flags at once.
|
|
237
|
+
|
|
238
|
+
**Parameters:**
|
|
239
|
+
- `flagKeys` (required): Array of flag keys
|
|
240
|
+
- `context` (required): User context
|
|
241
|
+
- `environment` (optional): Environment name
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
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
|
+
## Examples
|
|
280
|
+
|
|
281
|
+
### Example 1: Create and Configure a Flag
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
User: "Create a feature flag for beta users"
|
|
285
|
+
|
|
286
|
+
AI: I'll create a beta feature flag for you.
|
|
287
|
+
*uses create_flag_natural_language tool*
|
|
288
|
+
|
|
289
|
+
Result: Created flag 'beta-features' with targeting rule for users with plan=beta
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Example 2: Gradual Rollout
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
User: "Create a new-ui flag and roll it out slowly"
|
|
296
|
+
|
|
297
|
+
AI: I'll create a new UI flag with a gradual rollout.
|
|
298
|
+
*uses create_flag tool with rolloutPercentage: 10*
|
|
299
|
+
|
|
300
|
+
User: "Increase it to 25%"
|
|
301
|
+
|
|
302
|
+
AI: I'll increase the rollout.
|
|
303
|
+
*uses update_flag tool*
|
|
304
|
+
|
|
305
|
+
Result: Rollout increased to 25%
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Example 3: Conditional Feature Access
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
User: "Create a premium-analytics flag only for enterprise users"
|
|
312
|
+
|
|
313
|
+
AI: I'll create that with enterprise targeting.
|
|
314
|
+
*uses create_flag_natural_language tool*
|
|
315
|
+
|
|
316
|
+
Result: Created flag with targeting rule: plan equals 'enterprise'
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Example 4: Evaluate Flags
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
User: "Check if premium-analytics is enabled for user@company.com with plan enterprise"
|
|
323
|
+
|
|
324
|
+
AI: I'll evaluate that for you.
|
|
325
|
+
*uses evaluate_flag tool*
|
|
326
|
+
|
|
327
|
+
Result: {
|
|
328
|
+
flagKey: "premium-analytics",
|
|
329
|
+
value: true,
|
|
330
|
+
reason: "Matched targeting rule: plan equals enterprise"
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Advanced Usage
|
|
337
|
+
|
|
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
|
+
### Per-Request Project ID
|
|
347
|
+
|
|
348
|
+
If you manage multiple projects, omit `FLAGDECK_PROJECT_ID` and provide it per-request:
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
"List flags in project proj-123"
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
The AI will include `projectId: "proj-123"` in the tool arguments.
|
|
355
|
+
|
|
356
|
+
### Environment-Specific Operations
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
"Evaluate dark-mode for user@example.com in staging environment"
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Development
|
|
365
|
+
|
|
366
|
+
### Building from Source
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
git clone https://github.com/flagdeck/flagdeck.git
|
|
370
|
+
cd packages/@flagdeck/mcp-server
|
|
371
|
+
npm install
|
|
372
|
+
npm run build
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Running Locally
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
npm run dev
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Testing
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
npm test
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## API Reference
|
|
390
|
+
|
|
391
|
+
### Configuration
|
|
392
|
+
|
|
393
|
+
| Environment Variable | Required | Default | Description |
|
|
394
|
+
|---------------------|----------|---------|-------------|
|
|
395
|
+
| `FLAGDECK_API_KEY` | Yes | - | Your Flagdeck API key |
|
|
396
|
+
| `FLAGDECK_API_URL` | No | `http://localhost:3008` | Flagdeck API URL |
|
|
397
|
+
| `FLAGDECK_PROJECT_ID` | No | - | Default project ID |
|
|
398
|
+
| `FLAGDECK_ENVIRONMENT` | No | `production` | Default environment |
|
|
399
|
+
|
|
400
|
+
### Tool Summary
|
|
401
|
+
|
|
402
|
+
| Tool | Purpose | Required Params |
|
|
403
|
+
|------|---------|-----------------|
|
|
404
|
+
| `list_projects` | List all projects | - |
|
|
405
|
+
| `get_project` | Get project details | - |
|
|
406
|
+
| `list_environments` | List environments | - |
|
|
407
|
+
| `list_flags` | List flags | - |
|
|
408
|
+
| `get_flag` | Get flag details | `flagId` or `flagKey` |
|
|
409
|
+
| `create_flag` | Create new flag | `key`, `name`, `valueType`, `defaultValue` |
|
|
410
|
+
| `update_flag` | Update flag | `flagId` |
|
|
411
|
+
| `delete_flag` | Delete flag | `flagId` |
|
|
412
|
+
| `toggle_flag` | Toggle flag status | `flagId` |
|
|
413
|
+
| `archive_flag` | Archive flag | `flagId` |
|
|
414
|
+
| `evaluate_flag` | Evaluate single flag | `flagKey`, `context` |
|
|
415
|
+
| `evaluate_batch` | Evaluate multiple flags | `flagKeys`, `context` |
|
|
416
|
+
| `create_flag_natural_language` | AI-powered flag creation | `input` |
|
|
417
|
+
| `update_flag_natural_language` | AI-powered flag update | `input` |
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## Troubleshooting
|
|
422
|
+
|
|
423
|
+
### "FLAGDECK_API_KEY is required"
|
|
424
|
+
|
|
425
|
+
Set your API key:
|
|
426
|
+
```bash
|
|
427
|
+
export FLAGDECK_API_KEY=your-key-here
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### "projectId is required"
|
|
431
|
+
|
|
432
|
+
Either set `FLAGDECK_PROJECT_ID` or provide it in each request.
|
|
433
|
+
|
|
434
|
+
### Connection Errors
|
|
435
|
+
|
|
436
|
+
Check that `FLAGDECK_API_URL` is correct and the API is reachable:
|
|
437
|
+
```bash
|
|
438
|
+
curl $FLAGDECK_API_URL/health
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Tool Not Found
|
|
442
|
+
|
|
443
|
+
Make sure you're using a compatible MCP client (Claude Desktop, Cursor, etc.) and the server is properly configured.
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Contributing
|
|
448
|
+
|
|
449
|
+
We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md).
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## License
|
|
454
|
+
|
|
455
|
+
MIT
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## Links
|
|
460
|
+
|
|
461
|
+
- [Flagdeck Documentation](https://docs.flagdeck.com)
|
|
462
|
+
- [MCP Specification](https://modelcontextprotocol.io)
|
|
463
|
+
- [GitHub Issues](https://github.com/flagdeck/flagdeck/issues)
|
|
464
|
+
- [NPM Package](https://www.npmjs.com/package/@flagdeck/mcp-server)
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
**Built with ❤️ by the Flagdeck team**
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flagdeck API Client
|
|
3
|
+
* Handles communication with the Flagdeck API
|
|
4
|
+
*/
|
|
5
|
+
import { FlagdeckConfig, Flag, CreateFlagInput, UpdateFlagInput, EvaluationContext, EvaluationResult, Project, Environment } from './types.js';
|
|
6
|
+
export interface ApiKeyContext {
|
|
7
|
+
projectId: string;
|
|
8
|
+
projectKey: string;
|
|
9
|
+
projectName: string;
|
|
10
|
+
projectSlug: string;
|
|
11
|
+
organizationId: string;
|
|
12
|
+
environmentId?: string;
|
|
13
|
+
environmentKey?: string;
|
|
14
|
+
environmentName?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class FlagdeckClient {
|
|
17
|
+
private config;
|
|
18
|
+
private baseHeaders;
|
|
19
|
+
private resolvedProjectId;
|
|
20
|
+
private resolvedContext;
|
|
21
|
+
constructor(config: FlagdeckConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Resolve project context from the API key at startup.
|
|
24
|
+
* Fetches /sdk/v1/context and caches the projectId for all subsequent calls.
|
|
25
|
+
*/
|
|
26
|
+
initialize(): Promise<ApiKeyContext>;
|
|
27
|
+
getResolvedProjectId(): string | undefined;
|
|
28
|
+
getContext(): ApiKeyContext | undefined;
|
|
29
|
+
private request;
|
|
30
|
+
listProjects(): Promise<Project[]>;
|
|
31
|
+
getProject(_projectId: string): Promise<Project>;
|
|
32
|
+
listEnvironments(_projectId: string): Promise<Environment[]>;
|
|
33
|
+
getEnvironment(_projectId: string, _environmentKey: string): Promise<Environment>;
|
|
34
|
+
listFlags(_projectId: string, params?: {
|
|
35
|
+
status?: string;
|
|
36
|
+
search?: string;
|
|
37
|
+
}): Promise<Flag[]>;
|
|
38
|
+
getFlag(_projectId: string, flagId: string): Promise<Flag>;
|
|
39
|
+
getFlagByKey(_projectId: string, flagKey: string): Promise<Flag>;
|
|
40
|
+
createFlag(_projectId: string, input: CreateFlagInput): Promise<Flag>;
|
|
41
|
+
updateFlag(_projectId: string, flagId: string, input: UpdateFlagInput): Promise<Flag>;
|
|
42
|
+
deleteFlag(_projectId: string, flagId: string): Promise<void>;
|
|
43
|
+
toggleFlag(_projectId: string, flagId: string): Promise<Flag>;
|
|
44
|
+
archiveFlag(_projectId: string, flagId: string): Promise<Flag>;
|
|
45
|
+
setFlagTargeting(_projectId: string, flagId: string, input: {
|
|
46
|
+
rolloutPercentage?: number;
|
|
47
|
+
rules?: Array<{
|
|
48
|
+
attribute: string;
|
|
49
|
+
operator: string;
|
|
50
|
+
value: any;
|
|
51
|
+
}>;
|
|
52
|
+
useTargeting?: boolean;
|
|
53
|
+
}): Promise<Flag>;
|
|
54
|
+
duplicateFlag(_projectId: string, flagId: string, customValues?: {
|
|
55
|
+
key?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
}): Promise<Flag>;
|
|
59
|
+
bulkArchive(_projectId: string, flagIds: string[]): Promise<{
|
|
60
|
+
archived: number;
|
|
61
|
+
}>;
|
|
62
|
+
evaluateFlag(flagKey: string, context: EvaluationContext, environment?: string): Promise<EvaluationResult>;
|
|
63
|
+
evaluateBatch(flagKeys: string[], context: EvaluationContext, environment?: string): Promise<Record<string, EvaluationResult>>;
|
|
64
|
+
listWebhooks(_projectId: string): Promise<any[]>;
|
|
65
|
+
createWebhook(_projectId: string, input: {
|
|
66
|
+
name: string;
|
|
67
|
+
url: string;
|
|
68
|
+
events: string[];
|
|
69
|
+
}): Promise<any>;
|
|
70
|
+
deleteWebhook(_projectId: string, webhookId: string): Promise<void>;
|
|
71
|
+
toggleWebhook(_projectId: string, webhookId: string): Promise<any>;
|
|
72
|
+
getFlagMetrics(_projectId: string, flagId: string): Promise<any>;
|
|
73
|
+
getProjectMetrics(_projectId: string): Promise<any>;
|
|
74
|
+
healthCheck(): Promise<boolean>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH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