-
Notifications
You must be signed in to change notification settings - Fork 300
Expand file tree
/
Copy pathfile.js
More file actions
50 lines (46 loc) · 1.18 KB
/
file.js
File metadata and controls
50 lines (46 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import apiClient from './client'
export const fileApi = {
// List directory via MCP
async listDirectory(path = '.') {
const response = await apiClient.post('/admin/mcp', {
name: 'list_directory',
arguments: { path }
})
// MCP returns array format, convert to {files: [...]}
if (Array.isArray(response)) {
return {
files: response.map(f => ({
name: f.name,
path: path === '.' ? f.name : `${path}/${f.name}`.replace(/^\.\//, ''),
isDirectory: f.isDirectory,
size: f.size
}))
}
}
return response
},
// Read file via MCP
async readFile(path) {
const response = await apiClient.post('/admin/mcp', {
name: 'read_file',
arguments: { path }
})
return response
},
// Write file via MCP
async writeFile(path, content) {
const response = await apiClient.post('/admin/mcp', {
name: 'write_file',
arguments: { path, content }
})
return response
},
// Delete file via MCP
async deleteFile(path) {
const response = await apiClient.post('/admin/mcp', {
name: 'delete_file',
arguments: { path }
})
return response
}
}