tiny-http-mcp-server 0.1.14 → 0.1.16

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.
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.14",
21
+ "version": "0.1.16",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -754,7 +754,7 @@ export class StreamableHttpTransport {
754
754
  const history = this.sseEventHistory.get(sessionId) ?? [];
755
755
  for (const event of history) {
756
756
  if (event.id > lastEventId && !res.writableEnded) {
757
- res.write(formatSseEvent({ id: String(event.id), data: event.data }));
757
+ this.writeToLiveGetStream(res, formatSseEvent({ id: String(event.id), data: event.data }));
758
758
  }
759
759
  }
760
760
  }
@@ -64,12 +64,19 @@ async function readStreamBody(req, maxBytes) {
64
64
  return Buffer.concat(chunks).toString("utf8");
65
65
  }
66
66
  async function readRawBody(req, preParsed, options) {
67
- if (preParsed !== undefined) {
68
- return preParsed;
69
- }
70
67
  const reqWithBody = req;
71
- if (reqWithBody.body !== undefined) {
72
- return reqWithBody.body;
68
+ const body = preParsed !== undefined ? preParsed : reqWithBody.body;
69
+ if (body !== undefined) {
70
+ if (options.maxBytes !== undefined) {
71
+ const serialized = JSON.stringify(body);
72
+ if (serialized === undefined) {
73
+ throw new Error("Invalid Request");
74
+ }
75
+ if (Buffer.byteLength(serialized, "utf8") > options.maxBytes) {
76
+ throw new Error("Payload too large");
77
+ }
78
+ }
79
+ return body;
73
80
  }
74
81
  const raw = await readStreamBody(req, options.maxBytes);
75
82
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",