poe-code 3.0.436 → 3.0.438

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "3.0.436",
3
+ "version": "3.0.438",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -37,6 +37,8 @@ export interface HttpServer extends Omit<Server, "tool" | "registerTool"> {
37
37
  }
38
38
  export interface HttpToolContext {
39
39
  request: AuthenticatedIncomingMessage;
40
+ sessionId?: string;
41
+ auth?: RequestAuthInfo;
40
42
  }
41
43
  export type HttpToolHandler<T = Record<string, unknown>, TOut = ToolReturn> = (args: T, context: HttpToolContext) => Promise<TOut | CallToolResult> | TOut | CallToolResult;
42
44
  export declare function createProtectedResourceMetadataDocument(options: ProtectedResourceMetadataOptions): Record<string, unknown>;
@@ -94,7 +94,11 @@ export function createHttpServer(options) {
94
94
  supportResourceSubscriptions: supportsSessions
95
95
  });
96
96
  const transport = new StreamableHttpTransport(server, options, async (req, callback) => requestContextStorage.run({
97
- request: req
97
+ request: req,
98
+ sessionId: Array.isArray(req.headers["mcp-session-id"])
99
+ ? req.headers["mcp-session-id"][0]
100
+ : req.headers["mcp-session-id"],
101
+ auth: req.auth
98
102
  }, callback));
99
103
  const protectedResourceMetadataBody = options.oauth === undefined
100
104
  ? undefined
@@ -103,7 +107,7 @@ export function createHttpServer(options) {
103
107
  const registerTool = server.tool.bind(server);
104
108
  const registerRichTool = server.registerTool.bind(server);
105
109
  const defaultContext = {
106
- request: {}
110
+ request: { headers: {}, socket: {} }
107
111
  };
108
112
  const authorizeHttpRequest = async (req, res, protectedResourcePath) => {
109
113
  if (options.oauth === undefined || req.method === "OPTIONS") {
@@ -242,7 +246,9 @@ export function createHttpServer(options) {
242
246
  };
243
247
  };
244
248
  httpServer.handleRequest = async (req, res) => {
245
- if (!(await authorizeHttpRequest(req, res, "/mcp"))) {
249
+ const { baseUrl } = req;
250
+ const protectedResourcePath = typeof baseUrl === "string" && baseUrl.length > 0 ? baseUrl : "/mcp";
251
+ if (!(await authorizeHttpRequest(req, res, protectedResourcePath))) {
246
252
  return;
247
253
  }
248
254
  await transport.handleRequest(req, res);