@ttoss/http-server-mcp 0.16.5 → 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.
Files changed (2) hide show
  1. package/README.md +7 -4
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -641,21 +641,23 @@ This package implements the [Model Context Protocol](https://spec.modelcontextpr
641
641
 
642
642
  ## AWS Lambda Deployment
643
643
 
644
- The default **stateless** mode (see [Stateless vs stateful mode](#stateless-vs-stateful-mode)) is built for serverless: a fresh transport is created per request, nothing is kept in memory between invocations, and responses are plain JSON (no SSE) — exactly the request/response shape API Gateway and Lambda Function URLs expect. Because the router is a regular Koa app, you wrap it with any Koa-to-Lambda adapter (e.g. [`serverless-http`](https://github.com/dougmoscrop/serverless-http)) and front it with an HTTP API Gateway or a Function URL.
644
+ The default **stateless** mode (see [Stateless vs stateful mode](#stateless-vs-stateful-mode)) is built for serverless: a fresh transport is created per request, nothing is kept in memory between invocations, and responses are plain JSON (no SSE) — exactly the request/response shape API Gateway and Lambda Function URLs expect.
645
+
646
+ Use [`@ttoss/http-server-serverless`](https://github.com/ttoss/ttoss/tree/main/packages/http-server-serverless) as the Lambda adapter. It wraps `serverless-http` and additionally populates `req.rawHeaders` from the API Gateway event before the request reaches Koa. Without this step, `@hono/node-server` — used internally by the MCP transport — drops all headers (including `Accept`) and every `initialize` request returns HTTP 406.
645
647
 
646
648
  ```mermaid
647
649
  flowchart LR
648
650
  Client[MCP Client] -->|POST /mcp| GW[API Gateway / Function URL]
649
651
  GW --> L[Lambda]
650
652
  subgraph L[Lambda]
651
- H[serverless-http handler] --> App[Koa App + createMcpRouter]
653
+ H[toLambdaHandler] -->|rawHeaders populated| App[Koa App + createMcpRouter]
652
654
  end
653
655
  ```
654
656
 
655
657
  ```typescript
656
- import serverless from 'serverless-http';
657
658
  import { App, bodyParser } from '@ttoss/http-server';
658
659
  import { createMcpRouter, McpServer, z } from '@ttoss/http-server-mcp';
660
+ import { toLambdaHandler } from '@ttoss/http-server-serverless';
659
661
 
660
662
  const mcpServer = new McpServer({ name: 'my-mcp-server', version: '1.0.0' });
661
663
 
@@ -675,7 +677,7 @@ app.use(bodyParser());
675
677
  // Stateless by default — no sessionIdGenerator
676
678
  app.use(createMcpRouter(mcpServer).routes());
677
679
 
678
- export const handler = serverless(app.callback());
680
+ export const handler = toLambdaHandler(app);
679
681
  ```
680
682
 
681
683
  Keep the following in mind:
@@ -689,6 +691,7 @@ Keep the following in mind:
689
691
  ## Related Packages
690
692
 
691
693
  - [@ttoss/http-server](https://ttoss.dev/docs/modules/packages/http-server) - HTTP server foundation
694
+ - [@ttoss/http-server-serverless](https://github.com/ttoss/ttoss/tree/main/packages/http-server-serverless) - AWS Lambda adapter (required for MCP on Lambda)
692
695
  - [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk) - MCP SDK
693
696
 
694
697
  ## Resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/http-server-mcp",
3
- "version": "0.16.5",
3
+ "version": "0.17.0",
4
4
  "description": "Model Context Protocol (MCP) server integration for @ttoss/http-server",
5
5
  "keywords": [
6
6
  "ai",
@@ -36,8 +36,8 @@
36
36
  "@modelcontextprotocol/sdk": "^1.29.0",
37
37
  "zod": "^4.4.3",
38
38
  "@ttoss/auth-core": "^0.7.0",
39
- "@ttoss/http-server-auth": "^0.3.3",
40
- "@ttoss/http-server": "^0.7.1"
39
+ "@ttoss/http-server": "^0.7.1",
40
+ "@ttoss/http-server-auth": "^0.3.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/koa": "^3.0.3",