@ironclads/incus-mcp 0.1.0
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/.claude/settings.local.json +10 -0
- package/.eslintrc.json +23 -0
- package/.mcp.json +38 -0
- package/.prettierrc +8 -0
- package/CLAUDE.md +127 -0
- package/README.md +315 -0
- package/build/incus.d.ts +17 -0
- package/build/incus.d.ts.map +1 -0
- package/build/incus.js +66 -0
- package/build/incus.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +291 -0
- package/build/index.js.map +1 -0
- package/build/schemas.d.ts +4 -0
- package/build/schemas.d.ts.map +1 -0
- package/build/schemas.js +202 -0
- package/build/schemas.js.map +1 -0
- package/mcp-config-example.json +11 -0
- package/package.json +45 -0
- package/src/incus.ts +71 -0
- package/src/index.ts +340 -0
- package/src/schemas.ts +204 -0
- package/test/client.ts +169 -0
- package/test/resource-test.js +164 -0
- package/test/simple-test.js +187 -0
- package/tsconfig.json +20 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"node": true,
|
|
4
|
+
"es2022": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"@typescript-eslint/recommended"
|
|
9
|
+
],
|
|
10
|
+
"parser": "@typescript-eslint/parser",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"ecmaVersion": 2022,
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"plugins": ["@typescript-eslint"],
|
|
16
|
+
"rules": {
|
|
17
|
+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
|
18
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
19
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
20
|
+
"prefer-const": "error",
|
|
21
|
+
"no-var": "error"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/.mcp.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"context7": {
|
|
4
|
+
"command": "npx",
|
|
5
|
+
"args": ["-y", "@upstash/context7-mcp@latest"]
|
|
6
|
+
},
|
|
7
|
+
"sequential-thinking": {
|
|
8
|
+
"command": "npx",
|
|
9
|
+
"args": [
|
|
10
|
+
"-y",
|
|
11
|
+
"@modelcontextprotocol/server-sequential-thinking"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"playwright": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": [
|
|
17
|
+
"-y",
|
|
18
|
+
"@playwright/mcp"
|
|
19
|
+
],
|
|
20
|
+
"env": {}
|
|
21
|
+
},
|
|
22
|
+
"cloudflare": {
|
|
23
|
+
"command": "npx",
|
|
24
|
+
"args": ["mcp-remote", "https://docs.mcp.cloudflare.com/sse"]
|
|
25
|
+
},
|
|
26
|
+
"podman": {
|
|
27
|
+
"command": "npx",
|
|
28
|
+
"args": [
|
|
29
|
+
"-y",
|
|
30
|
+
"podman-mcp-server@latest"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"incus": {
|
|
34
|
+
"command": "node",
|
|
35
|
+
"args": ["/Users/kaffa/mcp-servers/incus-mcp/build/index.js"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/.prettierrc
ADDED
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is the **Incus MCP Server** - a complete Model Context Protocol implementation for managing Incus containers and virtual machines. This repository contains both the MCP server implementation and configuration files for integration with Claude Code and other MCP clients.
|
|
8
|
+
|
|
9
|
+
## Project Structure
|
|
10
|
+
|
|
11
|
+
### Core Implementation
|
|
12
|
+
- **Source Code**: TypeScript implementation in `src/` directory
|
|
13
|
+
- `index.ts`: Main MCP server with all tool and resource handlers
|
|
14
|
+
- `incus.ts`: Incus command execution utilities and error handling
|
|
15
|
+
- `schemas.ts`: Tool and resource schema definitions for MCP protocol
|
|
16
|
+
- **Build Output**: Compiled JavaScript in `build/` directory
|
|
17
|
+
- **Tests**: Comprehensive test suite in `test/` directory
|
|
18
|
+
|
|
19
|
+
### Configuration Files
|
|
20
|
+
- **package.json**: Node.js project configuration with TypeScript build system
|
|
21
|
+
- **tsconfig.json**: TypeScript compiler configuration
|
|
22
|
+
- **.mcp.json**: MCP server configuration for local development and testing
|
|
23
|
+
|
|
24
|
+
## MCP Server Configuration
|
|
25
|
+
|
|
26
|
+
### Available Servers
|
|
27
|
+
The `.mcp.json` file configures six MCP servers:
|
|
28
|
+
|
|
29
|
+
- **context7**: Documentation and code examples lookup using `@upstash/context7-mcp`
|
|
30
|
+
- **sequential-thinking**: Complex multi-step analysis using `@modelcontextprotocol/server-sequential-thinking`
|
|
31
|
+
- **playwright**: Browser automation and E2E testing using `@playwright/mcp`
|
|
32
|
+
- **cloudflare**: Cloudflare documentation access via remote MCP endpoint
|
|
33
|
+
- **podman**: Container management using `podman-mcp-server`
|
|
34
|
+
- **incus**: Local Incus container management (this project's main server)
|
|
35
|
+
|
|
36
|
+
### Claude Code Integration
|
|
37
|
+
The `.claude/settings.local.json` file enables all configured MCP servers for Claude Code sessions in this directory.
|
|
38
|
+
|
|
39
|
+
## Incus MCP Server Capabilities
|
|
40
|
+
|
|
41
|
+
### Tools (10 available)
|
|
42
|
+
1. **incus_list_instances**: List all instances with status (supports remote servers)
|
|
43
|
+
2. **incus_show_instance**: Show detailed instance configuration and state
|
|
44
|
+
3. **incus_start_instance**: Start stopped instances
|
|
45
|
+
4. **incus_stop_instance**: Stop running instances (with force option)
|
|
46
|
+
5. **incus_restart_instance**: Restart instances (with force option)
|
|
47
|
+
6. **incus_create_instance**: Create new instances from images
|
|
48
|
+
7. **incus_delete_instance**: Delete instances (with force option)
|
|
49
|
+
8. **incus_exec_command**: Execute commands inside running instances
|
|
50
|
+
9. **incus_list_remotes**: List all configured remote servers
|
|
51
|
+
10. **incus_info**: Show Incus system information
|
|
52
|
+
|
|
53
|
+
### Resources (2 available)
|
|
54
|
+
- **incus://instances/list**: JSON list of all instances across all remotes
|
|
55
|
+
- **incus://remotes/list**: JSON list of all configured remote servers
|
|
56
|
+
|
|
57
|
+
### Remote Server Support
|
|
58
|
+
The server automatically works with all configured Incus remotes:
|
|
59
|
+
- **jp1**: Primary remote server (current)
|
|
60
|
+
- **kr1**: Secondary remote server
|
|
61
|
+
- **lambda**: Additional remote server
|
|
62
|
+
- **local**: Local Incus daemon
|
|
63
|
+
- **images**: LinuxContainers.org image server
|
|
64
|
+
- **docker**: Docker Hub OCI registry
|
|
65
|
+
- **ghcr**: GitHub Container Registry
|
|
66
|
+
|
|
67
|
+
## Common Operations
|
|
68
|
+
|
|
69
|
+
### Development Workflow
|
|
70
|
+
```bash
|
|
71
|
+
# Install dependencies
|
|
72
|
+
npm install
|
|
73
|
+
|
|
74
|
+
# Development mode with auto-reload
|
|
75
|
+
npm run dev
|
|
76
|
+
|
|
77
|
+
# Build TypeScript to JavaScript
|
|
78
|
+
npm run build
|
|
79
|
+
|
|
80
|
+
# Run the MCP server
|
|
81
|
+
npm start
|
|
82
|
+
|
|
83
|
+
# Run tests
|
|
84
|
+
node test/simple-test.js
|
|
85
|
+
node test/resource-test.js
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Production Deployment
|
|
89
|
+
```bash
|
|
90
|
+
# Build for production
|
|
91
|
+
npm run build
|
|
92
|
+
|
|
93
|
+
# Run the server directly
|
|
94
|
+
node build/index.js
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Configuration Updates
|
|
98
|
+
- Modify `src/schemas.ts` to add new tools or resources
|
|
99
|
+
- Update `src/index.ts` to implement new functionality
|
|
100
|
+
- Rebuild with `npm run build` after changes
|
|
101
|
+
- Test with provided test scripts
|
|
102
|
+
|
|
103
|
+
## Architecture Notes
|
|
104
|
+
|
|
105
|
+
This is a full-featured MCP server implementation with:
|
|
106
|
+
|
|
107
|
+
- **Protocol Layer**: Complete MCP protocol implementation using official SDK
|
|
108
|
+
- **Command Layer**: Safe Incus command execution with proper error handling
|
|
109
|
+
- **Validation Layer**: Zod schema validation for all tool arguments
|
|
110
|
+
- **Transport Layer**: Standard stdio transport for MCP communication
|
|
111
|
+
- **Security Layer**: Input validation and command sanitization
|
|
112
|
+
|
|
113
|
+
The server is designed for:
|
|
114
|
+
- **Local Development**: Direct integration with local Incus daemon
|
|
115
|
+
- **Remote Management**: Support for multiple Incus remotes
|
|
116
|
+
- **Production Use**: Robust error handling and logging
|
|
117
|
+
- **Claude Integration**: Optimized for Claude Code and Claude Desktop
|
|
118
|
+
|
|
119
|
+
## Testing and Validation
|
|
120
|
+
|
|
121
|
+
The repository includes comprehensive tests:
|
|
122
|
+
- **Integration Tests**: Full MCP protocol communication tests
|
|
123
|
+
- **Tool Tests**: Individual tool execution validation
|
|
124
|
+
- **Resource Tests**: Resource reading and JSON parsing verification
|
|
125
|
+
- **Error Tests**: Proper error handling for invalid inputs
|
|
126
|
+
|
|
127
|
+
All tests validate against real Incus installations with multiple configured remotes.
|
package/README.md
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# Incus MCP Server
|
|
2
|
+
|
|
3
|
+
A comprehensive Model Context Protocol (MCP) server for managing Incus containers and virtual machines. This server provides a complete set of tools and resources to interact with Incus instances locally and across remote servers through the MCP protocol.
|
|
4
|
+
|
|
5
|
+
## ⭐ Key Features
|
|
6
|
+
|
|
7
|
+
### 🛠 Tools (10 Available)
|
|
8
|
+
- **incus_list_instances**: List all instances with their current status (supports remote servers)
|
|
9
|
+
- **incus_show_instance**: Show detailed information about a specific instance
|
|
10
|
+
- **incus_start_instance**: Start stopped instances
|
|
11
|
+
- **incus_stop_instance**: Stop running instances (with optional force flag)
|
|
12
|
+
- **incus_restart_instance**: Restart instances (with optional force flag)
|
|
13
|
+
- **incus_create_instance**: Create new instances from images with custom configuration
|
|
14
|
+
- **incus_delete_instance**: Delete instances (with optional force flag)
|
|
15
|
+
- **incus_exec_command**: Execute commands inside running instances
|
|
16
|
+
- **incus_list_remotes**: List all configured remote servers
|
|
17
|
+
- **incus_info**: Show comprehensive Incus system information
|
|
18
|
+
|
|
19
|
+
### 📚 Resources (2 Available)
|
|
20
|
+
- **incus://instances/list**: JSON list of all instances across all remotes
|
|
21
|
+
- **incus://remotes/list**: JSON list of all configured remote servers with connection details
|
|
22
|
+
|
|
23
|
+
### 🌐 Multi-Remote Support
|
|
24
|
+
Seamlessly works with all your configured Incus remotes:
|
|
25
|
+
- **Local instances**: Direct access to local Incus daemon
|
|
26
|
+
- **Remote servers**: Full support for TLS-authenticated remote Incus servers
|
|
27
|
+
- **Image sources**: Integration with LinuxContainers.org, Docker Hub, GitHub Container Registry
|
|
28
|
+
- **Automatic discovery**: Automatically detects and works with existing remote configurations
|
|
29
|
+
|
|
30
|
+
## 📋 Prerequisites
|
|
31
|
+
|
|
32
|
+
- **Node.js 18+**: Required for running the TypeScript/JavaScript server
|
|
33
|
+
- **Incus installed**: Working Incus installation with daemon running
|
|
34
|
+
- **Proper permissions**: User must be in `incus` group or have appropriate file access
|
|
35
|
+
- **Remote configuration**: Pre-configured remote servers (optional but recommended)
|
|
36
|
+
|
|
37
|
+
## 🚀 Quick Start
|
|
38
|
+
|
|
39
|
+
### Installation from Source
|
|
40
|
+
```bash
|
|
41
|
+
# Clone the repository
|
|
42
|
+
git clone https://github.com/your-username/incus-mcp.git
|
|
43
|
+
cd incus-mcp
|
|
44
|
+
|
|
45
|
+
# Install dependencies
|
|
46
|
+
npm install
|
|
47
|
+
|
|
48
|
+
# Build the project
|
|
49
|
+
npm run build
|
|
50
|
+
|
|
51
|
+
# Test the installation
|
|
52
|
+
npm test
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Verify Incus Setup
|
|
56
|
+
```bash
|
|
57
|
+
# Check Incus is working
|
|
58
|
+
incus version
|
|
59
|
+
incus list
|
|
60
|
+
incus remote list
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 💻 Usage
|
|
64
|
+
|
|
65
|
+
### Standalone MCP Server
|
|
66
|
+
```bash
|
|
67
|
+
# Run the server directly
|
|
68
|
+
node build/index.js
|
|
69
|
+
|
|
70
|
+
# Development mode with auto-reload
|
|
71
|
+
npm run dev
|
|
72
|
+
|
|
73
|
+
# Production mode
|
|
74
|
+
npm start
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Integration with Claude Desktop
|
|
78
|
+
|
|
79
|
+
Add to your Claude Desktop MCP configuration (`~/.config/claude-desktop/config.json`):
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcpServers": {
|
|
84
|
+
"incus": {
|
|
85
|
+
"command": "node",
|
|
86
|
+
"args": ["/absolute/path/to/incus-mcp/build/index.js"],
|
|
87
|
+
"env": {
|
|
88
|
+
"PATH": "/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Integration with Claude Code
|
|
96
|
+
|
|
97
|
+
The repository includes `.mcp.json` for local development:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mcpServers": {
|
|
102
|
+
"incus": {
|
|
103
|
+
"command": "node",
|
|
104
|
+
"args": ["/Users/kaffa/mcp-servers/incus-mcp/build/index.js"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 🔧 Development
|
|
111
|
+
|
|
112
|
+
### Development Workflow
|
|
113
|
+
```bash
|
|
114
|
+
# Install dependencies
|
|
115
|
+
npm install
|
|
116
|
+
|
|
117
|
+
# Development mode with auto-reload
|
|
118
|
+
npm run dev
|
|
119
|
+
|
|
120
|
+
# Build TypeScript to JavaScript
|
|
121
|
+
npm run build
|
|
122
|
+
|
|
123
|
+
# Run comprehensive tests
|
|
124
|
+
node test/simple-test.js
|
|
125
|
+
node test/resource-test.js
|
|
126
|
+
|
|
127
|
+
# Code quality
|
|
128
|
+
npm run lint
|
|
129
|
+
npm run format
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Project Structure
|
|
133
|
+
```
|
|
134
|
+
incus-mcp/
|
|
135
|
+
├── src/
|
|
136
|
+
│ ├── index.ts # Main MCP server implementation
|
|
137
|
+
│ ├── incus.ts # Incus command execution utilities
|
|
138
|
+
│ └── schemas.ts # MCP tool/resource schema definitions
|
|
139
|
+
├── test/
|
|
140
|
+
│ ├── simple-test.js # Basic functionality tests
|
|
141
|
+
│ └── resource-test.js # Resource reading tests
|
|
142
|
+
├── build/ # Compiled JavaScript output
|
|
143
|
+
├── .mcp.json # Local MCP server configuration
|
|
144
|
+
└── mcp-config-example.json # Claude Desktop config template
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## ⚙️ Configuration
|
|
148
|
+
|
|
149
|
+
### System Requirements
|
|
150
|
+
The server automatically uses your existing Incus configuration:
|
|
151
|
+
|
|
152
|
+
1. **Incus daemon running**: `systemctl status incus` (Linux) or check process list
|
|
153
|
+
2. **User permissions**: Member of `incus` group or appropriate file access
|
|
154
|
+
3. **Remote servers**: Pre-configured remotes work automatically
|
|
155
|
+
|
|
156
|
+
### Setting up Remote Servers
|
|
157
|
+
```bash
|
|
158
|
+
# Add a remote Incus server
|
|
159
|
+
incus remote add myserver https://server.example.com:8443
|
|
160
|
+
|
|
161
|
+
# Add with custom certificate
|
|
162
|
+
incus remote add myserver https://server.example.com:8443 --password
|
|
163
|
+
|
|
164
|
+
# List all configured remotes
|
|
165
|
+
incus remote list
|
|
166
|
+
|
|
167
|
+
# Test remote connection
|
|
168
|
+
incus list myserver:
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Environment Variables
|
|
172
|
+
```bash
|
|
173
|
+
# Optional: Custom PATH for incus binary
|
|
174
|
+
export PATH="/opt/incus/bin:$PATH"
|
|
175
|
+
|
|
176
|
+
# Optional: Debug MCP communication
|
|
177
|
+
export MCP_DEBUG=1
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 📖 Usage Examples
|
|
181
|
+
|
|
182
|
+
### Basic Instance Management
|
|
183
|
+
```bash
|
|
184
|
+
# Via MCP tools (conceptual - actual usage through MCP client)
|
|
185
|
+
incus_list_instances: {}
|
|
186
|
+
# Returns: List of all instances across all remotes
|
|
187
|
+
|
|
188
|
+
incus_create_instance: {
|
|
189
|
+
"name": "webserver",
|
|
190
|
+
"image": "ubuntu:22.04",
|
|
191
|
+
"config": {"limits.cpu": "2", "limits.memory": "2GB"}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
incus_start_instance: {"name": "webserver"}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Remote Operations
|
|
198
|
+
```bash
|
|
199
|
+
incus_list_instances: {"remote": "jp1"}
|
|
200
|
+
# Lists instances only from the jp1 remote server
|
|
201
|
+
|
|
202
|
+
incus_show_instance: {"name": "myapp", "remote": "kr1"}
|
|
203
|
+
# Shows details for 'myapp' instance on kr1 server
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Command Execution
|
|
207
|
+
```bash
|
|
208
|
+
incus_exec_command: {
|
|
209
|
+
"instance": "webserver",
|
|
210
|
+
"command": "apt update && apt install -y nginx",
|
|
211
|
+
"remote": "jp1"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Resource Access
|
|
216
|
+
- `incus://instances/list` → JSON array of all instances with full metadata
|
|
217
|
+
- `incus://remotes/list` → JSON object with remote server configurations
|
|
218
|
+
|
|
219
|
+
## 🛡️ Security & Error Handling
|
|
220
|
+
|
|
221
|
+
### Security Features
|
|
222
|
+
- **Input validation**: All arguments validated with Zod schemas
|
|
223
|
+
- **Command sanitization**: No shell injection vulnerabilities
|
|
224
|
+
- **Permission isolation**: Uses existing Incus user permissions
|
|
225
|
+
- **Remote auth**: Leverages configured TLS certificates
|
|
226
|
+
- **Audit trail**: All commands logged through Incus
|
|
227
|
+
|
|
228
|
+
### Error Handling
|
|
229
|
+
- **Graceful failures**: Comprehensive error messages without exposing internals
|
|
230
|
+
- **Network timeouts**: Proper handling of remote server connectivity issues
|
|
231
|
+
- **Permission errors**: Clear guidance for permission-related problems
|
|
232
|
+
- **Invalid arguments**: Detailed validation error messages
|
|
233
|
+
|
|
234
|
+
## 🐛 Troubleshooting
|
|
235
|
+
|
|
236
|
+
### Common Issues & Solutions
|
|
237
|
+
|
|
238
|
+
#### 1. Permission Denied
|
|
239
|
+
```bash
|
|
240
|
+
# Add user to incus group
|
|
241
|
+
sudo usermod -a -G incus $USER
|
|
242
|
+
newgrp incus
|
|
243
|
+
|
|
244
|
+
# Verify permissions
|
|
245
|
+
id | grep incus
|
|
246
|
+
incus list # Should work without sudo
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### 2. Incus Not Found
|
|
250
|
+
```bash
|
|
251
|
+
# Check installation
|
|
252
|
+
which incus
|
|
253
|
+
incus version
|
|
254
|
+
|
|
255
|
+
# Install on Ubuntu/Debian
|
|
256
|
+
curl -fsSL https://packagecloud.io/install/repositories/candid/incus/script.deb.sh | sudo bash
|
|
257
|
+
sudo apt install incus
|
|
258
|
+
|
|
259
|
+
# Install on macOS
|
|
260
|
+
brew install incus
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### 3. Remote Connection Issues
|
|
264
|
+
```bash
|
|
265
|
+
# Verify remote configuration
|
|
266
|
+
incus remote list
|
|
267
|
+
|
|
268
|
+
# Test connectivity
|
|
269
|
+
incus info remote-name:
|
|
270
|
+
|
|
271
|
+
# Re-add problematic remote
|
|
272
|
+
incus remote remove old-remote
|
|
273
|
+
incus remote add old-remote https://server:8443
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### 4. MCP Server Issues
|
|
277
|
+
```bash
|
|
278
|
+
# Test MCP server directly
|
|
279
|
+
node build/index.js
|
|
280
|
+
# Should show: "Incus MCP server running on stdio"
|
|
281
|
+
|
|
282
|
+
# Check build output
|
|
283
|
+
npm run build
|
|
284
|
+
ls -la build/
|
|
285
|
+
|
|
286
|
+
# Run test suite
|
|
287
|
+
node test/simple-test.js
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Debug Mode
|
|
291
|
+
```bash
|
|
292
|
+
# Enable verbose logging
|
|
293
|
+
DEBUG=mcp* node build/index.js
|
|
294
|
+
|
|
295
|
+
# Test individual tools
|
|
296
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node build/index.js
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## 🤝 Contributing
|
|
300
|
+
|
|
301
|
+
1. Fork the repository
|
|
302
|
+
2. Create a feature branch: `git checkout -b feature-name`
|
|
303
|
+
3. Make your changes and add tests
|
|
304
|
+
4. Run the test suite: `node test/*.js`
|
|
305
|
+
5. Submit a pull request
|
|
306
|
+
|
|
307
|
+
## 📄 License
|
|
308
|
+
|
|
309
|
+
MIT License - see LICENSE file for details.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
**Built with ❤️ for the Incus and MCP communities**
|
|
314
|
+
|
|
315
|
+
For support, please open an issue on GitHub or check the [MCP documentation](https://modelcontextprotocol.io/).
|
package/build/incus.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute an incus command and return the output
|
|
3
|
+
*/
|
|
4
|
+
export declare function execIncusCommand(args: string[]): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Parse incus JSON output safely
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseIncusOutput<T = any>(output: string): T;
|
|
9
|
+
/**
|
|
10
|
+
* Check if incus is available and accessible
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkIncusAvailability(): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Get incus version information
|
|
15
|
+
*/
|
|
16
|
+
export declare function getIncusVersion(): Promise<string>;
|
|
17
|
+
//# sourceMappingURL=incus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incus.d.ts","sourceRoot":"","sources":["../src/incus.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BtE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAM3D;AAED;;GAEG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAMvD"}
|
package/build/incus.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Execute an incus command and return the output
|
|
4
|
+
*/
|
|
5
|
+
export async function execIncusCommand(args) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const child = spawn('incus', args, {
|
|
8
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
9
|
+
env: { ...process.env },
|
|
10
|
+
});
|
|
11
|
+
let stdout = '';
|
|
12
|
+
let stderr = '';
|
|
13
|
+
child.stdout?.on('data', (data) => {
|
|
14
|
+
stdout += data.toString();
|
|
15
|
+
});
|
|
16
|
+
child.stderr?.on('data', (data) => {
|
|
17
|
+
stderr += data.toString();
|
|
18
|
+
});
|
|
19
|
+
child.on('close', (code) => {
|
|
20
|
+
if (code === 0) {
|
|
21
|
+
resolve(stdout.trim());
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
reject(new Error(`Incus command failed (exit code ${code}): ${stderr || stdout}`));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
child.on('error', (error) => {
|
|
28
|
+
reject(new Error(`Failed to execute incus command: ${error.message}`));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse incus JSON output safely
|
|
34
|
+
*/
|
|
35
|
+
export function parseIncusOutput(output) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(output);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Error(`Failed to parse incus output as JSON: ${error}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if incus is available and accessible
|
|
45
|
+
*/
|
|
46
|
+
export async function checkIncusAvailability() {
|
|
47
|
+
try {
|
|
48
|
+
await execIncusCommand(['version']);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get incus version information
|
|
57
|
+
*/
|
|
58
|
+
export async function getIncusVersion() {
|
|
59
|
+
try {
|
|
60
|
+
return await execIncusCommand(['version']);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
throw new Error(`Failed to get incus version: ${error}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=incus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incus.js","sourceRoot":"","sources":["../src/incus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAc;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,K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