@perfai/mcp 1.0.24
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 +352 -0
- package/dist/auth/authManager.d.ts +83 -0
- package/dist/auth/authManager.d.ts.map +1 -0
- package/dist/auth/authManager.js +555 -0
- package/dist/auth/sessionCache.d.ts +5 -0
- package/dist/auth/sessionCache.d.ts.map +1 -0
- package/dist/auth/sessionCache.js +29 -0
- package/dist/auth/sessionStorage.d.ts +53 -0
- package/dist/auth/sessionStorage.d.ts.map +1 -0
- package/dist/auth/sessionStorage.js +234 -0
- package/dist/auth/types.d.ts +28 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/config.d.ts +65 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +74 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +144 -0
- package/dist/setup-config.d.ts +4 -0
- package/dist/setup-config.d.ts.map +1 -0
- package/dist/setup-config.js +69 -0
- package/dist/tools/index.d.ts +361 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +275 -0
- package/dist/tools/protected/aiFixDesignIssue.d.ts +17 -0
- package/dist/tools/protected/aiFixDesignIssue.d.ts.map +1 -0
- package/dist/tools/protected/aiFixDesignIssue.js +205 -0
- package/dist/tools/protected/aiFixQualityIssue.d.ts +17 -0
- package/dist/tools/protected/aiFixQualityIssue.d.ts.map +1 -0
- package/dist/tools/protected/aiFixQualityIssue.js +188 -0
- package/dist/tools/protected/aiFixSecurityIssue.d.ts +17 -0
- package/dist/tools/protected/aiFixSecurityIssue.d.ts.map +1 -0
- package/dist/tools/protected/aiFixSecurityIssue.js +205 -0
- package/dist/tools/protected/checkDesignFixes.d.ts +17 -0
- package/dist/tools/protected/checkDesignFixes.d.ts.map +1 -0
- package/dist/tools/protected/checkDesignFixes.js +199 -0
- package/dist/tools/protected/checkQualityFixes.d.ts +17 -0
- package/dist/tools/protected/checkQualityFixes.d.ts.map +1 -0
- package/dist/tools/protected/checkQualityFixes.js +199 -0
- package/dist/tools/protected/checkSecurityFixes.d.ts +17 -0
- package/dist/tools/protected/checkSecurityFixes.d.ts.map +1 -0
- package/dist/tools/protected/checkSecurityFixes.js +177 -0
- package/dist/tools/protected/listApis.d.ts +28 -0
- package/dist/tools/protected/listApis.d.ts.map +1 -0
- package/dist/tools/protected/listApis.js +102 -0
- package/dist/tools/protected/logout.d.ts +11 -0
- package/dist/tools/protected/logout.d.ts.map +1 -0
- package/dist/tools/protected/logout.js +22 -0
- package/dist/tools/protected/manageOrganizations.d.ts +26 -0
- package/dist/tools/protected/manageOrganizations.d.ts.map +1 -0
- package/dist/tools/protected/manageOrganizations.js +147 -0
- package/dist/tools/protected/runDesignTest.d.ts +21 -0
- package/dist/tools/protected/runDesignTest.d.ts.map +1 -0
- package/dist/tools/protected/runDesignTest.js +132 -0
- package/dist/tools/protected/runQualityTest.d.ts +21 -0
- package/dist/tools/protected/runQualityTest.d.ts.map +1 -0
- package/dist/tools/protected/runQualityTest.js +150 -0
- package/dist/tools/protected/runSecurityTest.d.ts +21 -0
- package/dist/tools/protected/runSecurityTest.d.ts.map +1 -0
- package/dist/tools/protected/runSecurityTest.js +107 -0
- package/dist/tools/protected/selectApi.d.ts +24 -0
- package/dist/tools/protected/selectApi.d.ts.map +1 -0
- package/dist/tools/protected/selectApi.js +172 -0
- package/dist/tools/protected/setup.d.ts +11 -0
- package/dist/tools/protected/setup.d.ts.map +1 -0
- package/dist/tools/protected/setup.js +151 -0
- package/dist/tools/protected/showDesignIssues.d.ts +38 -0
- package/dist/tools/protected/showDesignIssues.d.ts.map +1 -0
- package/dist/tools/protected/showDesignIssues.js +201 -0
- package/dist/tools/protected/showFixedIssues.d.ts +11 -0
- package/dist/tools/protected/showFixedIssues.d.ts.map +1 -0
- package/dist/tools/protected/showFixedIssues.js +36 -0
- package/dist/tools/protected/showQualityIssues.d.ts +33 -0
- package/dist/tools/protected/showQualityIssues.d.ts.map +1 -0
- package/dist/tools/protected/showQualityIssues.js +225 -0
- package/dist/tools/protected/showSecurityIssues.d.ts +47 -0
- package/dist/tools/protected/showSecurityIssues.d.ts.map +1 -0
- package/dist/tools/protected/showSecurityIssues.js +212 -0
- package/dist/tools/protected/summarizeIssues.d.ts +11 -0
- package/dist/tools/protected/summarizeIssues.d.ts.map +1 -0
- package/dist/tools/protected/summarizeIssues.js +161 -0
- package/dist/tools/protected/userInfo.d.ts +11 -0
- package/dist/tools/protected/userInfo.d.ts.map +1 -0
- package/dist/tools/protected/userInfo.js +21 -0
- package/dist/tools/protected/visionAiAppLearning.d.ts +37 -0
- package/dist/tools/protected/visionAiAppLearning.d.ts.map +1 -0
- package/dist/tools/protected/visionAiAppLearning.js +122 -0
- package/dist/tools/public/authStatus.d.ts +11 -0
- package/dist/tools/public/authStatus.d.ts.map +1 -0
- package/dist/tools/public/authStatus.js +78 -0
- package/dist/tools/public/login.d.ts +12 -0
- package/dist/tools/public/login.d.ts.map +1 -0
- package/dist/tools/public/login.js +230 -0
- package/dist/types/api.d.ts +12 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +1 -0
- package/dist/utils/dockerRunner.d.ts +44 -0
- package/dist/utils/dockerRunner.d.ts.map +1 -0
- package/dist/utils/dockerRunner.js +300 -0
- package/dist/utils/formatters.d.ts +14 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +510 -0
- package/dist/utils/promptBuilder.d.ts +4 -0
- package/dist/utils/promptBuilder.d.ts.map +1 -0
- package/dist/utils/promptBuilder.js +132 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PerfAI
|
|
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,352 @@
|
|
|
1
|
+
# PerfAI MCP Server
|
|
2
|
+
|
|
3
|
+
A specialized Model Context Protocol (MCP) server for **PerfAI Security Analysis** with Auth0 authentication.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation (from npm)
|
|
6
|
+
|
|
7
|
+
Install globally (CLI):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g perfai-mcp-server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or add as a project dependency:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install perfai-mcp-server --save-dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## ⚙️ Quick Setup
|
|
20
|
+
|
|
21
|
+
Generate MCP configuration files with placeholders:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
perfai-mcp-setup
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This creates `cursor_mcp_config.json` and `vscode_mcp_config.json` in your current directory with placeholder credentials that you can edit.
|
|
28
|
+
|
|
29
|
+
## 🚀 Run (CLI)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
perfai-mcp-server
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This starts the MCP server over stdio. Use with an MCP client (Cursor, VS Code, MCP Inspector).
|
|
36
|
+
|
|
37
|
+
### Required Environment Variables
|
|
38
|
+
|
|
39
|
+
You only need to provide your PerfAI credentials:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
set PERFAI_USERNAME=your-username
|
|
43
|
+
set PERFAI_PASSWORD=your-password
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Note:** Auth0 domain and client ID are pre-configured and don't need to be set.
|
|
47
|
+
|
|
48
|
+
### Kubernetes (K8s Secrets)
|
|
49
|
+
|
|
50
|
+
Store credentials in a Kubernetes `Secret` and inject them as environment variables (recommended for clusters).
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
apiVersion: v1
|
|
54
|
+
kind: Secret
|
|
55
|
+
metadata:
|
|
56
|
+
name: perfai-mcp-secrets
|
|
57
|
+
type: Opaque
|
|
58
|
+
stringData:
|
|
59
|
+
PERFAI_USERNAME: "<perfai-username>"
|
|
60
|
+
PERFAI_PASSWORD: "<perfai-password>"
|
|
61
|
+
# Optional (only if used in your deployment)
|
|
62
|
+
PERFAI_DASHBOARD_API_AUTH: "Authorization: Basic <base64(user:pass)>"
|
|
63
|
+
PERFAI_AUTH0_CLIENT_SECRET: "<auth0-client-secret>"
|
|
64
|
+
---
|
|
65
|
+
apiVersion: apps/v1
|
|
66
|
+
kind: Deployment
|
|
67
|
+
metadata:
|
|
68
|
+
name: perfai-mcp
|
|
69
|
+
spec:
|
|
70
|
+
template:
|
|
71
|
+
spec:
|
|
72
|
+
containers:
|
|
73
|
+
- name: perfai-mcp
|
|
74
|
+
envFrom:
|
|
75
|
+
- secretRef:
|
|
76
|
+
name: perfai-mcp-secrets
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 🧩 Programmatic Usage
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { startServer, authManager, AuthenticationManager } from '@perfai/mcp-server';
|
|
83
|
+
|
|
84
|
+
// Start server (returns a promise)
|
|
85
|
+
await startServer();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
All logging is written to stderr to remain MCP-compatible.
|
|
89
|
+
|
|
90
|
+
## 🔐 Authentication & Security
|
|
91
|
+
|
|
92
|
+
**🎯 Universal Device Code Authentication** - Works with ANY MCP client without configuration!
|
|
93
|
+
|
|
94
|
+
- **🔑 Auth0 Integration**: Seamless integration with `auth.perfai.ai`
|
|
95
|
+
- **🌐 Zero Configuration**: No redirect URLs needed - works everywhere
|
|
96
|
+
- **📱 Device Code Flow**: Simple browser authentication like Netflix/GitHub
|
|
97
|
+
- **🛡️ Session Management**: Secure token storage and automatic validation
|
|
98
|
+
- **🔄 Auto-Detection**: Server automatically detects authentication completion
|
|
99
|
+
- **👥 Multi-User Support**: Isolated sessions for different users
|
|
100
|
+
|
|
101
|
+
## 🛠️ Available Tools
|
|
102
|
+
|
|
103
|
+
### 🔓 **Public Tools** (No authentication required)
|
|
104
|
+
- **🔐 `login`**: Authenticate with PerfAI using OAuth2 Device Code flow
|
|
105
|
+
- **📊 `auth_status`**: Check current authentication status and user information
|
|
106
|
+
|
|
107
|
+
### 🔒 **Protected Tools** (Authentication required)
|
|
108
|
+
|
|
109
|
+
#### 👤 **User Management**
|
|
110
|
+
- **👤 `user_info`**: Get detailed authenticated user information
|
|
111
|
+
- **🚪 `logout`**: Clear authentication session and logout
|
|
112
|
+
|
|
113
|
+
#### 🏢 **Organization Management**
|
|
114
|
+
- **🏢 `manage_organizations`**: List, select, and refresh organizations
|
|
115
|
+
- Actions: `list`, `select`, `refresh`
|
|
116
|
+
- **📋 `list_apps`**: List all APPs in table format (Seq, App Name, Label) - shows unique instances
|
|
117
|
+
- **🎯 `select_app`**: Select an APP by sequence number from list_apps table
|
|
118
|
+
|
|
119
|
+
#### 🔒 **Security Analysis**
|
|
120
|
+
- **🔒 `show_security_issues`**: List security vulnerabilities by organization
|
|
121
|
+
- Shows 20 issues at a time with pagination
|
|
122
|
+
- Sorted by severity (Critical → High → Medium → Low)
|
|
123
|
+
- Displays CVSS scores for each issue
|
|
124
|
+
- Supports pagination, search, and severity filtering
|
|
125
|
+
- **🤖 `ai_fix_security_issue`**: Generate AI-powered remediation prompts
|
|
126
|
+
- Works with sequence numbers, issue IDs, or descriptive text
|
|
127
|
+
- **📋 `show_fixed_issues`**: View all AI-fixed security issues in current session
|
|
128
|
+
|
|
129
|
+
#### 🚀 **Security Testing**
|
|
130
|
+
- **🚀 `run_security_test`**: Execute comprehensive security analysis using Docker
|
|
131
|
+
- Requires OpenAPI spec URL and local API base path
|
|
132
|
+
- Uses PerfAI's Docker-based security testing engine
|
|
133
|
+
- Waits 40 seconds for system to process security issues
|
|
134
|
+
- **🔍 `check_security_fixes`**: Check which previously fixed security issues were actually resolved
|
|
135
|
+
- Independent tool that can be run anytime
|
|
136
|
+
- Shows comparison table of fixed vs still existing issues
|
|
137
|
+
- Clears fixed issues from session after comparison
|
|
138
|
+
|
|
139
|
+
## 🚀 Quick Start (Local Development)
|
|
140
|
+
|
|
141
|
+
### 1. Install Dependencies
|
|
142
|
+
```bash
|
|
143
|
+
npm install
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 2. Build the Project
|
|
147
|
+
```bash
|
|
148
|
+
npm run build
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 3. Start the Server (built output)
|
|
152
|
+
```bash
|
|
153
|
+
npm start
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or directly via ts-node (optional):
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx ts-node src/index.ts
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 4. Test with MCP Inspector (Optional)
|
|
163
|
+
```bash
|
|
164
|
+
npm run mcp:inspect
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 🔧 MCP Client Configuration
|
|
168
|
+
|
|
169
|
+
### For Cursor
|
|
170
|
+
Add to your `cursor_mcp_config.json`:
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"mcpServers": {
|
|
174
|
+
"perfai-mcp": {
|
|
175
|
+
"type": "stdio",
|
|
176
|
+
"command": "npx",
|
|
177
|
+
"args": ["perfai-mcp-server"],
|
|
178
|
+
"env": {
|
|
179
|
+
"PERFAI_USERNAME": "your-username",
|
|
180
|
+
"PERFAI_PASSWORD": "your-password"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### For VS Code
|
|
188
|
+
Add to your `vscode_mcp_config.json`:
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"mcpServers": {
|
|
192
|
+
"perfai-mcp": {
|
|
193
|
+
"type": "stdio",
|
|
194
|
+
"command": "npx",
|
|
195
|
+
"args": ["perfai-mcp-server"],
|
|
196
|
+
"env": {
|
|
197
|
+
"PERFAI_USERNAME": "your-username",
|
|
198
|
+
"PERFAI_PASSWORD": "your-password"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## 🧪 Authentication Flow
|
|
206
|
+
|
|
207
|
+
### Step-by-Step Authentication
|
|
208
|
+
|
|
209
|
+
1. **Check Initial Status**: Run `auth_status` → Shows "Not Authenticated"
|
|
210
|
+
2. **Login**: Run `login` tool:
|
|
211
|
+
- ✅ Browser automatically opens to PerfAI Auth0 device page
|
|
212
|
+
- 📱 You'll see a simple code (e.g., `BDJK-WHNZ`)
|
|
213
|
+
- 🔐 Enter the code in browser and complete authentication
|
|
214
|
+
- 🔄 Server automatically detects completion
|
|
215
|
+
3. **Verify**: Run `auth_status` → Shows user info and "Authenticated"
|
|
216
|
+
4. **Use Protected Tools**: All 9 protected tools now available
|
|
217
|
+
5. **Logout**: Run `logout` → Returns to 2 public tools only
|
|
218
|
+
|
|
219
|
+
### Security Features
|
|
220
|
+
- **🔒 Zero Configuration**: No Auth0 redirect URL setup required
|
|
221
|
+
- **🌐 Universal Compatibility**: Works with any MCP client
|
|
222
|
+
- **⏰ Auto-Expiry**: Tokens automatically expire for security
|
|
223
|
+
- **🔄 Session Isolation**: Each user session is completely isolated
|
|
224
|
+
|
|
225
|
+
## 📋 Tool Usage Examples
|
|
226
|
+
|
|
227
|
+
### Organization Management
|
|
228
|
+
```bash
|
|
229
|
+
# List available organizations
|
|
230
|
+
manage_organizations {"action": "list"}
|
|
231
|
+
|
|
232
|
+
# Select an organization
|
|
233
|
+
manage_organizations {"action": "select", "org_id": "your-org-id"}
|
|
234
|
+
|
|
235
|
+
# Refresh organization list
|
|
236
|
+
manage_organizations {"action": "refresh"}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Security Analysis
|
|
240
|
+
```bash
|
|
241
|
+
# List security issues
|
|
242
|
+
show_security_issues {"limit": 20}
|
|
243
|
+
|
|
244
|
+
# Search for specific app issues
|
|
245
|
+
show_security_issues {"search": "myapp", "limit": 10}
|
|
246
|
+
|
|
247
|
+
# Generate AI fix for an issue by sequence number
|
|
248
|
+
ai_fix_security_issue {"issue_id": "14"}
|
|
249
|
+
|
|
250
|
+
# Generate AI fix for an issue by ID
|
|
251
|
+
ai_fix_security_issue {"issue_id": "issue-id-here"}
|
|
252
|
+
|
|
253
|
+
# Generate AI fix for an issue by description
|
|
254
|
+
ai_fix_security_issue {"issue_id": "System Design Issues/Enumerable Resource ID • MULTIPLE /store"}
|
|
255
|
+
|
|
256
|
+
# Show all fixed issues
|
|
257
|
+
show_fixed_issues {}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### APP Management
|
|
261
|
+
```bash
|
|
262
|
+
# List available APPs (shows table with sequence numbers)
|
|
263
|
+
list_apps {}
|
|
264
|
+
|
|
265
|
+
# Select an APP by sequence number from list_apps table
|
|
266
|
+
select_app {"sequence": 1}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Security Testing
|
|
270
|
+
```bash
|
|
271
|
+
# Run comprehensive security test (waits 40 seconds for processing)
|
|
272
|
+
run_security_test {
|
|
273
|
+
"spec_url": "http://localhost:3000/swagger.json",
|
|
274
|
+
"local_base_path": "http://localhost:3000"
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
# Check which previously fixed issues were actually resolved
|
|
278
|
+
check_security_fixes {"wait_seconds": 15}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## 🏗️ Development
|
|
282
|
+
|
|
283
|
+
### Watch Mode
|
|
284
|
+
```bash
|
|
285
|
+
npm run dev
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Available Scripts
|
|
289
|
+
- `npm run build` – Compile TypeScript to JavaScript
|
|
290
|
+
- `npm run dev` – Watch mode for development
|
|
291
|
+
- `npm start` – Start the MCP server
|
|
292
|
+
- `npm run mcp:inspect` – Start MCP Inspector for testing
|
|
293
|
+
|
|
294
|
+
### Project Structure
|
|
295
|
+
```
|
|
296
|
+
├── src/
|
|
297
|
+
│ └── index.ts # Main MCP server implementation
|
|
298
|
+
├── dist/ # Compiled JavaScript output
|
|
299
|
+
├── package.json # Dependencies and scripts
|
|
300
|
+
├── tsconfig.json # TypeScript configuration
|
|
301
|
+
├── cursor_mcp_config.json # Cursor MCP client config
|
|
302
|
+
├── vscode_mcp_config.json # VS Code MCP client config
|
|
303
|
+
└── README.md # This file
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## 🔍 Troubleshooting
|
|
307
|
+
|
|
308
|
+
### Publishing (Maintainers)
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# Bump version (choose patch|minor|major)
|
|
312
|
+
npm version patch
|
|
313
|
+
|
|
314
|
+
# Publish (scoped public)
|
|
315
|
+
npm publish --access public
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
If you see 403 errors ensure: (1) You're logged in (`npm whoami`), (2) The `@perfai` scope exists and you have publish rights, (3) Version not already published.
|
|
319
|
+
|
|
320
|
+
### Common Issues
|
|
321
|
+
|
|
322
|
+
#### Authentication Problems
|
|
323
|
+
- **Browser doesn't open**: Manually visit the URL shown in the login response
|
|
324
|
+
- **Code expired**: Run `login` again to get a new device code
|
|
325
|
+
- **Stuck on authentication**: Check browser for any error messages
|
|
326
|
+
|
|
327
|
+
#### Organization Issues
|
|
328
|
+
- **No organizations found**: Run `manage_organizations {"action": "refresh"}`
|
|
329
|
+
- **Permission denied**: Ensure your PerfAI account has organization access
|
|
330
|
+
|
|
331
|
+
#### API Testing Issues
|
|
332
|
+
- **Docker errors**: Ensure Docker Desktop is running
|
|
333
|
+
- **Invalid URLs**: Verify your APP is accessible and spec URL is valid
|
|
334
|
+
- **Timeout**: Large APIs may take longer; check Docker logs
|
|
335
|
+
|
|
336
|
+
### Debug Mode
|
|
337
|
+
The server logs all activity to stderr, making debugging easier:
|
|
338
|
+
```bash
|
|
339
|
+
npm start 2> debug.log # Capture debug logs
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## 🌟 Features
|
|
343
|
+
|
|
344
|
+
- **🎯 PerfAI-Focused**: Built specifically for PerfAI security workflows
|
|
345
|
+
- **🔐 Secure Authentication**: OAuth2 Device Code flow with session management
|
|
346
|
+
- **📊 Comprehensive Analysis**: Full security issue management and AI-powered fixes
|
|
347
|
+
- **🐳 Docker Integration**: Containerized security testing engine
|
|
348
|
+
- **🔄 Real-time Updates**: Live tool list updates based on authentication state
|
|
349
|
+
- **📱 Universal Client Support**: Works with Cursor, VS Code, and any MCP client
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
**🚀 Ready to secure your APIs with PerfAI's MCP integration!**
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { UserSession, FixedIssue } from './types.js';
|
|
2
|
+
export declare class AuthenticationManager {
|
|
3
|
+
session: UserSession | null;
|
|
4
|
+
private codeVerifier;
|
|
5
|
+
private authServer;
|
|
6
|
+
private sessionStorage;
|
|
7
|
+
private isInitialized;
|
|
8
|
+
private initializationPromise;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Wait for session initialization to complete
|
|
12
|
+
*/
|
|
13
|
+
waitForInitialization(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize session from persistent storage
|
|
16
|
+
*/
|
|
17
|
+
private initializeSession;
|
|
18
|
+
/**
|
|
19
|
+
* Schedule automatic session saving when session data changes
|
|
20
|
+
*/
|
|
21
|
+
private scheduleSessionSave;
|
|
22
|
+
isAuthenticated(): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Synchronous version for backward compatibility
|
|
25
|
+
* Note: This will return false if initialization is still in progress
|
|
26
|
+
*/
|
|
27
|
+
isAuthenticatedSync(): boolean;
|
|
28
|
+
getUserInfo(): any;
|
|
29
|
+
getAccessToken(): string | null;
|
|
30
|
+
getTokenType(): string;
|
|
31
|
+
getSelectedOrgId(): string | null;
|
|
32
|
+
getOrganizations(): any[];
|
|
33
|
+
setSelectedOrgId(orgId: string): void;
|
|
34
|
+
getSelectedApiId(): string | null;
|
|
35
|
+
getSelectedApiData(): any | null;
|
|
36
|
+
getSelectedApiIdentifier(): any | null;
|
|
37
|
+
setSelectedApi(apiId: string, apiData: any, apiIdentifier: any): void;
|
|
38
|
+
getSelectedSecurityAppId(): string | null;
|
|
39
|
+
setSelectedSecurityAppId(securityAppId: string): void;
|
|
40
|
+
getSelectedDesignAppId(): string | null;
|
|
41
|
+
setSelectedDesignAppId(designAppId: string): void;
|
|
42
|
+
getSelectedQualityAppId(): string | null;
|
|
43
|
+
setSelectedQualityAppId(qualityAppId: string): void;
|
|
44
|
+
setAppSequenceMap(sequenceMap: Map<number, string>): void;
|
|
45
|
+
getAppSequenceMap(): Map<number, string> | null;
|
|
46
|
+
getAppIdBySequence(sequenceNumber: number): string | null;
|
|
47
|
+
clearAppSequenceMap(): void;
|
|
48
|
+
getFixedIssues(): FixedIssue[];
|
|
49
|
+
markIssueAsFixed(issueId: string, issue: any, prompt: string): FixedIssue;
|
|
50
|
+
isIssueFixed(issueId: string): boolean;
|
|
51
|
+
clearFixedIssues(): void;
|
|
52
|
+
getFixedDesignIssues(): FixedIssue[];
|
|
53
|
+
markDesignIssueAsFixed(issueId: string, issue: any, prompt: string): FixedIssue;
|
|
54
|
+
isDesignIssueFixed(issueId: string): boolean;
|
|
55
|
+
clearFixedDesignIssues(): void;
|
|
56
|
+
getFixedQualityIssues(): FixedIssue[];
|
|
57
|
+
addFixedQualityIssue(fixedIssue: FixedIssue): void;
|
|
58
|
+
markQualityIssueAsFixed(issueId: string, issue: any, prompt: string): FixedIssue;
|
|
59
|
+
isQualityIssueFixed(issueId: string): boolean;
|
|
60
|
+
clearFixedQualityIssues(): void;
|
|
61
|
+
clearSession(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Get session storage location for debugging
|
|
64
|
+
*/
|
|
65
|
+
getStorageLocation(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Check if there's a valid session in storage without loading it
|
|
68
|
+
*/
|
|
69
|
+
hasValidStoredSession(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Save current session to persistent storage
|
|
72
|
+
*/
|
|
73
|
+
saveCurrentSession(): Promise<void>;
|
|
74
|
+
generateCodeChallenge(): {
|
|
75
|
+
codeVerifier: string;
|
|
76
|
+
codeChallenge: string;
|
|
77
|
+
};
|
|
78
|
+
buildAuthUrl(): string;
|
|
79
|
+
manualCodeFlow(): Promise<string>;
|
|
80
|
+
startAuthServer(): Promise<string>;
|
|
81
|
+
exchangeCodeForTokens(code: string): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=authManager.d.ts.map
|
|
@@ -0,0 +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