givememy-mcp 0.1.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 +21 -0
- package/README.md +71 -0
- package/package.json +35 -0
- package/src/client.js +130 -0
- package/src/index.js +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 givememy.report contributors
|
|
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,71 @@
|
|
|
1
|
+
# givememy-mcp
|
|
2
|
+
|
|
3
|
+
Local stdio MCP server for publishing private HTML reports to givememy.report.
|
|
4
|
+
|
|
5
|
+
The server runs on the same machine as your agent, so it can read local files and upload their contents with your givememy.report API key.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"mcpServers": {
|
|
12
|
+
"givememy": {
|
|
13
|
+
"command": "npx",
|
|
14
|
+
"args": ["-y", "givememy-mcp"],
|
|
15
|
+
"env": {
|
|
16
|
+
"GIVEMEMY_API_KEY": "gmr_...",
|
|
17
|
+
"GIVEMEMY_BASE_URL": "https://givememy.report"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For local development from this repo:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"givememy": {
|
|
30
|
+
"command": "node",
|
|
31
|
+
"args": ["/absolute/path/to/givememy.report/mcp/src/index.js"],
|
|
32
|
+
"env": {
|
|
33
|
+
"GIVEMEMY_API_KEY": "gmr_..."
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Optional environment variables:
|
|
41
|
+
|
|
42
|
+
- `GIVEMEMY_BASE_URL` defaults to `https://givememy.report`.
|
|
43
|
+
- `GIVEMEMY_MAX_REPORT_BYTES` defaults to `1000000`.
|
|
44
|
+
|
|
45
|
+
## Tool
|
|
46
|
+
|
|
47
|
+
### `publish_report`
|
|
48
|
+
|
|
49
|
+
Arguments:
|
|
50
|
+
|
|
51
|
+
- `title?: string`
|
|
52
|
+
- `html?: string`
|
|
53
|
+
- `file_path?: string`
|
|
54
|
+
|
|
55
|
+
Pass either `html` or `file_path`, not both.
|
|
56
|
+
|
|
57
|
+
Examples an agent can call:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{ "title": "Weekly revenue", "file_path": "./report.html" }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{ "title": "Inline report", "html": "<h1>Hello</h1>" }
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The tool returns the private Cloudflare Access protected report URL.
|
|
68
|
+
|
|
69
|
+
## Notes
|
|
70
|
+
|
|
71
|
+
This is a stdio MCP server, so logs must go to stderr. Do not write human logs to stdout because stdout carries the MCP JSON-RPC protocol.
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "givememy-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local stdio MCP server for publishing private HTML reports to givememy.report.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"givememy-mcp": "src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"start": "node src/index.js",
|
|
15
|
+
"test": "node --test"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"reports",
|
|
21
|
+
"givememy"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"homepage": "https://givememy.report",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
33
|
+
"zod": "^3.25.76"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/client.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { stat, readFile } from 'node:fs/promises';
|
|
2
|
+
import { basename, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_BASE_URL = 'https://givememy.report';
|
|
5
|
+
export const DEFAULT_MAX_REPORT_BYTES = 1_000_000;
|
|
6
|
+
|
|
7
|
+
export function normalizeBaseUrl(value = DEFAULT_BASE_URL) {
|
|
8
|
+
const raw = String(value || DEFAULT_BASE_URL).trim();
|
|
9
|
+
return raw.replace(/\/+$/, '') || DEFAULT_BASE_URL;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getConfig(env = process.env) {
|
|
13
|
+
const apiKey = String(env.GIVEMEMY_API_KEY || '').trim();
|
|
14
|
+
if (!apiKey) {
|
|
15
|
+
throw new Error('GIVEMEMY_API_KEY is required');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const maxBytes = Number.parseInt(env.GIVEMEMY_MAX_REPORT_BYTES || `${DEFAULT_MAX_REPORT_BYTES}`, 10);
|
|
19
|
+
return {
|
|
20
|
+
apiKey,
|
|
21
|
+
baseUrl: normalizeBaseUrl(env.GIVEMEMY_BASE_URL),
|
|
22
|
+
maxBytes: Number.isFinite(maxBytes) && maxBytes > 0 ? maxBytes : DEFAULT_MAX_REPORT_BYTES,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function readReportFile(filePath, maxBytes = DEFAULT_MAX_REPORT_BYTES) {
|
|
27
|
+
if (!filePath || typeof filePath !== 'string') {
|
|
28
|
+
throw new Error('file_path must be a non-empty string');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const absolutePath = resolve(filePath);
|
|
32
|
+
const info = await stat(absolutePath).catch((error) => {
|
|
33
|
+
if (error?.code === 'ENOENT') throw new Error(`file not found: ${absolutePath}`);
|
|
34
|
+
throw error;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!info.isFile()) {
|
|
38
|
+
throw new Error(`not a file: ${absolutePath}`);
|
|
39
|
+
}
|
|
40
|
+
if (info.size > maxBytes) {
|
|
41
|
+
throw new Error(`file too large: ${info.size} bytes exceeds ${maxBytes}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const html = await readFile(absolutePath, 'utf8');
|
|
45
|
+
return { html, absolutePath, bytes: info.size, title: basename(absolutePath) };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function resolveReportInput(args = {}, options = {}) {
|
|
49
|
+
const maxBytes = options.maxBytes || DEFAULT_MAX_REPORT_BYTES;
|
|
50
|
+
const hasHtml = typeof args.html === 'string' && args.html.trim().length > 0;
|
|
51
|
+
const hasFilePath = typeof args.file_path === 'string' && args.file_path.trim().length > 0;
|
|
52
|
+
|
|
53
|
+
if (hasHtml && hasFilePath) {
|
|
54
|
+
throw new Error('provide either html or file_path, not both');
|
|
55
|
+
}
|
|
56
|
+
if (!hasHtml && !hasFilePath) {
|
|
57
|
+
throw new Error('publish_report requires html or file_path');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (hasFilePath) {
|
|
61
|
+
const file = await readReportFile(args.file_path, maxBytes);
|
|
62
|
+
return {
|
|
63
|
+
html: file.html,
|
|
64
|
+
title: args.title || file.title,
|
|
65
|
+
source: file.absolutePath,
|
|
66
|
+
bytes: file.bytes,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
html: args.html,
|
|
72
|
+
title: args.title || 'Untitled report',
|
|
73
|
+
source: 'inline html',
|
|
74
|
+
bytes: Buffer.byteLength(args.html, 'utf8'),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function publishReport({ title, html }, options = {}) {
|
|
79
|
+
const apiKey = options.apiKey;
|
|
80
|
+
if (!apiKey) throw new Error('GIVEMEMY_API_KEY is required');
|
|
81
|
+
if (!html || !html.trim()) throw new Error('empty_report');
|
|
82
|
+
|
|
83
|
+
const fetchImpl = options.fetchImpl || globalThis.fetch;
|
|
84
|
+
if (typeof fetchImpl !== 'function') throw new Error('fetch is not available in this Node runtime');
|
|
85
|
+
|
|
86
|
+
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
87
|
+
const response = await fetchImpl(`${baseUrl}/api/reports`, {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: {
|
|
90
|
+
authorization: `Bearer ${apiKey}`,
|
|
91
|
+
'content-type': 'text/html; charset=utf-8',
|
|
92
|
+
'x-report-title': title || 'Untitled report',
|
|
93
|
+
'user-agent': 'givememy-mcp/0.1.0',
|
|
94
|
+
},
|
|
95
|
+
body: html,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const responseText = await response.text();
|
|
99
|
+
let body = {};
|
|
100
|
+
try {
|
|
101
|
+
body = responseText ? JSON.parse(responseText) : {};
|
|
102
|
+
} catch {
|
|
103
|
+
body = { error: responseText };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const message = body.error || response.statusText || 'upload_failed';
|
|
108
|
+
throw new Error(`givememy.report upload failed (${response.status}): ${message}`);
|
|
109
|
+
}
|
|
110
|
+
if (!body.url) {
|
|
111
|
+
throw new Error('givememy.report upload response did not include a url');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return { title: title || 'Untitled report', url: body.url };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export async function publishFromArgs(args = {}, options = {}) {
|
|
118
|
+
const config = options.config || getConfig(options.env || process.env);
|
|
119
|
+
const input = await resolveReportInput(args, { maxBytes: config.maxBytes });
|
|
120
|
+
const result = await publishReport(
|
|
121
|
+
{ title: input.title, html: input.html },
|
|
122
|
+
{
|
|
123
|
+
apiKey: config.apiKey,
|
|
124
|
+
baseUrl: config.baseUrl,
|
|
125
|
+
fetchImpl: options.fetchImpl,
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return { ...result, source: input.source, bytes: input.bytes };
|
|
130
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { publishFromArgs } from './client.js';
|
|
8
|
+
|
|
9
|
+
export function createServer(options = {}) {
|
|
10
|
+
const server = new McpServer({
|
|
11
|
+
name: 'givememy',
|
|
12
|
+
version: '0.1.0',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
server.registerTool(
|
|
16
|
+
'publish_report',
|
|
17
|
+
{
|
|
18
|
+
description: 'Publish a private HTML report to givememy.report. Pass either html or a local file_path.',
|
|
19
|
+
inputSchema: {
|
|
20
|
+
title: z.string().optional().describe('Short report title. Defaults to the filename when file_path is used.'),
|
|
21
|
+
html: z.string().optional().describe('Complete HTML document or fragment to publish.'),
|
|
22
|
+
file_path: z.string().optional().describe('Local path to an HTML file to read and publish from this machine.'),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
async (args) => {
|
|
26
|
+
try {
|
|
27
|
+
const result = await publishFromArgs(args, options);
|
|
28
|
+
return {
|
|
29
|
+
content: [{ type: 'text', text: `Published ${result.url}` }],
|
|
30
|
+
structuredContent: result,
|
|
31
|
+
};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return {
|
|
34
|
+
isError: true,
|
|
35
|
+
content: [{ type: 'text', text: error?.message || String(error) }],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return server;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function main() {
|
|
45
|
+
const server = createServer();
|
|
46
|
+
const transport = new StdioServerTransport();
|
|
47
|
+
await server.connect(transport);
|
|
48
|
+
console.error('givememy MCP server running on stdio');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isMainEntry(argv = process.argv) {
|
|
52
|
+
if (!argv[1]) return false;
|
|
53
|
+
try {
|
|
54
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(argv[1]);
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (isMainEntry()) {
|
|
61
|
+
main().catch((error) => {
|
|
62
|
+
console.error('Fatal error in givememy MCP server:', error);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
});
|
|
65
|
+
}
|