Skip to content

Commit 8792c9f

Browse files
refactor: extract shared types from tool files to src/types/arcane-types.ts
- Create src/types/arcane-types.ts with 33 interfaces grouped by domain - Update 21 tool files to import from shared types instead of defining locally - Eliminates duplicate interface definitions that could drift from API schema - No behavioral changes: build and all 50 tests pass Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e49ba93 commit 8792c9f

22 files changed

Lines changed: 409 additions & 339 deletions

src/tools/build-tools.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,7 @@ import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { validatePath } from "../utils/format.js";
99
import { logger } from "../utils/logger.js";
10-
11-
interface Build {
12-
id: string;
13-
status: string;
14-
tag?: string;
15-
platform?: string;
16-
provider?: string;
17-
startedAt?: string;
18-
completedAt?: string;
19-
error?: string;
20-
}
21-
22-
interface BuildDetails extends Build {
23-
dockerfile?: string;
24-
gitUrl?: string;
25-
buildArgs?: Record<string, string>;
26-
logs?: string;
27-
}
28-
29-
interface WorkspaceFile {
30-
name: string;
31-
path: string;
32-
size?: number;
33-
isDirectory: boolean;
34-
modifiedAt?: string;
35-
}
10+
import type { Build, BuildDetails, WorkspaceFile } from "../types/arcane-types.js";
3611

3712
export function registerBuildTools(server: McpServer): void {
3813

src/tools/container-tools.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@ import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { DOCKER_SHORT_ID_LENGTH, MAX_DISPLAY_LABELS, DEFAULT_PAGINATION_START, DEFAULT_PAGINATION_LIMIT } from "../constants.js";
99
import { logger } from "../utils/logger.js";
10-
11-
interface Container {
12-
id: string;
13-
name: string;
14-
image: string;
15-
status: string;
16-
state: string;
17-
created: string;
18-
ports?: Array<{ privatePort: number; publicPort?: number; type: string }>;
19-
labels?: Record<string, string>;
20-
}
10+
import type { Container } from "../types/arcane-types.js";
2111

2212
export function registerContainerTools(server: McpServer): void {
2313

src/tools/dashboard-tools.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
66
import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { logger } from "../utils/logger.js";
9-
10-
interface DashboardSnapshot {
11-
containers: { total: number; running: number; stopped: number };
12-
projects: { total: number; running: number; stopped: number };
13-
images: { total: number; updatesAvailable: number };
14-
volumes: { total: number; totalSize?: string };
15-
networks: { total: number };
16-
systemInfo?: { dockerVersion?: string; osType?: string; cpus?: number; memoryBytes?: number };
17-
}
18-
19-
interface ActionItem {
20-
type: string;
21-
severity: string;
22-
title: string;
23-
description?: string;
24-
resourceId?: string;
25-
resourceName?: string;
26-
}
9+
import type { DashboardSnapshot, ActionItem } from "../types/arcane-types.js";
2710

2811
export function registerDashboardTools(server: McpServer): void {
2912

src/tools/environment-tools.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@ import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { formatSizeGB } from "../utils/format.js";
99
import { logger } from "../utils/logger.js";
10-
11-
interface Environment {
12-
id: string;
13-
name: string;
14-
apiUrl?: string;
15-
status?: string;
16-
createdAt?: string;
17-
updatedAt?: string;
18-
}
10+
import type { Environment } from "../types/arcane-types.js";
1911

2012
export function registerEnvironmentTools(server: McpServer): void {
2113
// arcane_environment_list

src/tools/event-tools.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,7 @@ import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { MAX_DISPLAY_EVENTS } from "../constants.js";
99
import { logger } from "../utils/logger.js";
10-
11-
interface Event {
12-
id: string;
13-
type: string;
14-
message: string;
15-
resourceType?: string;
16-
resourceId?: string;
17-
resourceName?: string;
18-
userId?: string;
19-
username?: string;
20-
createdAt: string;
21-
metadata?: Record<string, unknown>;
22-
}
10+
import type { Event } from "../types/arcane-types.js";
2311

2412
export function registerEventTools(server: McpServer): void {
2513

src/tools/gitops-tools.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,7 @@ import { z } from "zod";
88
import { toolHandler } from "../utils/tool-helpers.js";
99
import { validatePath } from "../utils/format.js";
1010
import { logger } from "../utils/logger.js";
11-
12-
interface GitOpsSync {
13-
id: string;
14-
name: string;
15-
repositoryId: string;
16-
branch: string;
17-
path: string;
18-
targetProjectId?: string;
19-
lastSyncAt?: string;
20-
lastSyncStatus?: string;
21-
autoSync: boolean;
22-
syncInterval?: number;
23-
}
24-
25-
interface GitRepository {
26-
id: string;
27-
name: string;
28-
url: string;
29-
branch: string;
30-
authType: string;
31-
lastTestAt?: string;
32-
lastTestStatus?: string;
33-
}
11+
import type { GitOpsSync, GitRepository } from "../types/arcane-types.js";
3412

3513
export function registerGitopsTools(server: McpServer): void {
3614
// ============= GitOps Sync =============

src/tools/image-tools.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ import { toolHandler } from "../utils/tool-helpers.js";
88
import { formatSize, formatSizeMB, formatSizeGB } from "../utils/format.js";
99
import { DOCKER_DIGEST_PREFIX_LENGTH, DOCKER_SHORT_ID_LENGTH } from "../constants.js";
1010
import { logger } from "../utils/logger.js";
11-
12-
interface Image {
13-
id: string;
14-
repoTags: string[];
15-
repoDigests?: string[];
16-
created: string;
17-
size: number;
18-
virtualSize?: number;
19-
}
11+
import type { Image } from "../types/arcane-types.js";
2012

2113
export function registerImageTools(server: McpServer): void {
2214
// arcane_image_list

src/tools/image-update-tools.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
66
import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { logger } from "../utils/logger.js";
9-
10-
interface ImageUpdateResponse {
11-
imageRef: string;
12-
currentDigest?: string;
13-
latestDigest?: string;
14-
updateAvailable: boolean;
15-
currentTag?: string;
16-
latestTag?: string;
17-
}
18-
19-
interface BatchImageUpdateResponse {
20-
results: Array<ImageUpdateResponse & { imageId: string }>;
21-
total: number;
22-
updatesAvailable: number;
23-
}
24-
25-
interface ImageUpdateSummary {
26-
totalImages: number;
27-
checkedImages: number;
28-
updatesAvailable: number;
29-
lastCheckedAt?: string;
30-
}
9+
import type { ImageUpdateResponse, BatchImageUpdateResponse, ImageUpdateSummary } from "../types/arcane-types.js";
3110

3211
export function registerImageUpdateTools(server: McpServer): void {
3312

src/tools/job-tools.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
66
import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { logger } from "../utils/logger.js";
9-
10-
interface Job {
11-
id: string;
12-
name: string;
13-
type: string;
14-
status: string;
15-
lastRunAt?: string;
16-
nextRunAt?: string;
17-
schedule?: string;
18-
enabled: boolean;
19-
}
9+
import type { Job } from "../types/arcane-types.js";
2010

2111
export function registerJobTools(server: McpServer): void {
2212
// arcane_job_list

src/tools/network-tools.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,7 @@ import { z } from "zod";
77
import { toolHandler } from "../utils/tool-helpers.js";
88
import { DOCKER_SHORT_ID_LENGTH } from "../constants.js";
99
import { logger } from "../utils/logger.js";
10-
11-
interface Network {
12-
id: string;
13-
name: string;
14-
driver: string;
15-
scope: string;
16-
internal: boolean;
17-
attachable: boolean;
18-
ipam?: {
19-
driver: string;
20-
config?: Array<{ subnet?: string; gateway?: string }>;
21-
};
22-
containers?: Record<string, { name: string; ipv4Address?: string }>;
23-
created?: string;
24-
}
10+
import type { Network } from "../types/arcane-types.js";
2511

2612
export function registerNetworkTools(server: McpServer): void {
2713

0 commit comments

Comments
 (0)