mcp-proxy 5.8.0 → 5.8.1

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Client, InMemoryEventStore, ReadBuffer, Server, __commonJS, __toESM, proxyServer, serializeMessage, startHTTPServer } from "../stdio-so1-I7Pn.js";
2
+ import { Client, InMemoryEventStore, ReadBuffer, Server, __commonJS, __toESM, proxyServer, serializeMessage, startHTTPServer } from "../stdio-9KZaSDCW.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { basename, dirname, extname, join, normalize, relative, resolve } from "path";
5
5
  import { format, inspect } from "util";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Client, InMemoryEventStore, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, NEVER, ReadBuffer, Server, ZodIssueCode, anyType, arrayType, booleanType, isInitializedNotification, isJSONRPCRequest, isJSONRPCResponse, numberType, objectType, proxyServer, serializeMessage, startHTTPServer, stringType } from "./stdio-so1-I7Pn.js";
1
+ import { Client, InMemoryEventStore, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, NEVER, ReadBuffer, Server, ZodIssueCode, anyType, arrayType, booleanType, isInitializedNotification, isJSONRPCRequest, isJSONRPCResponse, numberType, objectType, proxyServer, serializeMessage, startHTTPServer, stringType } from "./stdio-9KZaSDCW.js";
2
2
  import process from "node:process";
3
3
 
4
4
  //#region node_modules/.pnpm/eventsource-parser@3.0.6/node_modules/eventsource-parser/dist/index.js
@@ -15053,12 +15053,14 @@ const handleStreamRequest = async ({ activeTransports, authenticate, createServe
15053
15053
  let server;
15054
15054
  const body = await getBody(req);
15055
15055
  if (stateless && authenticate) try {
15056
- if (!await authenticate(req)) {
15056
+ const authResult = await authenticate(req);
15057
+ if (!authResult || typeof authResult === "object" && "authenticated" in authResult && !authResult.authenticated) {
15058
+ const errorMessage = authResult && typeof authResult === "object" && "error" in authResult && typeof authResult.error === "string" ? authResult.error : "Unauthorized: Authentication failed";
15057
15059
  res.setHeader("Content-Type", "application/json");
15058
15060
  res.writeHead(401).end(JSON.stringify({
15059
15061
  error: {
15060
15062
  code: -32e3,
15061
- message: "Unauthorized: Authentication failed"
15063
+ message: errorMessage
15062
15064
  },
15063
15065
  id: body?.id ?? null,
15064
15066
  jsonrpc: "2.0"
@@ -15066,12 +15068,13 @@ const handleStreamRequest = async ({ activeTransports, authenticate, createServe
15066
15068
  return true;
15067
15069
  }
15068
15070
  } catch (error) {
15071
+ const errorMessage = error instanceof Error ? error.message : "Unauthorized: Authentication error";
15069
15072
  console.error("Authentication error:", error);
15070
15073
  res.setHeader("Content-Type", "application/json");
15071
15074
  res.writeHead(401).end(JSON.stringify({
15072
15075
  error: {
15073
15076
  code: -32e3,
15074
- message: "Unauthorized: Authentication error"
15077
+ message: errorMessage
15075
15078
  },
15076
15079
  id: body?.id ?? null,
15077
15080
  jsonrpc: "2.0"
@@ -15112,6 +15115,19 @@ const handleStreamRequest = async ({ activeTransports, authenticate, createServe
15112
15115
  try {
15113
15116
  server = await createServer(req);
15114
15117
  } catch (error) {
15118
+ const errorMessage = error instanceof Error ? error.message : String(error);
15119
+ if (errorMessage.includes("Authentication") || errorMessage.includes("Invalid JWT") || errorMessage.includes("Token") || errorMessage.includes("Unauthorized")) {
15120
+ res.setHeader("Content-Type", "application/json");
15121
+ res.writeHead(401).end(JSON.stringify({
15122
+ error: {
15123
+ code: -32e3,
15124
+ message: errorMessage
15125
+ },
15126
+ id: body?.id ?? null,
15127
+ jsonrpc: "2.0"
15128
+ }));
15129
+ return true;
15130
+ }
15115
15131
  if (handleResponseError(error, res)) return true;
15116
15132
  res.writeHead(500).end("Error creating server");
15117
15133
  return true;
@@ -15130,6 +15146,19 @@ const handleStreamRequest = async ({ activeTransports, authenticate, createServe
15130
15146
  try {
15131
15147
  server = await createServer(req);
15132
15148
  } catch (error) {
15149
+ const errorMessage = error instanceof Error ? error.message : String(error);
15150
+ if (errorMessage.includes("Authentication") || errorMessage.includes("Invalid JWT") || errorMessage.includes("Token") || errorMessage.includes("Unauthorized")) {
15151
+ res.setHeader("Content-Type", "application/json");
15152
+ res.writeHead(401).end(JSON.stringify({
15153
+ error: {
15154
+ code: -32e3,
15155
+ message: errorMessage
15156
+ },
15157
+ id: body?.id ?? null,
15158
+ jsonrpc: "2.0"
15159
+ }));
15160
+ return true;
15161
+ }
15133
15162
  if (handleResponseError(error, res)) return true;
15134
15163
  res.writeHead(500).end("Error creating server");
15135
15164
  return true;
@@ -21510,4 +21539,4 @@ function serializeMessage(message) {
21510
21539
 
21511
21540
  //#endregion
21512
21541
  export { Client, InMemoryEventStore, JSONRPCMessageSchema, LATEST_PROTOCOL_VERSION, NEVER, ReadBuffer, Server, ZodIssueCode, __commonJS, __toESM, anyType, arrayType, booleanType, isInitializedNotification, isJSONRPCRequest, isJSONRPCResponse, numberType, objectType, proxyServer, serializeMessage, startHTTPServer, stringType };
21513
- //# sourceMappingURL=stdio-so1-I7Pn.js.map
21542
+ //# sourceMappingURL=stdio-9KZaSDCW.js.map