lattice-mcp 1.0.0 → 1.0.1

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 (3) hide show
  1. package/README.md +115 -0
  2. package/index.js +47 -1
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # lattice-mcp
2
+
3
+ MCP server for the [Lattice](https://github.com/aidenappl/lattice-api) container orchestration platform. Gives Claude Code direct access to manage workers, stacks, containers, and deployments.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npx lattice-mcp --setup
9
+ ```
10
+
11
+ This prompts for your Lattice API URL and API token, writes the config to `~/.mcp.json`, and you're ready to go. Restart Claude Code after setup.
12
+
13
+ ## Manual Setup
14
+
15
+ Add to `~/.mcp.json`:
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "lattice": {
21
+ "command": "npx",
22
+ "args": ["-y", "lattice-mcp"],
23
+ "env": {
24
+ "LATTICE_API_URL": "https://lattice-api.appleby.cloud",
25
+ "LATTICE_API_TOKEN": "your-api-token"
26
+ }
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ Generate an API token from the Lattice web dashboard under **Settings > API Tokens**.
33
+
34
+ ## Tools
35
+
36
+ ### Overview & Health
37
+ | Tool | Description |
38
+ |------|-------------|
39
+ | `lattice_overview` | Fleet overview — worker counts, stack counts, failed stacks, CPU/memory |
40
+ | `lattice_health` | API health and database connectivity |
41
+
42
+ ### Workers
43
+ | Tool | Description |
44
+ |------|-------------|
45
+ | `lattice_list_workers` | List workers with status, IP, versions |
46
+ | `lattice_get_worker` | Detailed worker info |
47
+ | `lattice_get_worker_metrics` | CPU, memory, disk, network metrics |
48
+ | `lattice_reboot_worker` | Reboot a worker machine |
49
+ | `lattice_upgrade_worker` | Upgrade worker runner to latest |
50
+ | `lattice_stop_all_worker` | Stop all containers on a worker |
51
+ | `lattice_start_all_worker` | Start all containers on a worker |
52
+
53
+ ### Stacks
54
+ | Tool | Description |
55
+ |------|-------------|
56
+ | `lattice_list_stacks` | List stacks with status and worker assignment |
57
+ | `lattice_get_stack` | Full stack details including compose YAML |
58
+ | `lattice_update_stack` | Update stack configuration |
59
+ | `lattice_deploy_stack` | Deploy a stack (all or specific containers) |
60
+ | `lattice_restart_stack` | Restart all containers in a stack |
61
+ | `lattice_stop_stack` | Stop all containers in a stack |
62
+ | `lattice_start_stack` | Start all containers in a stack |
63
+
64
+ ### Containers
65
+ | Tool | Description |
66
+ |------|-------------|
67
+ | `lattice_list_containers` | List containers with status, image, ports, health |
68
+ | `lattice_get_container` | Full container details |
69
+ | `lattice_get_container_logs` | Recent container logs (stdout/stderr) |
70
+ | `lattice_get_container_lifecycle` | Lifecycle events (start, stop, health changes) |
71
+ | `lattice_start_container` | Start a stopped container |
72
+ | `lattice_stop_container` | Stop a running container |
73
+ | `lattice_restart_container` | Restart a container |
74
+ | `lattice_kill_container` | Force kill a container |
75
+ | `lattice_pause_container` | Pause a running container |
76
+ | `lattice_unpause_container` | Unpause a paused container |
77
+ | `lattice_remove_container` | Remove a container |
78
+ | `lattice_recreate_container` | Remove and recreate a container |
79
+
80
+ ### Deployments
81
+ | Tool | Description |
82
+ |------|-------------|
83
+ | `lattice_list_deployments` | List deployments with status and timing |
84
+ | `lattice_get_deployment` | Deployment details with container-level status |
85
+ | `lattice_get_deployment_logs` | Pull, create, start, swap events with timing |
86
+ | `lattice_rollback_deployment` | Rollback to previous state |
87
+
88
+ ### System
89
+ | Tool | Description |
90
+ |------|-------------|
91
+ | `lattice_get_audit_log` | Recent audit log entries |
92
+ | `lattice_update_api` | Trigger API self-update |
93
+ | `lattice_update_web` | Trigger web container update |
94
+ | `lattice_list_api_tokens` | List API tokens |
95
+ | `lattice_create_api_token` | Create a new API token |
96
+ | `lattice_delete_api_token` | Delete an API token |
97
+
98
+ ## Example Prompts
99
+
100
+ - "What's the status of all stacks?"
101
+ - "Show me logs for the forta-api container"
102
+ - "Deploy stack 5"
103
+ - "Which containers are unhealthy?"
104
+ - "Rollback the last deployment on stack 12"
105
+
106
+ ## Environment Variables
107
+
108
+ | Variable | Required | Description |
109
+ |----------|----------|-------------|
110
+ | `LATTICE_API_URL` | Yes | Lattice API base URL |
111
+ | `LATTICE_API_TOKEN` | Yes | API token for authentication |
112
+
113
+ ## License
114
+
115
+ MIT
package/index.js CHANGED
@@ -2,12 +2,58 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { z } from "zod";
5
+ import { createInterface } from "readline";
6
+ import { readFileSync, writeFileSync, existsSync } from "fs";
7
+ import { join } from "path";
8
+ import { homedir } from "os";
9
+
10
+ // --- Interactive setup ---
11
+
12
+ if (process.argv.includes("--setup")) {
13
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
14
+ const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
15
+
16
+ console.log("\n Lattice MCP Setup\n");
17
+
18
+ const apiUrl = (await ask(" Lattice API URL (https://lattice-api.appleby.cloud): ")).trim() || "https://lattice-api.appleby.cloud";
19
+ const apiToken = (await ask(" Lattice API Token: ")).trim();
20
+ rl.close();
21
+
22
+ if (!apiToken) {
23
+ console.error("\n Error: API token is required.\n");
24
+ process.exit(1);
25
+ }
26
+
27
+ const mcpPath = join(homedir(), ".mcp.json");
28
+ let config = { mcpServers: {} };
29
+ if (existsSync(mcpPath)) {
30
+ try { config = JSON.parse(readFileSync(mcpPath, "utf-8")); } catch {}
31
+ if (!config.mcpServers) config.mcpServers = {};
32
+ }
33
+
34
+ config.mcpServers.lattice = {
35
+ command: "npx",
36
+ args: ["-y", "lattice-mcp"],
37
+ env: {
38
+ LATTICE_API_URL: apiUrl,
39
+ LATTICE_API_TOKEN: apiToken,
40
+ },
41
+ };
42
+
43
+ writeFileSync(mcpPath, JSON.stringify(config, null, 2) + "\n");
44
+ console.log(`\n Written to ${mcpPath}`);
45
+ console.log(" Restart Claude Code to load the Lattice MCP server.\n");
46
+ process.exit(0);
47
+ }
48
+
49
+ // --- MCP Server ---
5
50
 
6
51
  const API_URL = process.env.LATTICE_API_URL;
7
52
  const API_TOKEN = process.env.LATTICE_API_TOKEN;
8
53
 
9
54
  if (!API_URL || !API_TOKEN) {
10
- console.error("LATTICE_API_URL and LATTICE_API_TOKEN are required");
55
+ console.error("LATTICE_API_URL and LATTICE_API_TOKEN are required.");
56
+ console.error("Run `npx lattice-mcp --setup` to configure.");
11
57
  process.exit(1);
12
58
  }
13
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lattice-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MCP server for Lattice container orchestration platform",
5
5
  "type": "module",
6
6
  "main": "index.js",