brewpage-mcp 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Maksim Kochetkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # brewpage-mcp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/brewpage-mcp.svg)](https://www.npmjs.com/package/brewpage-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ MCP server for [BrewPage](https://brewpage.app) -- publish and manage HTML, KV, JSON, and file content directly from AI assistants.
7
+
8
+ ## Quick Start
9
+
10
+ ```bash
11
+ npx brewpage-mcp
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ ### Claude Desktop
17
+
18
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "brewpage": {
24
+ "command": "npx",
25
+ "args": ["-y", "brewpage-mcp"]
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### Claude Code
32
+
33
+ Add to `~/.claude/settings.json`:
34
+
35
+ ```json
36
+ {
37
+ "mcpServers": {
38
+ "brewpage": {
39
+ "command": "npx",
40
+ "args": ["-y", "brewpage-mcp"]
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### Global Install
47
+
48
+ ```bash
49
+ npm install -g brewpage-mcp
50
+ brewpage-mcp
51
+ ```
52
+
53
+ ## Tools
54
+
55
+ | Tool | Description |
56
+ |------|-------------|
57
+ | `publish_html` | Publish HTML or Markdown content -> URL + owner token |
58
+ | `publish_file` | Upload file from URL -> URL + owner token |
59
+ | `delete_resource` | Delete resource with owner token |
60
+ | `get_page` | Fetch published page content |
61
+ | `get_stats` | Platform-wide statistics |
62
+
63
+ ## Usage Examples
64
+
65
+ Ask Claude:
66
+
67
+ - *"Publish this HTML to BrewPage"* -> Creates a page, returns public URL
68
+ - *"Create a BrewPage with my meeting notes in Markdown"* -> Markdown page
69
+ - *"Upload this image to BrewPage"* -> File upload
70
+ - *"Delete my page demo/abc123, token tok_xyz"* -> Deletes resource
71
+ - *"Show BrewPage stats"* -> Platform statistics
72
+
73
+ ## Owner Token
74
+
75
+ Every publish response includes an **owner token** -- the only way to update or delete your content. **Save it! It cannot be recovered.**
76
+
77
+ ## Configuration
78
+
79
+ | Variable | Default | Description |
80
+ |----------|---------|-------------|
81
+ | `BREWPAGE_URL` | `https://brewpage.app` | API base URL |
82
+
83
+ ## What is BrewPage?
84
+
85
+ [BrewPage](https://brewpage.app) is a free content hosting platform. No signup required.
86
+
87
+ - **HTML/Markdown pages** with instant short URLs
88
+ - **Key-value store** (1,000 keys per store)
89
+ - **JSON documents** (10,000 per collection)
90
+ - **File hosting** (5 MB per file)
91
+
92
+ Both [brewpage.app](https://brewpage.app) and [brewdata.app](https://brewdata.app) serve the same API.
93
+
94
+ ## Links
95
+
96
+ - [brewpage.app](https://brewpage.app) -- Live platform
97
+ - [API Documentation](https://kochetkov-ma.github.io/brewpage-openapi/) -- Interactive docs
98
+ - [API Reference](https://kochetkov-ma.github.io/brewpage-openapi/api-reference/) -- Scalar API explorer
99
+ - [OpenAPI Spec](https://github.com/kochetkov-ma/brewpage-openapi/blob/main/openapi/openapi.yaml) -- Full specification
100
+ - [Claude Skill](https://github.com/kochetkov-ma/claude-brewcode/tree/main/skills/brewpage-publish) -- `/brewpage` command
101
+ - [Brewcode Plugin](https://github.com/kochetkov-ma/claude-brewcode) -- Claude Code plugin suite
102
+
103
+ ## License
104
+
105
+ [MIT](LICENSE)
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,239 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { z } from "zod";
5
+ const BASE_URL = process.env.BREWPAGE_URL || "https://brewpage.app";
6
+ const server = new McpServer({
7
+ name: "brewpage-mcp",
8
+ version: "1.0.0",
9
+ });
10
+ async function apiRequest(method, path, body, headers) {
11
+ const url = `${BASE_URL}${path}`;
12
+ const res = await fetch(url, {
13
+ method,
14
+ headers: {
15
+ "Content-Type": "application/json",
16
+ ...headers,
17
+ },
18
+ body: body ? JSON.stringify(body) : undefined,
19
+ });
20
+ const data = await res.json().catch(() => null);
21
+ return { ok: res.ok, status: res.status, data };
22
+ }
23
+ function formatPublishResponse(data) {
24
+ const lines = [
25
+ `Published successfully!`,
26
+ ``,
27
+ `URL: ${data.url || "N/A"}`,
28
+ ];
29
+ if (data.shortUrl)
30
+ lines.push(`Short URL: ${data.shortUrl}`);
31
+ lines.push(`Namespace: ${data.namespace || "N/A"}`, `ID: ${data.id || "N/A"}`);
32
+ if (data.expiresAt)
33
+ lines.push(`Expires: ${data.expiresAt}`);
34
+ lines.push(``, `===================================`, `OWNER TOKEN: ${data.ownerToken}`, `===================================`, ``, `IMPORTANT: Save your owner token! You need it to update or delete this resource later. It cannot be recovered if lost.`);
35
+ return lines.join("\n");
36
+ }
37
+ server.tool("publish_html", "Publish HTML or Markdown content to BrewPage. Returns a public URL and owner token. Supports password protection and custom TTL.", {
38
+ content: z.string().describe("HTML or Markdown content to publish"),
39
+ format: z
40
+ .enum(["HTML", "MARKDOWN"])
41
+ .default("HTML")
42
+ .describe("Content format: HTML or MARKDOWN"),
43
+ namespace: z
44
+ .string()
45
+ .optional()
46
+ .describe("Namespace for the page (optional, defaults to 'public')"),
47
+ password: z
48
+ .string()
49
+ .optional()
50
+ .describe("Optional password to protect the page"),
51
+ ttlDays: z
52
+ .number()
53
+ .min(30)
54
+ .max(365)
55
+ .optional()
56
+ .describe("Time to live in days (30-365, default: 365)"),
57
+ }, async ({ content, format, namespace, password, ttlDays }) => {
58
+ const body = { content, format };
59
+ if (namespace)
60
+ body.namespace = namespace;
61
+ if (password)
62
+ body.password = password;
63
+ if (ttlDays)
64
+ body.ttlDays = ttlDays;
65
+ const { ok, data } = await apiRequest("POST", "/api/html", body);
66
+ if (!ok) {
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: `Failed to publish: ${JSON.stringify(data)}`,
72
+ },
73
+ ],
74
+ isError: true,
75
+ };
76
+ }
77
+ return {
78
+ content: [
79
+ {
80
+ type: "text",
81
+ text: formatPublishResponse(data),
82
+ },
83
+ ],
84
+ };
85
+ });
86
+ server.tool("publish_file", "Upload a file to BrewPage via URL. Returns a public URL and owner token.", {
87
+ url: z.string().url().describe("URL of the file to upload"),
88
+ namespace: z
89
+ .string()
90
+ .optional()
91
+ .describe("Namespace for the file (optional, defaults to 'public')"),
92
+ filename: z.string().optional().describe("Custom filename (optional)"),
93
+ }, async ({ url: fileUrl, namespace, filename }) => {
94
+ const fileRes = await fetch(fileUrl);
95
+ if (!fileRes.ok) {
96
+ return {
97
+ content: [
98
+ {
99
+ type: "text",
100
+ text: `Failed to fetch file from URL: ${fileRes.status} ${fileRes.statusText}`,
101
+ },
102
+ ],
103
+ isError: true,
104
+ };
105
+ }
106
+ const blob = await fileRes.blob();
107
+ const formData = new FormData();
108
+ formData.append("file", blob, filename || fileUrl.split("/").pop() || "file");
109
+ if (namespace)
110
+ formData.append("namespace", namespace);
111
+ const res = await fetch(`${BASE_URL}/api/files/uploads`, {
112
+ method: "POST",
113
+ body: formData,
114
+ });
115
+ const data = await res.json().catch(() => null);
116
+ if (!res.ok) {
117
+ return {
118
+ content: [
119
+ {
120
+ type: "text",
121
+ text: `Failed to upload file: ${JSON.stringify(data)}`,
122
+ },
123
+ ],
124
+ isError: true,
125
+ };
126
+ }
127
+ return {
128
+ content: [
129
+ {
130
+ type: "text",
131
+ text: formatPublishResponse(data),
132
+ },
133
+ ],
134
+ };
135
+ });
136
+ server.tool("delete_resource", "Delete a BrewPage resource (HTML page, KV store, JSON collection, or file) using the owner token.", {
137
+ type: z
138
+ .enum(["html", "kv", "json", "file"])
139
+ .describe("Resource type to delete"),
140
+ namespace: z.string().describe("Resource namespace"),
141
+ id: z.string().describe("Resource ID"),
142
+ ownerToken: z
143
+ .string()
144
+ .describe("Owner token received when the resource was created"),
145
+ }, async ({ type, namespace, id, ownerToken }) => {
146
+ const pathMap = {
147
+ html: `/api/html/${namespace}/${id}`,
148
+ kv: `/api/kv/${namespace}/${id}`,
149
+ json: `/api/json/${namespace}/${id}`,
150
+ file: `/api/files/${namespace}/${id}`,
151
+ };
152
+ const { ok, status, data } = await apiRequest("DELETE", pathMap[type], undefined, { "X-Owner-Token": ownerToken });
153
+ if (!ok) {
154
+ return {
155
+ content: [
156
+ {
157
+ type: "text",
158
+ text: `Failed to delete (${status}): ${JSON.stringify(data)}`,
159
+ },
160
+ ],
161
+ isError: true,
162
+ };
163
+ }
164
+ return {
165
+ content: [
166
+ {
167
+ type: "text",
168
+ text: `Successfully deleted ${type} resource: ${namespace}/${id}`,
169
+ },
170
+ ],
171
+ };
172
+ });
173
+ server.tool("get_page", "Fetch a published BrewPage HTML page content by namespace and ID.", {
174
+ namespace: z.string().describe("Page namespace"),
175
+ id: z.string().describe("Page ID"),
176
+ password: z
177
+ .string()
178
+ .optional()
179
+ .describe("Password if the page is protected"),
180
+ }, async ({ namespace, id, password }) => {
181
+ const headers = {};
182
+ if (password)
183
+ headers["X-Password"] = password;
184
+ const { ok, status, data } = await apiRequest("GET", `/api/html/${namespace}/${id}`, undefined, headers);
185
+ if (!ok) {
186
+ return {
187
+ content: [
188
+ {
189
+ type: "text",
190
+ text: `Failed to fetch page (${status}): ${JSON.stringify(data)}`,
191
+ },
192
+ ],
193
+ isError: true,
194
+ };
195
+ }
196
+ const page = data;
197
+ const lines = [
198
+ `Page: ${namespace}/${id}`,
199
+ `URL: ${page.url || `${BASE_URL}/${namespace}/${id}`}`,
200
+ `Format: ${page.format || "HTML"}`,
201
+ `Created: ${page.createdAt || "N/A"}`,
202
+ ``,
203
+ `--- Content ---`,
204
+ `${page.content || ""}`,
205
+ ];
206
+ return {
207
+ content: [{ type: "text", text: lines.join("\n") }],
208
+ };
209
+ });
210
+ server.tool("get_stats", "Get BrewPage platform-wide usage statistics including page count, file count, and storage usage.", {}, async () => {
211
+ const { ok, data } = await apiRequest("GET", "/api/stats");
212
+ if (!ok) {
213
+ return {
214
+ content: [
215
+ {
216
+ type: "text",
217
+ text: `Failed to fetch stats: ${JSON.stringify(data)}`,
218
+ },
219
+ ],
220
+ isError: true,
221
+ };
222
+ }
223
+ return {
224
+ content: [
225
+ {
226
+ type: "text",
227
+ text: `BrewPage Platform Statistics:\n\n${JSON.stringify(data, null, 2)}`,
228
+ },
229
+ ],
230
+ };
231
+ });
232
+ async function main() {
233
+ const transport = new StdioServerTransport();
234
+ await server.connect(transport);
235
+ }
236
+ main().catch((error) => {
237
+ console.error("Fatal error:", error);
238
+ process.exit(1);
239
+ });
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "brewpage-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for BrewPage — publish and manage HTML, KV, JSON, and file content from AI assistants",
5
+ "type": "module",
6
+ "bin": {
7
+ "brewpage-mcp": "./dist/index.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "start": "node dist/index.js",
22
+ "dev": "tsx src/index.ts",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "keywords": [
26
+ "mcp",
27
+ "mcp-server",
28
+ "model-context-protocol",
29
+ "brewpage",
30
+ "claude",
31
+ "claude-desktop",
32
+ "claude-code",
33
+ "ai",
34
+ "hosting",
35
+ "html",
36
+ "markdown",
37
+ "api"
38
+ ],
39
+ "author": {
40
+ "name": "Maksim Kochetkov",
41
+ "url": "https://github.com/kochetkov-ma"
42
+ },
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/kochetkov-ma/brewpage-openapi.git",
47
+ "directory": "mcp-server"
48
+ },
49
+ "homepage": "https://brewpage.app",
50
+ "bugs": {
51
+ "url": "https://github.com/kochetkov-ma/brewpage-openapi/issues"
52
+ },
53
+ "dependencies": {
54
+ "@modelcontextprotocol/sdk": "^1.12.0",
55
+ "zod": "^3.24.0"
56
+ },
57
+ "devDependencies": {
58
+ "@types/node": "^22.0.0",
59
+ "tsx": "^4.19.0",
60
+ "typescript": "^5.8.0"
61
+ }
62
+ }