@prmichaelsen/acp-mcp 0.2.0 → 0.3.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/CHANGELOG.md +26 -0
- package/README.md +20 -0
- package/agent/design/acp-mcp-core-tools.md +382 -0
- package/agent/milestones/milestone-1-core-tools-implementation.md +50 -0
- package/agent/progress.yaml +86 -15
- package/agent/tasks/milestone-1-core-tools-implementation/task-1-implement-acp-remote-execute-command.md +149 -0
- package/agent/tasks/milestone-1-core-tools-implementation/task-2-implement-acp-remote-read-file.md +152 -0
- package/agent/tasks/milestone-1-core-tools-implementation/task-3-implement-acp-remote-write-file.md +165 -0
- package/dist/server-factory.js +329 -1
- package/dist/server-factory.js.map +4 -4
- package/dist/server.js +329 -1
- package/dist/server.js.map +4 -4
- package/dist/tools/acp-remote-execute-command.d.ts +16 -0
- package/dist/tools/acp-remote-read-file.d.ts +16 -0
- package/dist/tools/acp-remote-write-file.d.ts +16 -0
- package/dist/utils/ssh-connection.d.ts +29 -0
- package/package.json +1 -1
- package/src/server-factory.ts +13 -1
- package/src/server.ts +13 -1
- package/src/tools/acp-remote-execute-command.ts +92 -0
- package/src/tools/acp-remote-read-file.ts +88 -0
- package/src/tools/acp-remote-write-file.ts +101 -0
- package/src/utils/ssh-connection.ts +170 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Task 1: Implement acp_remote_execute_command Tool
|
|
2
|
+
|
|
3
|
+
**Milestone**: Milestone 1 - Core Tools Implementation
|
|
4
|
+
**Estimated Time**: 3-4 hours
|
|
5
|
+
**Dependencies**: None (SSH infrastructure complete)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Priority**: High (Most versatile tool)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Objective
|
|
12
|
+
|
|
13
|
+
Implement the `acp_remote_execute_command` tool to execute arbitrary shell commands on remote machines via SSH. This is the most important tool as it enables git operations, npm commands, and any other CLI operations users need.
|
|
14
|
+
|
|
15
|
+
## Context
|
|
16
|
+
|
|
17
|
+
**Design Reference**: See [`agent/design/acp-mcp-core-tools.md`](../../design/acp-mcp-core-tools.md#2-acp_remote_execute_command)
|
|
18
|
+
|
|
19
|
+
**Why This Tool**:
|
|
20
|
+
- Most versatile - handles any shell command
|
|
21
|
+
- Enables git operations (status, commit, push)
|
|
22
|
+
- Enables package management (npm, pip, cargo)
|
|
23
|
+
- Enables system operations (ls, pwd, whoami)
|
|
24
|
+
- Replaces need for specialized git tools
|
|
25
|
+
|
|
26
|
+
**Current State**:
|
|
27
|
+
- SSH infrastructure complete (`SSHConnectionManager`)
|
|
28
|
+
- `SSHConnectionManager.exec()` method already exists
|
|
29
|
+
- Just need to create tool wrapper and register it
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Steps
|
|
34
|
+
|
|
35
|
+
### 1. Create Tool File
|
|
36
|
+
|
|
37
|
+
Create `src/tools/acp-remote-execute-command.ts`
|
|
38
|
+
|
|
39
|
+
**Actions**:
|
|
40
|
+
- Define tool schema with MCP Tool interface
|
|
41
|
+
- Input: command (string), cwd (optional string), timeout (optional number)
|
|
42
|
+
- Output: stdout, stderr, exitCode, timedOut
|
|
43
|
+
- Export tool definition and handler function
|
|
44
|
+
|
|
45
|
+
### 2. Implement Handler Function
|
|
46
|
+
|
|
47
|
+
**Actions**:
|
|
48
|
+
- Accept args and SSHConnectionManager
|
|
49
|
+
- Extract command, cwd, timeout from args
|
|
50
|
+
- Handle working directory changes (cd && command)
|
|
51
|
+
- Call `sshConnection.exec()` with timeout
|
|
52
|
+
- Capture stdout, stderr, exit code
|
|
53
|
+
- Handle timeout errors
|
|
54
|
+
- Return formatted response
|
|
55
|
+
|
|
56
|
+
### 3. Add Timeout Support to SSHConnectionManager
|
|
57
|
+
|
|
58
|
+
**Actions**:
|
|
59
|
+
- Update `SSHConnectionManager.exec()` to support timeout parameter
|
|
60
|
+
- Implement timeout logic with Promise.race()
|
|
61
|
+
- Return timedOut flag in response
|
|
62
|
+
|
|
63
|
+
### 4. Register Tool in Servers
|
|
64
|
+
|
|
65
|
+
**Actions**:
|
|
66
|
+
- Import tool in `src/server.ts`
|
|
67
|
+
- Add to ListToolsRequestSchema handler
|
|
68
|
+
- Add case to CallToolRequestSchema handler
|
|
69
|
+
- Repeat for `src/server-factory.ts`
|
|
70
|
+
|
|
71
|
+
### 5. Update Documentation
|
|
72
|
+
|
|
73
|
+
**Actions**:
|
|
74
|
+
- Add tool to README.md Available Tools section
|
|
75
|
+
- Include example usage
|
|
76
|
+
- Document parameters and output
|
|
77
|
+
|
|
78
|
+
### 6. Test Tool
|
|
79
|
+
|
|
80
|
+
**Actions**:
|
|
81
|
+
- Build project (`npm run build`)
|
|
82
|
+
- Test TypeScript compilation
|
|
83
|
+
- Manual test with simple command (e.g., `pwd`)
|
|
84
|
+
- Test with working directory
|
|
85
|
+
- Test timeout behavior
|
|
86
|
+
- Test error handling
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Verification
|
|
91
|
+
|
|
92
|
+
- [ ] Tool file created with proper schema
|
|
93
|
+
- [ ] Handler function implemented
|
|
94
|
+
- [ ] Timeout support added to SSHConnectionManager
|
|
95
|
+
- [ ] Tool registered in both server files
|
|
96
|
+
- [ ] README.md updated
|
|
97
|
+
- [ ] TypeScript compiles without errors
|
|
98
|
+
- [ ] Build completes successfully
|
|
99
|
+
- [ ] Manual testing successful
|
|
100
|
+
- [ ] Error handling works correctly
|
|
101
|
+
- [ ] Timeout behavior works correctly
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Expected Output
|
|
106
|
+
|
|
107
|
+
### Files Created
|
|
108
|
+
- `src/tools/acp-remote-execute-command.ts`
|
|
109
|
+
|
|
110
|
+
### Files Modified
|
|
111
|
+
- `src/utils/ssh-connection.ts` (timeout support)
|
|
112
|
+
- `src/server.ts` (tool registration)
|
|
113
|
+
- `src/server-factory.ts` (tool registration)
|
|
114
|
+
- `README.md` (documentation)
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Example Implementation
|
|
119
|
+
|
|
120
|
+
**Tool Schema**:
|
|
121
|
+
```typescript
|
|
122
|
+
export const acpRemoteExecuteCommandTool: Tool = {
|
|
123
|
+
name: 'acp_remote_execute_command',
|
|
124
|
+
description: 'Execute a shell command on the remote machine via SSH',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
command: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
description: 'Shell command to execute',
|
|
131
|
+
},
|
|
132
|
+
cwd: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'Working directory (optional)',
|
|
135
|
+
},
|
|
136
|
+
timeout: {
|
|
137
|
+
type: 'number',
|
|
138
|
+
description: 'Timeout in seconds (default: 30)',
|
|
139
|
+
default: 30,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
required: ['command'],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
**Next Task**: [Task 2: Implement acp_remote_read_file](task-2-implement-acp-remote-read-file.md)
|
package/agent/tasks/milestone-1-core-tools-implementation/task-2-implement-acp-remote-read-file.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Task 2: Implement acp_remote_read_file Tool
|
|
2
|
+
|
|
3
|
+
**Milestone**: Milestone 1 - Core Tools Implementation
|
|
4
|
+
**Estimated Time**: 2-3 hours
|
|
5
|
+
**Dependencies**: None (SSH infrastructure complete)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Priority**: Medium
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Objective
|
|
12
|
+
|
|
13
|
+
Implement the `acp_remote_read_file` tool to read file contents from remote machines via SSH. Essential for viewing remote files, code review, and debugging.
|
|
14
|
+
|
|
15
|
+
## Context
|
|
16
|
+
|
|
17
|
+
**Design Reference**: See [`agent/design/acp-mcp-core-tools.md`](../../design/acp-mcp-core-tools.md#3-acp_remote_read_file)
|
|
18
|
+
|
|
19
|
+
**Why This Tool**:
|
|
20
|
+
- View remote file contents
|
|
21
|
+
- Code review and debugging
|
|
22
|
+
- Read configuration files
|
|
23
|
+
- Inspect logs
|
|
24
|
+
|
|
25
|
+
**Current State**:
|
|
26
|
+
- SSH infrastructure complete (`SSHConnectionManager`)
|
|
27
|
+
- SFTP support available via `getSFTP()`
|
|
28
|
+
- Need to create tool wrapper
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Steps
|
|
33
|
+
|
|
34
|
+
### 1. Create Tool File
|
|
35
|
+
|
|
36
|
+
Create `src/tools/acp-remote-read-file.ts`
|
|
37
|
+
|
|
38
|
+
**Actions**:
|
|
39
|
+
- Define tool schema with MCP Tool interface
|
|
40
|
+
- Input: path (string), encoding (optional), maxSize (optional)
|
|
41
|
+
- Output: content, size, encoding
|
|
42
|
+
- Export tool definition and handler function
|
|
43
|
+
|
|
44
|
+
### 2. Implement Handler Function
|
|
45
|
+
|
|
46
|
+
**Actions**:
|
|
47
|
+
- Accept args and SSHConnectionManager
|
|
48
|
+
- Extract path, encoding, maxSize from args
|
|
49
|
+
- Get SFTP connection
|
|
50
|
+
- Check file exists and get stats
|
|
51
|
+
- Validate file size (default max: 1MB)
|
|
52
|
+
- Read file contents
|
|
53
|
+
- Handle encoding (utf-8, ascii, base64)
|
|
54
|
+
- Return formatted response with content, size, encoding
|
|
55
|
+
|
|
56
|
+
### 3. Add SFTP Read Helper to SSHConnectionManager
|
|
57
|
+
|
|
58
|
+
**Actions**:
|
|
59
|
+
- Add `readFile(path, encoding, maxSize)` method
|
|
60
|
+
- Use SFTP to read file
|
|
61
|
+
- Return file contents and metadata
|
|
62
|
+
|
|
63
|
+
### 4. Register Tool in Servers
|
|
64
|
+
|
|
65
|
+
**Actions**:
|
|
66
|
+
- Import tool in `src/server.ts`
|
|
67
|
+
- Add to ListToolsRequestSchema handler
|
|
68
|
+
- Add case to CallToolRequestSchema handler
|
|
69
|
+
- Repeat for `src/server-factory.ts`
|
|
70
|
+
|
|
71
|
+
### 5. Update Documentation
|
|
72
|
+
|
|
73
|
+
**Actions**:
|
|
74
|
+
- Add tool to README.md Available Tools section
|
|
75
|
+
- Include example usage
|
|
76
|
+
- Document parameters and output
|
|
77
|
+
- Note file size limits
|
|
78
|
+
|
|
79
|
+
### 6. Test Tool
|
|
80
|
+
|
|
81
|
+
**Actions**:
|
|
82
|
+
- Build project (`npm run build`)
|
|
83
|
+
- Test TypeScript compilation
|
|
84
|
+
- Test reading text file
|
|
85
|
+
- Test file size limit
|
|
86
|
+
- Test non-existent file error
|
|
87
|
+
- Test permission denied error
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Verification
|
|
92
|
+
|
|
93
|
+
- [ ] Tool file created with proper schema
|
|
94
|
+
- [ ] Handler function implemented
|
|
95
|
+
- [ ] SFTP read helper added to SSHConnectionManager
|
|
96
|
+
- [ ] Tool registered in both server files
|
|
97
|
+
- [ ] README.md updated
|
|
98
|
+
- [ ] TypeScript compiles without errors
|
|
99
|
+
- [ ] Build completes successfully
|
|
100
|
+
- [ ] Can read text files
|
|
101
|
+
- [ ] File size limit enforced
|
|
102
|
+
- [ ] Error handling works correctly
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Expected Output
|
|
107
|
+
|
|
108
|
+
### Files Created
|
|
109
|
+
- `src/tools/acp-remote-read-file.ts`
|
|
110
|
+
|
|
111
|
+
### Files Modified
|
|
112
|
+
- `src/utils/ssh-connection.ts` (readFile helper)
|
|
113
|
+
- `src/server.ts` (tool registration)
|
|
114
|
+
- `src/server-factory.ts` (tool registration)
|
|
115
|
+
- `README.md` (documentation)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Example Implementation
|
|
120
|
+
|
|
121
|
+
**Tool Schema**:
|
|
122
|
+
```typescript
|
|
123
|
+
export const acpRemoteReadFileTool: Tool = {
|
|
124
|
+
name: 'acp_remote_read_file',
|
|
125
|
+
description: 'Read file contents from the remote machine via SSH',
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
path: {
|
|
130
|
+
type: 'string',
|
|
131
|
+
description: 'Absolute path to file',
|
|
132
|
+
},
|
|
133
|
+
encoding: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'File encoding (default: utf-8)',
|
|
136
|
+
default: 'utf-8',
|
|
137
|
+
enum: ['utf-8', 'ascii', 'base64'],
|
|
138
|
+
},
|
|
139
|
+
maxSize: {
|
|
140
|
+
type: 'number',
|
|
141
|
+
description: 'Max file size in bytes (default: 1MB)',
|
|
142
|
+
default: 1048576,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
required: ['path'],
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
**Next Task**: [Task 3: Implement acp_remote_write_file](task-3-implement-acp-remote-write-file.md)
|
package/agent/tasks/milestone-1-core-tools-implementation/task-3-implement-acp-remote-write-file.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Task 3: Implement acp_remote_write_file Tool
|
|
2
|
+
|
|
3
|
+
**Milestone**: Milestone 1 - Core Tools Implementation
|
|
4
|
+
**Estimated Time**: 3-4 hours
|
|
5
|
+
**Dependencies**: None (SSH infrastructure complete)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Priority**: Medium
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Objective
|
|
12
|
+
|
|
13
|
+
Implement the `acp_remote_write_file` tool to write file contents to remote machines via SSH. Completes CRUD operations and enables remote file editing.
|
|
14
|
+
|
|
15
|
+
## Context
|
|
16
|
+
|
|
17
|
+
**Design Reference**: See [`agent/design/acp-mcp-core-tools.md`](../../design/acp-mcp-core-tools.md#4-acp_remote_write_file)
|
|
18
|
+
|
|
19
|
+
**Why This Tool**:
|
|
20
|
+
- Edit remote files
|
|
21
|
+
- Create configuration files
|
|
22
|
+
- Write code changes
|
|
23
|
+
- Update documentation
|
|
24
|
+
|
|
25
|
+
**Current State**:
|
|
26
|
+
- SSH infrastructure complete (`SSHConnectionManager`)
|
|
27
|
+
- SFTP support available via `getSFTP()`
|
|
28
|
+
- Need to create tool wrapper
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Steps
|
|
33
|
+
|
|
34
|
+
### 1. Create Tool File
|
|
35
|
+
|
|
36
|
+
Create `src/tools/acp-remote-write-file.ts`
|
|
37
|
+
|
|
38
|
+
**Actions**:
|
|
39
|
+
- Define tool schema with MCP Tool interface
|
|
40
|
+
- Input: path, content, encoding (optional), createDirs (optional), backup (optional)
|
|
41
|
+
- Output: success, bytesWritten, backupPath (optional)
|
|
42
|
+
- Export tool definition and handler function
|
|
43
|
+
|
|
44
|
+
### 2. Implement Handler Function
|
|
45
|
+
|
|
46
|
+
**Actions**:
|
|
47
|
+
- Accept args and SSHConnectionManager
|
|
48
|
+
- Extract path, content, encoding, createDirs, backup from args
|
|
49
|
+
- Get SFTP connection
|
|
50
|
+
- Optionally backup existing file
|
|
51
|
+
- Optionally create parent directories
|
|
52
|
+
- Write to temp file first (atomic write)
|
|
53
|
+
- Rename temp file to target (atomic operation)
|
|
54
|
+
- Return formatted response
|
|
55
|
+
|
|
56
|
+
### 3. Add SFTP Write Helper to SSHConnectionManager
|
|
57
|
+
|
|
58
|
+
**Actions**:
|
|
59
|
+
- Add `writeFile(path, content, options)` method
|
|
60
|
+
- Support createDirs option (mkdir -p)
|
|
61
|
+
- Support backup option
|
|
62
|
+
- Implement atomic write (temp file + rename)
|
|
63
|
+
- Return bytes written and backup path
|
|
64
|
+
|
|
65
|
+
### 4. Register Tool in Servers
|
|
66
|
+
|
|
67
|
+
**Actions**:
|
|
68
|
+
- Import tool in `src/server.ts`
|
|
69
|
+
- Add to ListToolsRequestSchema handler
|
|
70
|
+
- Add case to CallToolRequestSchema handler
|
|
71
|
+
- Repeat for `src/server-factory.ts`
|
|
72
|
+
|
|
73
|
+
### 5. Update Documentation
|
|
74
|
+
|
|
75
|
+
**Actions**:
|
|
76
|
+
- Add tool to README.md Available Tools section
|
|
77
|
+
- Include example usage
|
|
78
|
+
- Document parameters and output
|
|
79
|
+
- Note security considerations
|
|
80
|
+
|
|
81
|
+
### 6. Test Tool
|
|
82
|
+
|
|
83
|
+
**Actions**:
|
|
84
|
+
- Build project (`npm run build`)
|
|
85
|
+
- Test TypeScript compilation
|
|
86
|
+
- Test writing new file
|
|
87
|
+
- Test overwriting existing file
|
|
88
|
+
- Test backup functionality
|
|
89
|
+
- Test createDirs functionality
|
|
90
|
+
- Test permission denied error
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Verification
|
|
95
|
+
|
|
96
|
+
- [ ] Tool file created with proper schema
|
|
97
|
+
- [ ] Handler function implemented
|
|
98
|
+
- [ ] SFTP write helper added to SSHConnectionManager
|
|
99
|
+
- [ ] Atomic write implemented (temp + rename)
|
|
100
|
+
- [ ] Backup functionality works
|
|
101
|
+
- [ ] Create directories functionality works
|
|
102
|
+
- [ ] Tool registered in both server files
|
|
103
|
+
- [ ] README.md updated
|
|
104
|
+
- [ ] TypeScript compiles without errors
|
|
105
|
+
- [ ] Build completes successfully
|
|
106
|
+
- [ ] Can write files
|
|
107
|
+
- [ ] Error handling works correctly
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Expected Output
|
|
112
|
+
|
|
113
|
+
### Files Created
|
|
114
|
+
- `src/tools/acp-remote-write-file.ts`
|
|
115
|
+
|
|
116
|
+
### Files Modified
|
|
117
|
+
- `src/utils/ssh-connection.ts` (writeFile helper)
|
|
118
|
+
- `src/server.ts` (tool registration)
|
|
119
|
+
- `src/server-factory.ts` (tool registration)
|
|
120
|
+
- `README.md` (documentation)
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Example Implementation
|
|
125
|
+
|
|
126
|
+
**Tool Schema**:
|
|
127
|
+
```typescript
|
|
128
|
+
export const acpRemoteWriteFileTool: Tool = {
|
|
129
|
+
name: 'acp_remote_write_file',
|
|
130
|
+
description: 'Write file contents to the remote machine via SSH',
|
|
131
|
+
inputSchema: {
|
|
132
|
+
type: 'object',
|
|
133
|
+
properties: {
|
|
134
|
+
path: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
description: 'Absolute path to file',
|
|
137
|
+
},
|
|
138
|
+
content: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'File contents to write',
|
|
141
|
+
},
|
|
142
|
+
encoding: {
|
|
143
|
+
type: 'string',
|
|
144
|
+
description: 'File encoding (default: utf-8)',
|
|
145
|
+
default: 'utf-8',
|
|
146
|
+
},
|
|
147
|
+
createDirs: {
|
|
148
|
+
type: 'boolean',
|
|
149
|
+
description: 'Create parent directories (default: false)',
|
|
150
|
+
default: false,
|
|
151
|
+
},
|
|
152
|
+
backup: {
|
|
153
|
+
type: 'boolean',
|
|
154
|
+
description: 'Backup existing file (default: false)',
|
|
155
|
+
default: false,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
required: ['path', 'content'],
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
**Next Task**: Version bump and deployment preparation
|