mcp-file-adapter 0.1.0 → 0.1.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.
- package/dist/index.js +32 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91,28 +91,22 @@ function createServer() {
|
|
|
91
91
|
name: "mcp-file-adapter",
|
|
92
92
|
version: "0.1.0",
|
|
93
93
|
});
|
|
94
|
-
const errorSchema = z.object({
|
|
95
|
-
ok: z.literal(false),
|
|
96
|
-
error: z.string(),
|
|
97
|
-
code: z.string().optional(),
|
|
98
|
-
});
|
|
99
94
|
server.registerTool("list_files", {
|
|
100
95
|
description: "列出远程目录下的条目;返回 name/type/size/mtimeMs。",
|
|
101
96
|
inputSchema: z.object({
|
|
102
97
|
path: z.string(),
|
|
103
98
|
}),
|
|
104
|
-
outputSchema: z.
|
|
105
|
-
z.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
]),
|
|
99
|
+
outputSchema: z.object({
|
|
100
|
+
ok: z.boolean(),
|
|
101
|
+
entries: z.array(z.object({
|
|
102
|
+
name: z.string(),
|
|
103
|
+
type: z.enum(["file", "dir"]),
|
|
104
|
+
size: z.number().optional(),
|
|
105
|
+
mtimeMs: z.number(),
|
|
106
|
+
})).optional(),
|
|
107
|
+
error: z.string().optional(),
|
|
108
|
+
code: z.string().optional(),
|
|
109
|
+
}),
|
|
116
110
|
}, async ({ path: relPath }) => {
|
|
117
111
|
const url = buildUrl("/list", { path: relPath });
|
|
118
112
|
const res = await fetchWithTimeout(url, {
|
|
@@ -133,12 +127,11 @@ function createServer() {
|
|
|
133
127
|
path: z.string(),
|
|
134
128
|
recursive: z.boolean().optional(),
|
|
135
129
|
}),
|
|
136
|
-
outputSchema: z.
|
|
137
|
-
z.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
]),
|
|
130
|
+
outputSchema: z.object({
|
|
131
|
+
ok: z.boolean(),
|
|
132
|
+
error: z.string().optional(),
|
|
133
|
+
code: z.string().optional(),
|
|
134
|
+
}),
|
|
142
135
|
}, async ({ path: relPath, recursive }) => {
|
|
143
136
|
return postJson("/mkdir", { path: relPath, recursive: recursive ?? true });
|
|
144
137
|
});
|
|
@@ -150,15 +143,14 @@ function createServer() {
|
|
|
150
143
|
overwrite: z.boolean().optional(),
|
|
151
144
|
mkdirs: z.boolean().optional(),
|
|
152
145
|
}),
|
|
153
|
-
outputSchema: z.
|
|
154
|
-
z.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
]),
|
|
146
|
+
outputSchema: z.object({
|
|
147
|
+
ok: z.boolean(),
|
|
148
|
+
remote_path: z.string().optional(),
|
|
149
|
+
local_path: z.string().optional(),
|
|
150
|
+
size: z.number().optional(),
|
|
151
|
+
error: z.string().optional(),
|
|
152
|
+
code: z.string().optional(),
|
|
153
|
+
}),
|
|
162
154
|
}, async ({ local_path: localPath, remote_path: remotePath, overwrite, mkdirs, }) => {
|
|
163
155
|
try {
|
|
164
156
|
const localFull = resolveLocalPath(localPath);
|
|
@@ -206,15 +198,14 @@ function createServer() {
|
|
|
206
198
|
overwrite: z.boolean().optional(),
|
|
207
199
|
mkdirs: z.boolean().optional(),
|
|
208
200
|
}),
|
|
209
|
-
outputSchema: z.
|
|
210
|
-
z.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
]),
|
|
201
|
+
outputSchema: z.object({
|
|
202
|
+
ok: z.boolean(),
|
|
203
|
+
remote_path: z.string().optional(),
|
|
204
|
+
local_path: z.string().optional(),
|
|
205
|
+
size: z.number().optional(),
|
|
206
|
+
error: z.string().optional(),
|
|
207
|
+
code: z.string().optional(),
|
|
208
|
+
}),
|
|
218
209
|
}, async ({ remote_path: remotePath, local_path: localPath, overwrite, mkdirs, }) => {
|
|
219
210
|
try {
|
|
220
211
|
const localFull = resolveLocalPath(localPath);
|