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.
Files changed (2) hide show
  1. package/dist/index.js +32 -41
  2. 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.union([
105
- z.object({
106
- ok: z.literal(true),
107
- entries: z.array(z.object({
108
- name: z.string(),
109
- type: z.enum(["file", "dir"]),
110
- size: z.number().optional(),
111
- mtimeMs: z.number(),
112
- })),
113
- }),
114
- errorSchema,
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.union([
137
- z.object({
138
- ok: z.literal(true),
139
- }),
140
- errorSchema,
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.union([
154
- z.object({
155
- ok: z.literal(true),
156
- remote_path: z.string(),
157
- local_path: z.string(),
158
- size: z.number(),
159
- }),
160
- errorSchema,
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.union([
210
- z.object({
211
- ok: z.literal(true),
212
- remote_path: z.string(),
213
- local_path: z.string(),
214
- size: z.number(),
215
- }),
216
- errorSchema,
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-file-adapter",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Local MCP stdio adapter for remote file service.",
5
5
  "license": "MIT",
6
6
  "type": "module",