pretext-pdf-mcp 1.0.1 → 1.0.2
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 +7 -39
- package/package.json +27 -6
package/dist/index.js
CHANGED
|
@@ -26,14 +26,11 @@ function createServer() {
|
|
|
26
26
|
}
|
|
27
27
|
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : null;
|
|
28
28
|
if (port) {
|
|
29
|
-
// HTTP mode — for hosted deployments (Smithery, VPS, etc.)
|
|
29
|
+
// HTTP mode — stateless, for hosted deployments (Smithery, VPS, etc.)
|
|
30
30
|
const { createServer: createHttpServer } = await import('node:http');
|
|
31
31
|
const { StreamableHTTPServerTransport } = await import('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
32
|
-
const { randomUUID } = await import('node:crypto');
|
|
33
|
-
const sessions = new Map();
|
|
34
32
|
const httpServer = createHttpServer(async (req, res) => {
|
|
35
33
|
const url = new URL(req.url ?? '/', `http://localhost:${port}`);
|
|
36
|
-
// Health check
|
|
37
34
|
if (url.pathname === '/health') {
|
|
38
35
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
39
36
|
res.end(JSON.stringify({ ok: true, service: 'pretext-pdf-mcp' }));
|
|
@@ -45,48 +42,19 @@ if (port) {
|
|
|
45
42
|
return;
|
|
46
43
|
}
|
|
47
44
|
if (req.method === 'POST') {
|
|
48
|
-
// Parse body
|
|
49
45
|
const chunks = [];
|
|
50
46
|
for await (const chunk of req)
|
|
51
47
|
chunks.push(chunk);
|
|
52
48
|
const body = JSON.parse(Buffer.concat(chunks).toString());
|
|
53
|
-
//
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else if (!sessionId && body?.method === 'initialize') {
|
|
60
|
-
// New session
|
|
61
|
-
transport = new StreamableHTTPServerTransport({
|
|
62
|
-
sessionIdGenerator: () => randomUUID(),
|
|
63
|
-
});
|
|
64
|
-
const server = createServer();
|
|
65
|
-
await server.connect(transport);
|
|
66
|
-
transport.onclose = () => {
|
|
67
|
-
if (transport.sessionId)
|
|
68
|
-
sessions.delete(transport.sessionId);
|
|
69
|
-
};
|
|
70
|
-
sessions.set(transport.sessionId, transport);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
74
|
-
res.end(JSON.stringify({ error: 'Bad request: missing or invalid session' }));
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
49
|
+
// Stateless: fresh transport+server per request — no session tracking
|
|
50
|
+
const transport = new StreamableHTTPServerTransport({
|
|
51
|
+
sessionIdGenerator: undefined,
|
|
52
|
+
});
|
|
53
|
+
const server = createServer();
|
|
54
|
+
await server.connect(transport);
|
|
77
55
|
await transport.handleRequest(req, res, body);
|
|
78
56
|
return;
|
|
79
57
|
}
|
|
80
|
-
if (req.method === 'GET' || req.method === 'DELETE') {
|
|
81
|
-
const sessionId = req.headers['mcp-session-id'];
|
|
82
|
-
if (!sessionId || !sessions.has(sessionId)) {
|
|
83
|
-
res.writeHead(404);
|
|
84
|
-
res.end();
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
await sessions.get(sessionId).handleRequest(req, res);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
58
|
res.writeHead(405);
|
|
91
59
|
res.end();
|
|
92
60
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pretext-pdf-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MCP server for pretext-pdf — generate professional PDFs from JSON in Claude, Cursor, or any AI agent",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"pdf",
|
|
8
|
+
"pdf-generation",
|
|
9
|
+
"invoice",
|
|
10
|
+
"report",
|
|
11
|
+
"claude",
|
|
12
|
+
"ai-agent",
|
|
13
|
+
"pretext"
|
|
14
|
+
],
|
|
6
15
|
"type": "module",
|
|
7
16
|
"main": "./dist/index.js",
|
|
8
|
-
"bin": {
|
|
17
|
+
"bin": {
|
|
18
|
+
"pretext-pdf-mcp": "./dist/index.js"
|
|
19
|
+
},
|
|
9
20
|
"scripts": {
|
|
10
21
|
"build": "tsc",
|
|
11
22
|
"dev": "tsx src/index.ts",
|
|
@@ -20,10 +31,20 @@
|
|
|
20
31
|
"tsx": "^4.0.0",
|
|
21
32
|
"typescript": "^5.0.0"
|
|
22
33
|
},
|
|
23
|
-
"files": [
|
|
24
|
-
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/**/*",
|
|
36
|
+
"smithery.yaml",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
},
|
|
25
43
|
"license": "MIT",
|
|
26
44
|
"author": "Himanshu Jain",
|
|
27
|
-
"repository": {
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/Himaan1998Y/pretext-pdf-mcp"
|
|
48
|
+
},
|
|
28
49
|
"homepage": "https://github.com/Himaan1998Y/pretext-pdf-mcp#readme"
|
|
29
50
|
}
|