@debugg-ai/debugg-ai-mcp 1.0.63 → 1.0.64

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.
Files changed (46) hide show
  1. package/dist/config/index.js +4 -1
  2. package/dist/handlers/createEnvironmentHandler.js +33 -0
  3. package/dist/handlers/createProjectHandler.js +62 -10
  4. package/dist/handlers/index.js +4 -14
  5. package/dist/handlers/searchEnvironmentsHandler.js +122 -0
  6. package/dist/handlers/searchExecutionsHandler.js +71 -0
  7. package/dist/handlers/searchProjectsHandler.js +72 -0
  8. package/dist/handlers/testPageChangesHandler.js +46 -5
  9. package/dist/handlers/triggerCrawlHandler.js +37 -7
  10. package/dist/handlers/updateEnvironmentHandler.js +94 -15
  11. package/dist/index.js +15 -2
  12. package/dist/tools/createEnvironment.js +5 -1
  13. package/dist/tools/index.js +9 -42
  14. package/dist/tools/searchEnvironments.js +35 -0
  15. package/dist/tools/searchExecutions.js +31 -0
  16. package/dist/tools/searchProjects.js +30 -0
  17. package/dist/types/index.js +52 -71
  18. package/package.json +4 -1
  19. package/dist/handlers/cancelExecutionHandler.js +0 -41
  20. package/dist/handlers/createCredentialHandler.js +0 -60
  21. package/dist/handlers/deleteCredentialHandler.js +0 -51
  22. package/dist/handlers/getCredentialHandler.js +0 -49
  23. package/dist/handlers/getEnvironmentHandler.js +0 -49
  24. package/dist/handlers/getExecutionHandler.js +0 -37
  25. package/dist/handlers/getProjectHandler.js +0 -37
  26. package/dist/handlers/listCredentialsHandler.js +0 -93
  27. package/dist/handlers/listEnvironmentsHandler.js +0 -63
  28. package/dist/handlers/listExecutionsHandler.js +0 -35
  29. package/dist/handlers/listProjectsHandler.js +0 -32
  30. package/dist/handlers/listReposHandler.js +0 -27
  31. package/dist/handlers/listTeamsHandler.js +0 -27
  32. package/dist/handlers/updateCredentialHandler.js +0 -70
  33. package/dist/tools/cancelExecution.js +0 -22
  34. package/dist/tools/createCredential.js +0 -52
  35. package/dist/tools/deleteCredential.js +0 -24
  36. package/dist/tools/getCredential.js +0 -24
  37. package/dist/tools/getEnvironment.js +0 -23
  38. package/dist/tools/getExecution.js +0 -22
  39. package/dist/tools/getProject.js +0 -22
  40. package/dist/tools/listCredentials.js +0 -30
  41. package/dist/tools/listEnvironments.js +0 -28
  42. package/dist/tools/listExecutions.js +0 -24
  43. package/dist/tools/listProjects.js +0 -27
  44. package/dist/tools/listRepos.js +0 -23
  45. package/dist/tools/listTeams.js +0 -23
  46. package/dist/tools/updateCredential.js +0 -28
@@ -1,51 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { detectRepoName } from '../utils/gitContext.js';
6
- const logger = new Logger({ module: 'deleteCredentialHandler' });
7
- function notFound(uuid, context) {
8
- return {
9
- content: [{ type: 'text', text: JSON.stringify({
10
- error: 'NotFound',
11
- message: `Credential ${uuid} not found (${context}).`,
12
- uuid,
13
- }, null, 2) }],
14
- isError: true,
15
- };
16
- }
17
- export async function deleteCredentialHandler(input, _context) {
18
- const start = Date.now();
19
- logger.toolStart('delete_credential', { uuid: input.uuid, environmentId: input.environmentId });
20
- try {
21
- const client = new DebuggAIServerClient(config.api.key);
22
- await client.init();
23
- let projectUuid = input.projectUuid;
24
- if (!projectUuid) {
25
- const repoName = detectRepoName();
26
- if (!repoName)
27
- return notFound(input.uuid, 'no git repo and no projectUuid');
28
- const project = await client.findProjectByRepoName(repoName);
29
- if (!project)
30
- return notFound(input.uuid, `no project for repo "${repoName}"`);
31
- projectUuid = project.uuid;
32
- }
33
- try {
34
- await client.deleteCredential(projectUuid, input.environmentId, input.uuid);
35
- logger.toolComplete('delete_credential', Date.now() - start);
36
- return {
37
- content: [{ type: 'text', text: JSON.stringify({ deleted: true, uuid: input.uuid }, null, 2) }],
38
- };
39
- }
40
- catch (err) {
41
- if (err?.statusCode === 404 || err?.response?.status === 404) {
42
- return notFound(input.uuid, `backend 404 for env ${input.environmentId}`);
43
- }
44
- throw err;
45
- }
46
- }
47
- catch (error) {
48
- logger.toolError('delete_credential', error, Date.now() - start);
49
- throw handleExternalServiceError(error, 'DebuggAI', 'delete_credential');
50
- }
51
- }
@@ -1,49 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { detectRepoName } from '../utils/gitContext.js';
6
- const logger = new Logger({ module: 'getCredentialHandler' });
7
- function notFound(uuid, context) {
8
- return {
9
- content: [{ type: 'text', text: JSON.stringify({
10
- error: 'NotFound',
11
- message: `Credential ${uuid} not found (${context}).`,
12
- uuid,
13
- }, null, 2) }],
14
- isError: true,
15
- };
16
- }
17
- export async function getCredentialHandler(input, _context) {
18
- const start = Date.now();
19
- logger.toolStart('get_credential', { uuid: input.uuid, environmentId: input.environmentId, projectUuid: input.projectUuid });
20
- try {
21
- const client = new DebuggAIServerClient(config.api.key);
22
- await client.init();
23
- let projectUuid = input.projectUuid;
24
- if (!projectUuid) {
25
- const repoName = detectRepoName();
26
- if (!repoName)
27
- return notFound(input.uuid, 'no git repo and no projectUuid');
28
- const project = await client.findProjectByRepoName(repoName);
29
- if (!project)
30
- return notFound(input.uuid, `no project for repo "${repoName}"`);
31
- projectUuid = project.uuid;
32
- }
33
- try {
34
- const credential = await client.getCredential(projectUuid, input.environmentId, input.uuid);
35
- logger.toolComplete('get_credential', Date.now() - start);
36
- return { content: [{ type: 'text', text: JSON.stringify({ credential }, null, 2) }] };
37
- }
38
- catch (err) {
39
- if (err?.statusCode === 404 || err?.response?.status === 404) {
40
- return notFound(input.uuid, `backend 404 for env ${input.environmentId}`);
41
- }
42
- throw err;
43
- }
44
- }
45
- catch (error) {
46
- logger.toolError('get_credential', error, Date.now() - start);
47
- throw handleExternalServiceError(error, 'DebuggAI', 'get_credential');
48
- }
49
- }
@@ -1,49 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { detectRepoName } from '../utils/gitContext.js';
6
- const logger = new Logger({ module: 'getEnvironmentHandler' });
7
- function notFound(uuid, context) {
8
- return {
9
- content: [{ type: 'text', text: JSON.stringify({
10
- error: 'NotFound',
11
- message: `Environment ${uuid} not found (${context}).`,
12
- uuid,
13
- }, null, 2) }],
14
- isError: true,
15
- };
16
- }
17
- export async function getEnvironmentHandler(input, _context) {
18
- const start = Date.now();
19
- logger.toolStart('get_environment', { uuid: input.uuid, projectUuid: input.projectUuid });
20
- try {
21
- const client = new DebuggAIServerClient(config.api.key);
22
- await client.init();
23
- let projectUuid = input.projectUuid;
24
- if (!projectUuid) {
25
- const repoName = detectRepoName();
26
- if (!repoName)
27
- return notFound(input.uuid, 'no git repo detected and no projectUuid provided');
28
- const project = await client.findProjectByRepoName(repoName);
29
- if (!project)
30
- return notFound(input.uuid, `no project found for repo "${repoName}"`);
31
- projectUuid = project.uuid;
32
- }
33
- try {
34
- const environment = await client.getEnvironment(projectUuid, input.uuid);
35
- logger.toolComplete('get_environment', Date.now() - start);
36
- return { content: [{ type: 'text', text: JSON.stringify({ environment }, null, 2) }] };
37
- }
38
- catch (err) {
39
- if (err?.statusCode === 404 || err?.response?.status === 404) {
40
- return notFound(input.uuid, `backend returned 404 for project ${projectUuid}`);
41
- }
42
- throw err;
43
- }
44
- }
45
- catch (error) {
46
- logger.toolError('get_environment', error, Date.now() - start);
47
- throw handleExternalServiceError(error, 'DebuggAI', 'get_environment');
48
- }
49
- }
@@ -1,37 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- const logger = new Logger({ module: 'getExecutionHandler' });
6
- function notFound(uuid) {
7
- return {
8
- content: [{ type: 'text', text: JSON.stringify({
9
- error: 'NotFound',
10
- message: `Execution ${uuid} not found.`,
11
- uuid,
12
- }, null, 2) }],
13
- isError: true,
14
- };
15
- }
16
- export async function getExecutionHandler(input, _context) {
17
- const start = Date.now();
18
- logger.toolStart('get_execution', { uuid: input.uuid });
19
- try {
20
- const client = new DebuggAIServerClient(config.api.key);
21
- await client.init();
22
- try {
23
- const execution = await client.workflows.getExecution(input.uuid);
24
- logger.toolComplete('get_execution', Date.now() - start);
25
- return { content: [{ type: 'text', text: JSON.stringify({ execution }, null, 2) }] };
26
- }
27
- catch (err) {
28
- if (err?.statusCode === 404 || err?.response?.status === 404)
29
- return notFound(input.uuid);
30
- throw err;
31
- }
32
- }
33
- catch (error) {
34
- logger.toolError('get_execution', error, Date.now() - start);
35
- throw handleExternalServiceError(error, 'DebuggAI', 'get_execution');
36
- }
37
- }
@@ -1,37 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- const logger = new Logger({ module: 'getProjectHandler' });
6
- function notFound(uuid) {
7
- return {
8
- content: [{ type: 'text', text: JSON.stringify({
9
- error: 'NotFound',
10
- message: `Project ${uuid} not found.`,
11
- uuid,
12
- }, null, 2) }],
13
- isError: true,
14
- };
15
- }
16
- export async function getProjectHandler(input, _context) {
17
- const start = Date.now();
18
- logger.toolStart('get_project', { uuid: input.uuid });
19
- try {
20
- const client = new DebuggAIServerClient(config.api.key);
21
- await client.init();
22
- try {
23
- const project = await client.getProject(input.uuid);
24
- logger.toolComplete('get_project', Date.now() - start);
25
- return { content: [{ type: 'text', text: JSON.stringify({ project }, null, 2) }] };
26
- }
27
- catch (err) {
28
- if (err?.statusCode === 404 || err?.response?.status === 404)
29
- return notFound(input.uuid);
30
- throw err;
31
- }
32
- }
33
- catch (error) {
34
- logger.toolError('get_project', error, Date.now() - start);
35
- throw handleExternalServiceError(error, 'DebuggAI', 'get_project');
36
- }
37
- }
@@ -1,93 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { detectRepoName } from '../utils/gitContext.js';
6
- import { toPaginationParams, makePageInfo } from '../utils/pagination.js';
7
- const logger = new Logger({ module: 'listCredentialsHandler' });
8
- export async function listCredentialsHandler(input, _context) {
9
- const start = Date.now();
10
- const pagination = toPaginationParams({ page: input.page, pageSize: input.pageSize });
11
- logger.toolStart('list_credentials', {
12
- environmentId: input.environmentId,
13
- projectUuid: input.projectUuid,
14
- q: input.q,
15
- role: input.role,
16
- ...pagination,
17
- });
18
- try {
19
- const client = new DebuggAIServerClient(config.api.key);
20
- await client.init();
21
- let projectUuid = input.projectUuid;
22
- if (!projectUuid) {
23
- const repoName = detectRepoName();
24
- if (!repoName) {
25
- const payload = {
26
- error: 'NoProjectResolved',
27
- message: 'No git repo detected and no projectUuid provided. Pass projectUuid (get it from list_projects) or invoke from a directory with a git origin.',
28
- pageInfo: makePageInfo(pagination.page, pagination.pageSize, 0, null),
29
- credentials: [],
30
- };
31
- logger.toolComplete('list_credentials', Date.now() - start);
32
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
33
- }
34
- const project = await client.findProjectByRepoName(repoName);
35
- if (!project) {
36
- const payload = {
37
- error: 'NoProjectResolved',
38
- message: `No DebuggAI project found for repo "${repoName}". Pass projectUuid explicitly.`,
39
- pageInfo: makePageInfo(pagination.page, pagination.pageSize, 0, null),
40
- credentials: [],
41
- };
42
- logger.toolComplete('list_credentials', Date.now() - start);
43
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
44
- }
45
- projectUuid = project.uuid;
46
- }
47
- let pageInfo;
48
- let credentials = [];
49
- if (input.environmentId) {
50
- // Paginated path — scoped to a single env.
51
- const result = await client.listCredentialsPaginated(projectUuid, input.environmentId, pagination, input.q, input.role);
52
- pageInfo = result.pageInfo;
53
- credentials = result.credentials;
54
- }
55
- else {
56
- // No env filter — iterate all envs and merge. Synthesize pageInfo from the full
57
- // result (client-side paginate the merged list for consistent shape).
58
- const envs = await client.listEnvironmentsForProject(projectUuid);
59
- const all = [];
60
- for (const env of envs) {
61
- const credsForEnv = await client.listCredentialsForEnvironment(projectUuid, env.uuid, input.q, input.role);
62
- all.push(...credsForEnv);
63
- }
64
- const offset = (pagination.page - 1) * pagination.pageSize;
65
- credentials = all.slice(offset, offset + pagination.pageSize);
66
- const totalCount = all.length;
67
- const totalPages = totalCount === 0 ? 0 : Math.ceil(totalCount / pagination.pageSize);
68
- pageInfo = {
69
- page: pagination.page,
70
- pageSize: pagination.pageSize,
71
- totalCount,
72
- totalPages,
73
- hasMore: offset + credentials.length < totalCount,
74
- };
75
- }
76
- const payload = {
77
- project: { uuid: projectUuid },
78
- filter: {
79
- environmentId: input.environmentId ?? null,
80
- q: input.q ?? null,
81
- role: input.role ?? null,
82
- },
83
- pageInfo,
84
- credentials,
85
- };
86
- logger.toolComplete('list_credentials', Date.now() - start);
87
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
88
- }
89
- catch (error) {
90
- logger.toolError('list_credentials', error, Date.now() - start);
91
- throw handleExternalServiceError(error, 'DebuggAI', 'list_credentials');
92
- }
93
- }
@@ -1,63 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { detectRepoName } from '../utils/gitContext.js';
6
- import { toPaginationParams, makePageInfo } from '../utils/pagination.js';
7
- const logger = new Logger({ module: 'listEnvironmentsHandler' });
8
- export async function listEnvironmentsHandler(input, _context) {
9
- const start = Date.now();
10
- const pagination = toPaginationParams({ page: input.page, pageSize: input.pageSize });
11
- logger.toolStart('list_environments', { projectUuid: input.projectUuid, q: input.q, ...pagination });
12
- try {
13
- const client = new DebuggAIServerClient(config.api.key);
14
- await client.init();
15
- let projectUuid = input.projectUuid;
16
- let projectName = null;
17
- let projectRepoName = null;
18
- if (!projectUuid) {
19
- const repoName = detectRepoName();
20
- if (!repoName) {
21
- const payload = {
22
- error: 'NoProjectResolved',
23
- message: 'No git repo detected and no projectUuid provided. Pass projectUuid (get it from list_projects) or invoke from a directory with a git origin.',
24
- pageInfo: makePageInfo(pagination.page, pagination.pageSize, 0, null),
25
- environments: [],
26
- };
27
- logger.toolComplete('list_environments', Date.now() - start);
28
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
29
- }
30
- const project = await client.findProjectByRepoName(repoName);
31
- if (!project) {
32
- const payload = {
33
- error: 'NoProjectResolved',
34
- message: `No DebuggAI project found for repo "${repoName}". Pass projectUuid explicitly or call list_projects to discover.`,
35
- pageInfo: makePageInfo(pagination.page, pagination.pageSize, 0, null),
36
- environments: [],
37
- };
38
- logger.toolComplete('list_environments', Date.now() - start);
39
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
40
- }
41
- projectUuid = project.uuid;
42
- projectName = project.name;
43
- projectRepoName = project.repo?.name ?? repoName;
44
- }
45
- const { pageInfo, environments } = await client.listEnvironmentsPaginated(projectUuid, pagination, input.q);
46
- const payload = {
47
- project: {
48
- uuid: projectUuid,
49
- name: projectName,
50
- repoName: projectRepoName,
51
- },
52
- filter: { q: input.q ?? null },
53
- pageInfo,
54
- environments,
55
- };
56
- logger.toolComplete('list_environments', Date.now() - start);
57
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
58
- }
59
- catch (error) {
60
- logger.toolError('list_environments', error, Date.now() - start);
61
- throw handleExternalServiceError(error, 'DebuggAI', 'list_environments');
62
- }
63
- }
@@ -1,35 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { toPaginationParams } from '../utils/pagination.js';
6
- const logger = new Logger({ module: 'listExecutionsHandler' });
7
- export async function listExecutionsHandler(input, _context) {
8
- const start = Date.now();
9
- const pagination = toPaginationParams({ page: input.page, pageSize: input.pageSize });
10
- logger.toolStart('list_executions', { status: input.status, projectUuid: input.projectUuid, ...pagination });
11
- try {
12
- const client = new DebuggAIServerClient(config.api.key);
13
- await client.init();
14
- const { pageInfo, executions } = await client.workflows.listExecutions({
15
- status: input.status,
16
- projectId: input.projectUuid,
17
- page: pagination.page,
18
- pageSize: pagination.pageSize,
19
- });
20
- const payload = {
21
- filter: {
22
- status: input.status ?? null,
23
- projectUuid: input.projectUuid ?? null,
24
- },
25
- pageInfo,
26
- executions,
27
- };
28
- logger.toolComplete('list_executions', Date.now() - start);
29
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
30
- }
31
- catch (error) {
32
- logger.toolError('list_executions', error, Date.now() - start);
33
- throw handleExternalServiceError(error, 'DebuggAI', 'list_executions');
34
- }
35
- }
@@ -1,32 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { toPaginationParams } from '../utils/pagination.js';
6
- const logger = new Logger({ module: 'listProjectsHandler' });
7
- export async function listProjectsHandler(input, _context) {
8
- const start = Date.now();
9
- const pagination = toPaginationParams({ page: input.page, pageSize: input.pageSize });
10
- logger.toolStart('list_projects', { q: input.q, ...pagination });
11
- try {
12
- const client = new DebuggAIServerClient(config.api.key);
13
- await client.init();
14
- const { pageInfo, projects } = await client.listProjects(pagination, input.q);
15
- const payload = {
16
- filter: { q: input.q ?? null },
17
- pageInfo,
18
- projects: projects.map(p => ({
19
- uuid: p.uuid,
20
- name: p.name,
21
- slug: p.slug,
22
- repoName: p.repo?.name ?? null,
23
- })),
24
- };
25
- logger.toolComplete('list_projects', Date.now() - start);
26
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
27
- }
28
- catch (error) {
29
- logger.toolError('list_projects', error, Date.now() - start);
30
- throw handleExternalServiceError(error, 'DebuggAI', 'list_projects');
31
- }
32
- }
@@ -1,27 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { toPaginationParams } from '../utils/pagination.js';
6
- const logger = new Logger({ module: 'listReposHandler' });
7
- export async function listReposHandler(input, _context) {
8
- const start = Date.now();
9
- const pagination = toPaginationParams({ page: input.page, pageSize: input.pageSize });
10
- logger.toolStart('list_repos', { q: input.q, ...pagination });
11
- try {
12
- const client = new DebuggAIServerClient(config.api.key);
13
- await client.init();
14
- const { pageInfo, repos } = await client.listRepos(pagination, input.q);
15
- const payload = {
16
- filter: { q: input.q ?? null },
17
- pageInfo,
18
- repos,
19
- };
20
- logger.toolComplete('list_repos', Date.now() - start);
21
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
22
- }
23
- catch (error) {
24
- logger.toolError('list_repos', error, Date.now() - start);
25
- throw handleExternalServiceError(error, 'DebuggAI', 'list_repos');
26
- }
27
- }
@@ -1,27 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { toPaginationParams } from '../utils/pagination.js';
6
- const logger = new Logger({ module: 'listTeamsHandler' });
7
- export async function listTeamsHandler(input, _context) {
8
- const start = Date.now();
9
- const pagination = toPaginationParams({ page: input.page, pageSize: input.pageSize });
10
- logger.toolStart('list_teams', { q: input.q, ...pagination });
11
- try {
12
- const client = new DebuggAIServerClient(config.api.key);
13
- await client.init();
14
- const { pageInfo, teams } = await client.listTeams(pagination, input.q);
15
- const payload = {
16
- filter: { q: input.q ?? null },
17
- pageInfo,
18
- teams,
19
- };
20
- logger.toolComplete('list_teams', Date.now() - start);
21
- return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
22
- }
23
- catch (error) {
24
- logger.toolError('list_teams', error, Date.now() - start);
25
- throw handleExternalServiceError(error, 'DebuggAI', 'list_teams');
26
- }
27
- }
@@ -1,70 +0,0 @@
1
- import { Logger } from '../utils/logger.js';
2
- import { handleExternalServiceError } from '../utils/errors.js';
3
- import { DebuggAIServerClient } from '../services/index.js';
4
- import { config } from '../config/index.js';
5
- import { detectRepoName } from '../utils/gitContext.js';
6
- const logger = new Logger({ module: 'updateCredentialHandler' });
7
- function notFound(uuid, context) {
8
- return {
9
- content: [{ type: 'text', text: JSON.stringify({
10
- error: 'NotFound',
11
- message: `Credential ${uuid} not found (${context}).`,
12
- uuid,
13
- }, null, 2) }],
14
- isError: true,
15
- };
16
- }
17
- // Defensive stripper: ensure no password/secret keys slip through into responses.
18
- function stripSecrets(obj) {
19
- const copy = { ...obj };
20
- delete copy.password;
21
- delete copy.secret;
22
- return copy;
23
- }
24
- export async function updateCredentialHandler(input, _context) {
25
- const start = Date.now();
26
- logger.toolStart('update_credential', {
27
- uuid: input.uuid,
28
- environmentId: input.environmentId,
29
- patchKeys: Object.keys(input).filter(k => !['uuid', 'environmentId', 'projectUuid', 'password'].includes(k)).concat(input.password !== undefined ? ['password'] : []),
30
- });
31
- try {
32
- const client = new DebuggAIServerClient(config.api.key);
33
- await client.init();
34
- let projectUuid = input.projectUuid;
35
- if (!projectUuid) {
36
- const repoName = detectRepoName();
37
- if (!repoName)
38
- return notFound(input.uuid, 'no git repo and no projectUuid');
39
- const project = await client.findProjectByRepoName(repoName);
40
- if (!project)
41
- return notFound(input.uuid, `no project for repo "${repoName}"`);
42
- projectUuid = project.uuid;
43
- }
44
- try {
45
- const credential = await client.updateCredential(projectUuid, input.environmentId, input.uuid, {
46
- label: input.label,
47
- username: input.username,
48
- password: input.password,
49
- role: input.role,
50
- });
51
- logger.toolComplete('update_credential', Date.now() - start);
52
- return {
53
- content: [{ type: 'text', text: JSON.stringify({
54
- updated: true,
55
- credential: stripSecrets(credential),
56
- }, null, 2) }],
57
- };
58
- }
59
- catch (err) {
60
- if (err?.statusCode === 404 || err?.response?.status === 404) {
61
- return notFound(input.uuid, `backend 404 for env ${input.environmentId}`);
62
- }
63
- throw err;
64
- }
65
- }
66
- catch (error) {
67
- logger.toolError('update_credential', error, Date.now() - start);
68
- throw handleExternalServiceError(error, 'DebuggAI', 'update_credential');
69
- }
70
- }
@@ -1,22 +0,0 @@
1
- import { CancelExecutionInputSchema } from '../types/index.js';
2
- import { cancelExecutionHandler } from '../handlers/cancelExecutionHandler.js';
3
- const DESCRIPTION = `Cancel an in-flight workflow execution by UUID. Returns {cancelled:true, uuid} on success. Returns isError:true + AlreadyCompleted when the execution is already done (backend 409). Returns isError:true + NotFound when uuid doesn't exist.`;
4
- export function buildCancelExecutionTool() {
5
- return {
6
- name: 'cancel_execution',
7
- title: 'Cancel Workflow Execution',
8
- description: DESCRIPTION,
9
- inputSchema: {
10
- type: 'object',
11
- properties: {
12
- uuid: { type: 'string', description: 'Execution UUID. Required.' },
13
- },
14
- required: ['uuid'],
15
- additionalProperties: false,
16
- },
17
- };
18
- }
19
- export function buildValidatedCancelExecutionTool() {
20
- const tool = buildCancelExecutionTool();
21
- return { ...tool, inputSchema: CancelExecutionInputSchema, handler: cancelExecutionHandler };
22
- }
@@ -1,52 +0,0 @@
1
- import { CreateCredentialInputSchema } from '../types/index.js';
2
- import { createCredentialHandler } from '../handlers/createCredentialHandler.js';
3
- const DESCRIPTION = `Create a new credential under an environment. Required: environmentId, label, username, password. Optional role (e.g. "admin", "guest"). password is write-only — the response returns only uuid/label/username/role/environmentUuid, never the raw password. Defaults to the project resolved from the current git repo; pass projectUuid to target a different project (get UUIDs via list_projects). Returns the created credential's uuid for use with check_app_in_browser via credentialId.`;
4
- export function buildCreateCredentialTool() {
5
- return {
6
- name: 'create_credential',
7
- title: 'Create Environment Credential',
8
- description: DESCRIPTION,
9
- inputSchema: {
10
- type: 'object',
11
- properties: {
12
- environmentId: {
13
- type: 'string',
14
- description: 'UUID of the environment this credential belongs to. Required.',
15
- },
16
- label: {
17
- type: 'string',
18
- description: 'Human-readable label for the credential (e.g. "Admin Account"). Required.',
19
- minLength: 1,
20
- },
21
- username: {
22
- type: 'string',
23
- description: 'Username or email used to log in. Required.',
24
- minLength: 1,
25
- },
26
- password: {
27
- type: 'string',
28
- description: 'Password. Write-only — never echoed in any MCP tool response. Required.',
29
- minLength: 1,
30
- },
31
- role: {
32
- type: 'string',
33
- description: 'Optional: role string (e.g. "admin", "guest"). Persists on the credential and can be used with credentialRole resolution.',
34
- },
35
- projectUuid: {
36
- type: 'string',
37
- description: 'Optional: UUID of the target project. Defaults to the project resolved from the current git repo.',
38
- },
39
- },
40
- required: ['environmentId', 'label', 'username', 'password'],
41
- additionalProperties: false,
42
- },
43
- };
44
- }
45
- export function buildValidatedCreateCredentialTool() {
46
- const tool = buildCreateCredentialTool();
47
- return {
48
- ...tool,
49
- inputSchema: CreateCredentialInputSchema,
50
- handler: createCredentialHandler,
51
- };
52
- }