@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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const authStatusTool = {
|
|
2
|
+
name: "auth_status",
|
|
3
|
+
description: "š Check current authentication status and user information",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {},
|
|
7
|
+
additionalProperties: false,
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export async function handleAuthStatus(authManager) {
|
|
11
|
+
const isAuthenticated = await authManager.isAuthenticated();
|
|
12
|
+
if (isAuthenticated) {
|
|
13
|
+
const userInfo = authManager.getUserInfo();
|
|
14
|
+
const organizations = authManager.getOrganizations();
|
|
15
|
+
const selectedOrgId = authManager.getSelectedOrgId();
|
|
16
|
+
// Check if we need to save the session to persistence
|
|
17
|
+
const hasStoredSession = authManager.hasValidStoredSession();
|
|
18
|
+
let persistenceStatus = '';
|
|
19
|
+
// Auto-save functionality commented out for security
|
|
20
|
+
// if (!hasStoredSession && authManager.session) {
|
|
21
|
+
// // Session exists in memory but not saved to disk - save it now!
|
|
22
|
+
// try {
|
|
23
|
+
// console.error('š¾ Auth status detected unsaved session - saving now...');
|
|
24
|
+
// await authManager.saveCurrentSession();
|
|
25
|
+
// console.error('ā
Session saved successfully via auth_status');
|
|
26
|
+
// persistenceStatus = '\nš **Auto-saved session to persistent storage**';
|
|
27
|
+
// } catch (error) {
|
|
28
|
+
// console.error('ā Failed to save session via auth_status:', error);
|
|
29
|
+
// persistenceStatus = '\nā ļø **Failed to save session to storage**';
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
if (authManager.session) {
|
|
33
|
+
persistenceStatus = '\nā ļø **Session storage disabled - credentials not persisted**';
|
|
34
|
+
}
|
|
35
|
+
let orgInfo = '';
|
|
36
|
+
if (organizations.length > 0) {
|
|
37
|
+
const selectedOrg = organizations.find((org) => org.org_id === selectedOrgId);
|
|
38
|
+
const orgName = selectedOrg?.orgDetails?.name || selectedOrgId || 'Unknown';
|
|
39
|
+
orgInfo = `\n\nš¢ **Organization:** ${orgName}\nš **Org ID:** ${selectedOrgId}\nš **Available Orgs:** ${organizations.length}`;
|
|
40
|
+
// Add debug info
|
|
41
|
+
orgInfo += `\n\nš **Debug Info:**`;
|
|
42
|
+
orgInfo += `\n ⢠Selected Org ID: ${selectedOrgId || 'NULL'}`;
|
|
43
|
+
orgInfo += `\n ⢠Organizations Array: ${organizations.length} items`;
|
|
44
|
+
if (organizations.length > 0) {
|
|
45
|
+
orgInfo += `\n ⢠First Org: ${organizations[0]?.org_id || 'No org_id'} (${organizations[0]?.orgDetails?.name || 'No name'})`;
|
|
46
|
+
}
|
|
47
|
+
orgInfo += `\n ⢠Session Keys: ${authManager.session ? Object.keys(authManager.session).join(', ') : 'No session'}`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
orgInfo = '\n\nā ļø **Organization:** No organizations found';
|
|
51
|
+
orgInfo += `\nš **Debug:** Session exists: ${!!authManager.session}, Selected ID: ${selectedOrgId || 'NULL'}`;
|
|
52
|
+
}
|
|
53
|
+
// Add session persistence info
|
|
54
|
+
const storageLocation = authManager.getStorageLocation();
|
|
55
|
+
const finalStoredSession = authManager.hasValidStoredSession(); // Check again after potential save
|
|
56
|
+
orgInfo += `\n\nš¾ **Session Storage:**`;
|
|
57
|
+
orgInfo += `\n ⢠Location: ${storageLocation}`;
|
|
58
|
+
orgInfo += `\n ⢠Stored Session: ${finalStoredSession ? 'ā
Valid' : 'ā None/Expired'}`;
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
text: `ā
**Authenticated**\n\nš¤ **User:** ${userInfo.name || userInfo.email}\nš§ **Email:** ${userInfo.email}\nš **User ID:** ${userInfo.sub}\nā° **Session expires:** ${new Date(authManager.session?.expiresAt || 0).toLocaleString()}${orgInfo}${persistenceStatus}\n\nš ļø **Available:** All protected tools are now accessible`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
text: `ā **Not Authenticated**\n\nš Please run the 'login' tool to authenticate with PerfAI.\n\nā ļø **Restricted Access:** Only public tools (login, auth_status) are available until you authenticate.`,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthenticationManager } from "../../auth/authManager.js";
|
|
2
|
+
export declare const loginTool: {
|
|
3
|
+
readonly name: "login";
|
|
4
|
+
readonly description: "š Login to PerfAI using username/password from MCP config. Uses credentials from env variables.";
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {};
|
|
8
|
+
readonly additionalProperties: false;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function handleLogin(authManager: AuthenticationManager): Promise<any>;
|
|
12
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/tools/public/login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AA+FlE,eAAO,MAAM,SAAS;;;;;;;;CAQZ,CAAC;AAEX,wBAAsB,WAAW,CAAC,WAAW,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,CAsJlF"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { AUTH0_DOMAIN, CLIENT_ID } from "../../config.js";
|
|
4
|
+
// OAuth login tool commented out - replaced with username/password authentication
|
|
5
|
+
// export const loginTool = {
|
|
6
|
+
// name: "login",
|
|
7
|
+
// description: "š Login to PerfAI using Auth0 OAuth. Opens browser for authentication. Required before using any other tools.",
|
|
8
|
+
// inputSchema: {
|
|
9
|
+
// type: "object",
|
|
10
|
+
// properties: {},
|
|
11
|
+
// additionalProperties: false,
|
|
12
|
+
// },
|
|
13
|
+
// } as const;
|
|
14
|
+
// export async function handleLogin(authManager: AuthenticationManager): Promise<any> {
|
|
15
|
+
// console.error('š Login tool called');
|
|
16
|
+
//
|
|
17
|
+
// if (await authManager.isAuthenticated()) {
|
|
18
|
+
// const userInfo = authManager.getUserInfo();
|
|
19
|
+
// console.error('ā
User already authenticated:', userInfo.email);
|
|
20
|
+
// return {
|
|
21
|
+
// content: [
|
|
22
|
+
// {
|
|
23
|
+
// type: "text",
|
|
24
|
+
// text: `ā
Already authenticated as ${userInfo.email}\n\nIf you want to login as a different user, please logout first.`,
|
|
25
|
+
// },
|
|
26
|
+
// ],
|
|
27
|
+
// };
|
|
28
|
+
// }
|
|
29
|
+
// try {
|
|
30
|
+
// console.error('š Starting authentication process...');
|
|
31
|
+
// // Start auth server and open browser
|
|
32
|
+
// const authUrl = authManager.buildAuthUrl();
|
|
33
|
+
// console.error('š Generated auth URL:', authUrl);
|
|
34
|
+
// const authPromise = authManager.startAuthServer();
|
|
35
|
+
// console.error('š„ļø Auth server starting...');
|
|
36
|
+
// // Open browser for authentication
|
|
37
|
+
// await open(authUrl);
|
|
38
|
+
// console.error('š Browser opened for authentication');
|
|
39
|
+
// // Wait for authentication to complete (with timeout)
|
|
40
|
+
// console.error('ā³ Waiting for authentication to complete...');
|
|
41
|
+
// try {
|
|
42
|
+
// await authPromise;
|
|
43
|
+
// console.error('ā
Authentication completed successfully!');
|
|
44
|
+
// // Check if we're now authenticated
|
|
45
|
+
// const isNowAuthenticated = await authManager.isAuthenticated();
|
|
46
|
+
// console.error('š Post-auth authentication check:', isNowAuthenticated ? 'SUCCESS' : 'FAILED');
|
|
47
|
+
// if (isNowAuthenticated) {
|
|
48
|
+
// const userInfo = authManager.getUserInfo();
|
|
49
|
+
// console.error('š¤ Authenticated user:', userInfo.email);
|
|
50
|
+
// return {
|
|
51
|
+
// content: [
|
|
52
|
+
// {
|
|
53
|
+
// type: "text",
|
|
54
|
+
// text: `ā
**Authentication Successful!**\n\nš¤ **User:** ${userInfo.email}\nš§ **Email:** ${userInfo.email}\nš **User ID:** ${userInfo.sub}\nā° **Session expires:** ${new Date(authManager.session?.expiresAt || 0).toLocaleString()}\n\nš You are now authenticated and can use all protected tools!`,
|
|
55
|
+
// },
|
|
56
|
+
// ],
|
|
57
|
+
// };
|
|
58
|
+
// } else {
|
|
59
|
+
// console.error('ā Authentication completed but user not authenticated');
|
|
60
|
+
// return {
|
|
61
|
+
// content: [
|
|
62
|
+
// {
|
|
63
|
+
// type: "text",
|
|
64
|
+
// text: `ā ļø **Authentication Process Completed**\n\nā However, authentication verification failed.\n\nš **Troubleshooting:**\n1. Try running \`auth_status\` to check your authentication state\n2. If still not authenticated, try the login process again\n3. Check for any error messages in the server logs`,
|
|
65
|
+
// },
|
|
66
|
+
// ],
|
|
67
|
+
// };
|
|
68
|
+
// }
|
|
69
|
+
// } catch (authError) {
|
|
70
|
+
// console.error('ā Authentication process failed:', authError);
|
|
71
|
+
// return {
|
|
72
|
+
// content: [
|
|
73
|
+
// {
|
|
74
|
+
// type: "text",
|
|
75
|
+
// text: `ā **Authentication Failed**\n\nError: ${authError instanceof Error ? authError.message : String(authError)}\n\nš **Troubleshooting:**\n1. Make sure you completed the authentication in the browser\n2. Check if the browser was redirected to a success page\n3. Try the login process again`,
|
|
76
|
+
// },
|
|
77
|
+
// ],
|
|
78
|
+
// };
|
|
79
|
+
// }
|
|
80
|
+
// } catch (error) {
|
|
81
|
+
// console.error('ā Login tool error:', error);
|
|
82
|
+
// throw new McpError(ErrorCode.InternalError, `Authentication failed: ${error}`);
|
|
83
|
+
// }
|
|
84
|
+
// }
|
|
85
|
+
// New username/password authentication tool
|
|
86
|
+
export const loginTool = {
|
|
87
|
+
name: "login",
|
|
88
|
+
description: "š Login to PerfAI using username/password from MCP config. Uses credentials from env variables.",
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {},
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export async function handleLogin(authManager) {
|
|
96
|
+
console.error('š Username/Password login tool called');
|
|
97
|
+
if (await authManager.isAuthenticated()) {
|
|
98
|
+
const userInfo = authManager.getUserInfo();
|
|
99
|
+
console.error('ā
User already authenticated:', userInfo?.email || 'Unknown');
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
type: "text",
|
|
104
|
+
text: `ā
Already authenticated as ${userInfo?.email || 'Unknown User'}\n\nIf you want to login as a different user, please logout first.`,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
console.error('š Starting username/password authentication...');
|
|
111
|
+
// Get credentials from environment variables
|
|
112
|
+
const username = process.env.PERFAI_USERNAME;
|
|
113
|
+
const password = process.env.PERFAI_PASSWORD;
|
|
114
|
+
console.error('š Environment variables check:');
|
|
115
|
+
console.error(' - PERFAI_USERNAME:', username ? 'ā
Found' : 'ā Missing');
|
|
116
|
+
console.error(' - PERFAI_PASSWORD:', password ? 'ā
Found' : 'ā Missing');
|
|
117
|
+
if (!username || !password) {
|
|
118
|
+
console.error('ā Missing credentials in environment variables');
|
|
119
|
+
console.error('Available env vars:', Object.keys(process.env).filter(key => key.includes('PERFAI')));
|
|
120
|
+
return {
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: `ā **Authentication Failed**\n\nš§ **Configuration Required:**\n\nPlease add your PerfAI credentials to the MCP config:\n\n\`\`\`json\n{\n "mcpServers": {\n "perfai-mcp": {\n "command": "node",\n "args": ["path/to/dist/index.js"],\n "env": {\n "PERFAI_USERNAME": "your-username",\n "PERFAI_PASSWORD": "your-password"\n }\n }\n }\n}\n\`\`\`\n\nā ļø **Security Note:** Credentials are stored in the MCP config file.`,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
console.error('š Found credentials, attempting authentication...');
|
|
130
|
+
// Call Auth0 Resource Owner Password grant
|
|
131
|
+
const tokenUrl = `https://${AUTH0_DOMAIN}/oauth/token`;
|
|
132
|
+
const payload = {
|
|
133
|
+
grant_type: 'password',
|
|
134
|
+
username,
|
|
135
|
+
password,
|
|
136
|
+
client_id: CLIENT_ID,
|
|
137
|
+
scope: 'openid profile email',
|
|
138
|
+
};
|
|
139
|
+
console.error('š POST', tokenUrl);
|
|
140
|
+
console.error('š¦ Payload:', JSON.stringify({ ...payload, password: '***' }));
|
|
141
|
+
const response = await axios.post(tokenUrl, payload, {
|
|
142
|
+
headers: { 'Content-Type': 'application/json' }
|
|
143
|
+
});
|
|
144
|
+
console.error('ā
Authentication API response received');
|
|
145
|
+
if (response.data && response.data.id_token) {
|
|
146
|
+
console.error('š« ID Token received from PerfAI API');
|
|
147
|
+
// Parse the JWT token to extract user info
|
|
148
|
+
let userInfo = {
|
|
149
|
+
email: username,
|
|
150
|
+
name: username,
|
|
151
|
+
sub: `perfai-user-${username}`
|
|
152
|
+
};
|
|
153
|
+
try {
|
|
154
|
+
// Decode the JWT payload (basic decoding without verification for user info)
|
|
155
|
+
const tokenParts = response.data.id_token.split('.');
|
|
156
|
+
if (tokenParts.length === 3) {
|
|
157
|
+
const payload = JSON.parse(Buffer.from(tokenParts[1], 'base64').toString());
|
|
158
|
+
userInfo = {
|
|
159
|
+
email: payload.email || username,
|
|
160
|
+
name: payload.name || payload.nickname || username,
|
|
161
|
+
sub: payload.sub || `perfai-user-${username}`
|
|
162
|
+
};
|
|
163
|
+
console.error('š¤ Extracted user info from token:', userInfo.email);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (parseError) {
|
|
167
|
+
console.error('ā ļø Could not parse token payload, using fallback user info');
|
|
168
|
+
}
|
|
169
|
+
// Create a session object with the id_token
|
|
170
|
+
const session = {
|
|
171
|
+
accessToken: response.data.id_token,
|
|
172
|
+
idToken: response.data.id_token,
|
|
173
|
+
tokenType: 'Bearer', // Default token type for PerfAI API
|
|
174
|
+
userInfo: userInfo,
|
|
175
|
+
expiresAt: Date.now() + (24 * 60 * 60 * 1000), // 24 hours from now
|
|
176
|
+
organizations: [],
|
|
177
|
+
selectedOrgId: undefined
|
|
178
|
+
};
|
|
179
|
+
// Set session in memory
|
|
180
|
+
authManager.session = session;
|
|
181
|
+
console.error('ā
Session created in memory');
|
|
182
|
+
// Save session to persistent storage
|
|
183
|
+
try {
|
|
184
|
+
await authManager.saveCurrentSession();
|
|
185
|
+
console.error('ā
Session saved to persistent storage');
|
|
186
|
+
}
|
|
187
|
+
catch (saveError) {
|
|
188
|
+
console.error('ā ļø Failed to save session:', saveError);
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
content: [
|
|
192
|
+
{
|
|
193
|
+
type: "text",
|
|
194
|
+
text: `ā
**Authentication Successful!**\n\nš¤ **User:** ${userInfo.name}\nš§ **Email:** ${userInfo.email}\nš« **Token:** ${response.data.id_token.substring(0, 20)}...\nā° **Session expires:** ${new Date(session.expiresAt).toLocaleString()}\n\nš You are now authenticated and can use all protected tools!\n\nš¾ **Session persisted:** Your authentication will be remembered between tool calls.`,
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
console.error('ā Invalid response from authentication API');
|
|
201
|
+
console.error('Response data:', JSON.stringify(response.data, null, 2));
|
|
202
|
+
return {
|
|
203
|
+
content: [
|
|
204
|
+
{
|
|
205
|
+
type: "text",
|
|
206
|
+
text: `ā **Authentication Failed**\n\nInvalid response from PerfAI. Expected 'id_token' in response.\n\nResponse received: ${JSON.stringify(response.data, null, 2)}`,
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
console.error('ā Authentication error:', error);
|
|
214
|
+
if (axios.isAxiosError(error)) {
|
|
215
|
+
const status = error.response?.status;
|
|
216
|
+
const responseBody = JSON.stringify(error.response?.data, null, 2);
|
|
217
|
+
const message = error.response?.data?.message || error.response?.data?.error_description || error.message;
|
|
218
|
+
console.error('ā Auth0 error response:', status, responseBody);
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: "text",
|
|
223
|
+
text: `ā **Authentication Failed**\n\nStatus: ${status || 'Unknown'}\nError: ${message}\n\nFull response:\n\`\`\`json\n${responseBody}\n\`\`\``,
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
throw new McpError(ErrorCode.InternalError, `Authentication failed: ${error}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ApiCatalog {
|
|
2
|
+
_id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
api_name: string;
|
|
5
|
+
environment: string;
|
|
6
|
+
sensitive_data_id: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ApiSelection {
|
|
9
|
+
type: "label" | "name";
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface DockerRunOptions {
|
|
2
|
+
apiId: string;
|
|
3
|
+
orgId: string;
|
|
4
|
+
accessToken: string;
|
|
5
|
+
specUrl: string;
|
|
6
|
+
localBasePath: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VisionAiAppLearningRunOptions {
|
|
9
|
+
appId: string;
|
|
10
|
+
orgId: string;
|
|
11
|
+
accessToken: string;
|
|
12
|
+
appUrl: string;
|
|
13
|
+
userId?: string;
|
|
14
|
+
specUrl?: string;
|
|
15
|
+
chatId?: string;
|
|
16
|
+
modelConfig?: string;
|
|
17
|
+
accountEmail?: string;
|
|
18
|
+
accountPassword?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function runDockerSecurityTest(options: DockerRunOptions): Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
output: string;
|
|
23
|
+
errors: string;
|
|
24
|
+
exitCode: number | null;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function runDockerVisionAiAppLearning(options: VisionAiAppLearningRunOptions): Promise<{
|
|
27
|
+
success: boolean;
|
|
28
|
+
output: string;
|
|
29
|
+
errors: string;
|
|
30
|
+
exitCode: number | null;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function runDockerDesignTest(options: DockerRunOptions): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
output: string;
|
|
35
|
+
errors: string;
|
|
36
|
+
exitCode: number | null;
|
|
37
|
+
}>;
|
|
38
|
+
export declare function runDockerQualityTest(options: DockerRunOptions): Promise<{
|
|
39
|
+
success: boolean;
|
|
40
|
+
output: string;
|
|
41
|
+
errors: string;
|
|
42
|
+
exitCode: number | null;
|
|
43
|
+
}>;
|
|
44
|
+
//# sourceMappingURL=dockerRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dockerRunner.d.ts","sourceRoot":"","sources":["../../src/utils/dockerRunner.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC9E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC,CAmFD;AAED,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC;IAClG,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC,CA+FD;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC5E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC,CA4ED;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC,CAqFD"}
|