@pairdraw/mcp 0.16.1 → 0.17.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/connect.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./rolldown-runtime-ClRpJifh.mjs";
3
- import { f as pairingFingerprint, i as resolveCORSOrigins, n as startServer, r as DEFAULT_CONNECT_APP_URL, t as MCP_VERSION } from "./server-BdiJUhSs.mjs";
3
+ import { f as pairingFingerprint, i as resolveCORSOrigins, n as startServer, r as DEFAULT_CONNECT_APP_URL, t as MCP_VERSION } from "./server-B-NBTb6z.mjs";
4
4
  import { n as getCompanionDir } from "./paths-BpcXnrbP.mjs";
5
5
  import { t as resolveMCPRoot } from "./root-BzmoiT2g.mjs";
6
6
  import { i as readToolPolicyFromEnv } from "./policy-B8Ka4WRH.mjs";
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import "./rolldown-runtime-ClRpJifh.mjs";
3
- import { d as devAgentBridgeFromEnv, i as resolveCORSOrigins, n as startServer, t as MCP_VERSION } from "./server-BdiJUhSs.mjs";
3
+ import { d as devAgentBridgeFromEnv, i as resolveCORSOrigins, n as startServer, t as MCP_VERSION } from "./server-B-NBTb6z.mjs";
4
4
  import { t as resolveMCPRoot } from "./root-BzmoiT2g.mjs";
5
5
  import { i as readToolPolicyFromEnv } from "./policy-B8Ka4WRH.mjs";
6
6
  //#region src/index.ts
@@ -1463,24 +1463,6 @@ function createBrowserRPCBridge({ authToken, authorize = (token) => isAuthorized
1463
1463
  };
1464
1464
  }
1465
1465
  //#endregion
1466
- //#region src/http-options.ts
1467
- const MCP_CORS_METHODS = [
1468
- "GET",
1469
- "POST",
1470
- "PUT",
1471
- "DELETE",
1472
- "OPTIONS"
1473
- ];
1474
- const MCP_CORS_HEADERS = [
1475
- "Content-Type",
1476
- "Authorization",
1477
- "x-mcp-token",
1478
- "mcp-session-id",
1479
- "Last-Event-ID",
1480
- "mcp-protocol-version"
1481
- ];
1482
- const MCP_EXPOSED_HEADERS = ["mcp-session-id", "mcp-protocol-version"];
1483
- //#endregion
1484
1466
  //#region src/result.ts
1485
1467
  const MAX_RESULT_BYTES = 9e5;
1486
1468
  function resultTooLargeMessage(kind, bytes, hint) {
@@ -1714,6 +1696,32 @@ async function writeToolOutput(toolName, result, filePath, root) {
1714
1696
  return ok(await writeInsideRoot(filePath, root, content));
1715
1697
  }
1716
1698
  //#endregion
1699
+ //#region src/http-options.ts
1700
+ const MCP_CORS_METHODS = [
1701
+ "GET",
1702
+ "POST",
1703
+ "PUT",
1704
+ "DELETE",
1705
+ "OPTIONS"
1706
+ ];
1707
+ /**
1708
+ * Refuses a larger body, counted as it streams in, so one without Content-Length is bounded too.
1709
+ * Routes check the token before it, so a caller without one never makes the server buffer.
1710
+ */
1711
+ const limitBody = bodyLimit({
1712
+ maxSize: 2 * MAX_FILE_TRANSFER_BYTES,
1713
+ onError: (c) => c.json({ error: "Request is too large" }, 413)
1714
+ });
1715
+ const MCP_CORS_HEADERS = [
1716
+ "Content-Type",
1717
+ "Authorization",
1718
+ "x-mcp-token",
1719
+ "mcp-session-id",
1720
+ "Last-Event-ID",
1721
+ "mcp-protocol-version"
1722
+ ];
1723
+ const MCP_EXPOSED_HEADERS = ["mcp-session-id", "mcp-protocol-version"];
1724
+ //#endregion
1717
1725
  //#region src/server/files.ts
1718
1726
  /**
1719
1727
  * The path after `/files/`, one encoded segment per folder, so the URL ends in the file's name.
@@ -2612,7 +2620,7 @@ function isLoopbackHost(host) {
2612
2620
  }
2613
2621
  //#endregion
2614
2622
  //#region package.json
2615
- var version = "0.16.1";
2623
+ var version = "0.17.0";
2616
2624
  //#endregion
2617
2625
  //#region src/server/connections.ts
2618
2626
  const HEARTBEAT_INTERVAL_MS = 5e3;
@@ -2972,7 +2980,7 @@ function createHonoApp(options) {
2972
2980
  app.use("/files/*", requireToken);
2973
2981
  registerFileRoutes(app, fileRoot);
2974
2982
  }
2975
- app.post("/rpc", async (c) => {
2983
+ app.post("/rpc", limitBody, async (c) => {
2976
2984
  const body = await c.req.json().catch(() => null);
2977
2985
  if (!body || typeof body !== "object" || Array.isArray(body)) return c.json({ error: "Invalid request body" }, 400);
2978
2986
  try {
@@ -2986,9 +2994,11 @@ function createHonoApp(options) {
2986
2994
  }, 502);
2987
2995
  }
2988
2996
  });
2989
- app.all("/mcp", async (c) => {
2997
+ const requireMCPToken = async (c, next) => {
2990
2998
  const token = mcpRequestToken(c.req.header("authorization"), c.req.header("x-mcp-token"));
2991
- if (!verifyMCPToken(token)) return c.json({ error: "Unauthorized" }, 401);
2999
+ return verifyMCPToken(token) ? next() : c.json({ error: "Unauthorized" }, 401);
3000
+ };
3001
+ app.all("/mcp", requireMCPToken, limitBody, async (c) => {
2992
3002
  if (!MCP_METHODS.includes(c.req.method)) return c.json({ error: "Method not allowed" }, {
2993
3003
  status: 405,
2994
3004
  headers: { Allow: MCP_METHODS.join(", ") }
@@ -3258,4 +3268,4 @@ function armAppAttachWatchdog(timeoutMs, browserRPC, handle) {
3258
3268
  //#endregion
3259
3269
  export { createServerInstructions as a, registerSkill as c, devAgentBridgeFromEnv as d, pairingFingerprint as f, resolveCORSOrigins as i, fail as l, startServer as n, MCP_AGENT_KINDS as o, DEFAULT_CONNECT_APP_URL as r, registerTools as s, MCP_VERSION as t, ok as u };
3260
3270
 
3261
- //# sourceMappingURL=server-BdiJUhSs.mjs.map
3271
+ //# sourceMappingURL=server-B-NBTb6z.mjs.map