@reidar80/webshelf-mcp 0.1.0 → 0.2.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/dist/api.d.ts +5 -2
- package/dist/api.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -12
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ApiFile {
|
|
|
12
12
|
collectionId: string | null;
|
|
13
13
|
ownerId: string;
|
|
14
14
|
protection: "public" | "authenticated" | "inherit" | "individual";
|
|
15
|
+
format: "html" | "markdown";
|
|
15
16
|
sizeBytes: number;
|
|
16
17
|
createdAt: string;
|
|
17
18
|
updatedAt: string;
|
|
@@ -52,14 +53,16 @@ export interface ApiClient {
|
|
|
52
53
|
}>;
|
|
53
54
|
getFileContent(id: string): Promise<{
|
|
54
55
|
name: string;
|
|
55
|
-
|
|
56
|
+
content: string;
|
|
57
|
+
format: ApiFile["format"];
|
|
56
58
|
}>;
|
|
57
59
|
createFile(input: {
|
|
58
60
|
name: string;
|
|
59
61
|
description?: string | null;
|
|
60
62
|
collectionId: string | null;
|
|
61
63
|
protection?: ApiFile["protection"];
|
|
62
|
-
|
|
64
|
+
format?: ApiFile["format"];
|
|
65
|
+
content: string;
|
|
63
66
|
}): Promise<{
|
|
64
67
|
file: ApiFile;
|
|
65
68
|
}>;
|
package/dist/api.js
CHANGED
|
@@ -61,8 +61,8 @@ export function createApiClient(options) {
|
|
|
61
61
|
getFile: (id) => request("GET", `/api/v1/files/${id}`),
|
|
62
62
|
getFileContent: async (id) => {
|
|
63
63
|
const json = await request("GET", `/api/v1/files/${id}/content?as=base64`);
|
|
64
|
-
const
|
|
65
|
-
return { name: json.name,
|
|
64
|
+
const content = Buffer.from(json.contentBase64, "base64").toString("utf8");
|
|
65
|
+
return { name: json.name, content, format: json.format };
|
|
66
66
|
},
|
|
67
67
|
createFile: (input) => request("POST", "/api/v1/files", input),
|
|
68
68
|
updateFile: (id, input) => request("PATCH", `/api/v1/files/${id}`, input),
|
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* webshelf_list_collections — list collections the caller can write to
|
|
18
18
|
* webshelf_list_files — list files (own / by collection)
|
|
19
19
|
* webshelf_get_file — metadata for a single file
|
|
20
|
-
* webshelf_read_file — fetch HTML
|
|
21
|
-
* webshelf_create_file — upload a new HTML file
|
|
20
|
+
* webshelf_read_file — fetch file contents (HTML or markdown)
|
|
21
|
+
* webshelf_create_file — upload a new HTML or markdown file
|
|
22
22
|
* webshelf_update_file — rename / move / re-describe
|
|
23
23
|
* webshelf_delete_file — soft-delete a file (recycle bin)
|
|
24
24
|
*/
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* webshelf_list_collections — list collections the caller can write to
|
|
18
18
|
* webshelf_list_files — list files (own / by collection)
|
|
19
19
|
* webshelf_get_file — metadata for a single file
|
|
20
|
-
* webshelf_read_file — fetch HTML
|
|
21
|
-
* webshelf_create_file — upload a new HTML file
|
|
20
|
+
* webshelf_read_file — fetch file contents (HTML or markdown)
|
|
21
|
+
* webshelf_create_file — upload a new HTML or markdown file
|
|
22
22
|
* webshelf_update_file — rename / move / re-describe
|
|
23
23
|
* webshelf_delete_file — soft-delete a file (recycle bin)
|
|
24
24
|
*/
|
|
@@ -84,7 +84,7 @@ const tools = [
|
|
|
84
84
|
.parse(input ?? {});
|
|
85
85
|
const { files, nextCursor } = await client.listFiles(parsed);
|
|
86
86
|
const body = files
|
|
87
|
-
.map((f) => `${f.id} ${JSON.stringify(f.name)} collection=${f.collectionId ?? "(personal)"} ${formatBytes(f.sizeBytes)} ${f.protection} updated=${f.updatedAt}`)
|
|
87
|
+
.map((f) => `${f.id} ${JSON.stringify(f.name)} format=${f.format} collection=${f.collectionId ?? "(personal)"} ${formatBytes(f.sizeBytes)} ${f.protection} updated=${f.updatedAt}`)
|
|
88
88
|
.join("\n") || "(no files match)";
|
|
89
89
|
return text(nextCursor ? `${body}\n\nnextCursor=${nextCursor}` : body);
|
|
90
90
|
},
|
|
@@ -108,7 +108,7 @@ const tools = [
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
name: "webshelf_read_file",
|
|
111
|
-
description: "Return the
|
|
111
|
+
description: "Return the contents of a file by id. Returns the raw source — HTML for `format=html` files, markdown for `format=markdown` files. The response is a text block; the MCP client can save it, render it, or feed it back into a tool call.",
|
|
112
112
|
inputSchema: {
|
|
113
113
|
type: "object",
|
|
114
114
|
additionalProperties: false,
|
|
@@ -119,17 +119,18 @@ const tools = [
|
|
|
119
119
|
},
|
|
120
120
|
handler: async (input) => {
|
|
121
121
|
const { id } = z.object({ id: z.string().uuid() }).parse(input);
|
|
122
|
-
const {
|
|
123
|
-
|
|
122
|
+
const { content, name, format } = await client.getFileContent(id);
|
|
123
|
+
const ext = format === "markdown" ? "md" : "html";
|
|
124
|
+
return text(`Filename: ${name}.${ext}\nFormat: ${format}\n\n${content}`);
|
|
124
125
|
},
|
|
125
126
|
},
|
|
126
127
|
{
|
|
127
128
|
name: "webshelf_create_file",
|
|
128
|
-
description: "Upload a new
|
|
129
|
+
description: "Upload a new file. `format` may be \"html\" (default) or \"markdown\"; pass the bytes in `content`. Set collectionId to a uuid to place inside a collection (caller must be owner/manager), or null for a standalone personal file. Returns the created file's metadata.",
|
|
129
130
|
inputSchema: {
|
|
130
131
|
type: "object",
|
|
131
132
|
additionalProperties: false,
|
|
132
|
-
required: ["name", "
|
|
133
|
+
required: ["name", "content"],
|
|
133
134
|
properties: {
|
|
134
135
|
name: { type: "string", minLength: 1, maxLength: 200 },
|
|
135
136
|
description: { type: "string", maxLength: 2000 },
|
|
@@ -138,7 +139,8 @@ const tools = [
|
|
|
138
139
|
type: "string",
|
|
139
140
|
enum: ["public", "authenticated", "inherit", "individual"],
|
|
140
141
|
},
|
|
141
|
-
|
|
142
|
+
format: { type: "string", enum: ["html", "markdown"] },
|
|
143
|
+
content: { type: "string" },
|
|
142
144
|
},
|
|
143
145
|
},
|
|
144
146
|
handler: async (input) => {
|
|
@@ -150,11 +152,12 @@ const tools = [
|
|
|
150
152
|
protection: z
|
|
151
153
|
.enum(["public", "authenticated", "inherit", "individual"])
|
|
152
154
|
.optional(),
|
|
153
|
-
|
|
155
|
+
format: z.enum(["html", "markdown"]).optional(),
|
|
156
|
+
content: z.string().min(1),
|
|
154
157
|
})
|
|
155
158
|
.parse(input);
|
|
156
159
|
const { file } = await client.createFile(parsed);
|
|
157
|
-
return text(`Created file ${file.id} (${file.name}) — ${formatBytes(file.sizeBytes)}\n${BASE_URL}/app/files/${file.id}`);
|
|
160
|
+
return text(`Created ${file.format} file ${file.id} (${file.name}) — ${formatBytes(file.sizeBytes)}\n${BASE_URL}/app/files/${file.id}`);
|
|
158
161
|
},
|
|
159
162
|
},
|
|
160
163
|
{
|
|
@@ -203,7 +206,7 @@ const tools = [
|
|
|
203
206
|
];
|
|
204
207
|
const server = new Server({
|
|
205
208
|
name: "@reidar80/webshelf-mcp",
|
|
206
|
-
version: "0.
|
|
209
|
+
version: "0.2.0",
|
|
207
210
|
}, {
|
|
208
211
|
capabilities: {
|
|
209
212
|
tools: {},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reidar80/webshelf-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Model Context Protocol server for Webshelf — list, read, upload and manage HTML files hosted on webshelf.app from any MCP-aware client.",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Model Context Protocol server for Webshelf — list, read, upload and manage HTML and markdown files hosted on webshelf.app from any MCP-aware client.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
7
7
|
"model-context-protocol",
|