@aws/run-mcp-servers-with-aws-lambda 0.2.4 → 0.3.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 (23) hide show
  1. package/dist/handlers/{api_gateway_proxy_event_handler.d.ts → apiGatewayProxyEventHandler.d.ts} +2 -2
  2. package/dist/handlers/{api_gateway_proxy_event_handler.js → apiGatewayProxyEventHandler.js} +1 -1
  3. package/dist/handlers/{api_gateway_proxy_event_v2_handler.d.ts → apiGatewayProxyEventV2Handler.d.ts} +2 -2
  4. package/dist/handlers/{api_gateway_proxy_event_v2_handler.js → apiGatewayProxyEventV2Handler.js} +1 -1
  5. package/dist/handlers/index.d.ts +4 -4
  6. package/dist/handlers/index.js +3 -3
  7. package/dist/handlers/{lambda_function_url_event_handler.d.ts → lambdaFunctionUrlEventHandler.d.ts} +2 -2
  8. package/dist/handlers/{lambda_function_url_event_handler.js → lambdaFunctionUrlEventHandler.js} +1 -1
  9. package/dist/handlers/{streamable_http_handler.d.ts → streamableHttpHandler.d.ts} +1 -1
  10. package/dist/server-adapter/index.d.ts +2 -2
  11. package/dist/server-adapter/index.js +2 -2
  12. package/dist/server-adapter/{stdio_server_adapter.test.js → stdioServerAdapter.test.js} +2 -2
  13. package/dist/server-adapter/{stdio_server_adapter_request_handler.d.ts → stdioServerAdapterRequestHandler.d.ts} +1 -1
  14. package/dist/server-adapter/{stdio_server_adapter_request_handler.js → stdioServerAdapterRequestHandler.js} +1 -1
  15. package/dist/server-adapter/{stdio_server_adapter_request_handler.test.js → stdioServerAdapterRequestHandler.test.js} +53 -53
  16. package/package.json +2 -1
  17. /package/dist/handlers/{request_handler.d.ts → requestHandler.d.ts} +0 -0
  18. /package/dist/handlers/{request_handler.js → requestHandler.js} +0 -0
  19. /package/dist/handlers/{streamable_http_handler.js → streamableHttpHandler.js} +0 -0
  20. /package/dist/server-adapter/{stdio_server_adapter.d.ts → stdioServerAdapter.d.ts} +0 -0
  21. /package/dist/server-adapter/{stdio_server_adapter.js → stdioServerAdapter.js} +0 -0
  22. /package/dist/server-adapter/{stdio_server_adapter.test.d.ts → stdioServerAdapter.test.d.ts} +0 -0
  23. /package/dist/server-adapter/{stdio_server_adapter_request_handler.test.d.ts → stdioServerAdapterRequestHandler.test.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
2
- import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamable_http_handler.js";
3
- import { RequestHandler } from "./request_handler.js";
2
+ import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamableHttpHandler.js";
3
+ import { RequestHandler } from "./requestHandler.js";
4
4
  /**
5
5
  * Handler for API Gateway V1 events (REST APIs)
6
6
  *
@@ -1,4 +1,4 @@
1
- import { StreamableHttpHandler, } from "./streamable_http_handler.js";
1
+ import { StreamableHttpHandler, } from "./streamableHttpHandler.js";
2
2
  /**
3
3
  * Handler for API Gateway V1 events (REST APIs)
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
2
- import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamable_http_handler.js";
3
- import { RequestHandler } from "./request_handler.js";
2
+ import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamableHttpHandler.js";
3
+ import { RequestHandler } from "./requestHandler.js";
4
4
  /**
5
5
  * Handler for API Gateway V2 events (HTTP APIs)
6
6
  *
@@ -1,4 +1,4 @@
1
- import { StreamableHttpHandler, } from "./streamable_http_handler.js";
1
+ import { StreamableHttpHandler, } from "./streamableHttpHandler.js";
2
2
  /**
3
3
  * Handler for API Gateway V2 events (HTTP APIs)
4
4
  *
@@ -1,4 +1,4 @@
1
- export { RequestHandler } from "./request_handler.js";
2
- export { APIGatewayProxyEventHandler } from "./api_gateway_proxy_event_handler.js";
3
- export { APIGatewayProxyEventV2Handler } from "./api_gateway_proxy_event_v2_handler.js";
4
- export { LambdaFunctionURLEventHandler } from "./lambda_function_url_event_handler.js";
1
+ export { RequestHandler } from "./requestHandler.js";
2
+ export { APIGatewayProxyEventHandler } from "./apiGatewayProxyEventHandler.js";
3
+ export { APIGatewayProxyEventV2Handler } from "./apiGatewayProxyEventV2Handler.js";
4
+ export { LambdaFunctionURLEventHandler } from "./lambdaFunctionUrlEventHandler.js";
@@ -1,3 +1,3 @@
1
- export { APIGatewayProxyEventHandler } from "./api_gateway_proxy_event_handler.js";
2
- export { APIGatewayProxyEventV2Handler } from "./api_gateway_proxy_event_v2_handler.js";
3
- export { LambdaFunctionURLEventHandler } from "./lambda_function_url_event_handler.js";
1
+ export { APIGatewayProxyEventHandler } from "./apiGatewayProxyEventHandler.js";
2
+ export { APIGatewayProxyEventV2Handler } from "./apiGatewayProxyEventV2Handler.js";
3
+ export { LambdaFunctionURLEventHandler } from "./lambdaFunctionUrlEventHandler.js";
@@ -1,6 +1,6 @@
1
1
  import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
2
- import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamable_http_handler.js";
3
- import { RequestHandler } from "./request_handler.js";
2
+ import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamableHttpHandler.js";
3
+ import { RequestHandler } from "./requestHandler.js";
4
4
  /**
5
5
  * Handler for Lambda Function URL requests
6
6
  *
@@ -1,4 +1,4 @@
1
- import { StreamableHttpHandler, } from "./streamable_http_handler.js";
1
+ import { StreamableHttpHandler, } from "./streamableHttpHandler.js";
2
2
  /**
3
3
  * Handler for Lambda Function URL requests
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { Context } from "aws-lambda";
2
2
  import { ErrorCode } from "@modelcontextprotocol/sdk/types.js";
3
- import { RequestHandler } from "./request_handler.js";
3
+ import { RequestHandler } from "./requestHandler.js";
4
4
  /**
5
5
  * Parsed HTTP request data extracted from various Lambda event types
6
6
  */
@@ -1,2 +1,2 @@
1
- export { stdioServerAdapter } from "./stdio_server_adapter.js";
2
- export { StdioServerAdapterRequestHandler } from "./stdio_server_adapter_request_handler.js";
1
+ export { stdioServerAdapter } from "./stdioServerAdapter.js";
2
+ export { StdioServerAdapterRequestHandler } from "./stdioServerAdapterRequestHandler.js";
@@ -1,2 +1,2 @@
1
- export { stdioServerAdapter } from "./stdio_server_adapter.js";
2
- export { StdioServerAdapterRequestHandler } from "./stdio_server_adapter_request_handler.js";
1
+ export { stdioServerAdapter } from "./stdioServerAdapter.js";
2
+ export { StdioServerAdapterRequestHandler } from "./stdioServerAdapterRequestHandler.js";
@@ -1,8 +1,8 @@
1
1
  import { ErrorCode, } from '@modelcontextprotocol/sdk/types.js';
2
- import { stdioServerAdapter } from './stdio_server_adapter.js';
2
+ import { stdioServerAdapter } from './stdioServerAdapter.js';
3
3
  const serverParameters = {
4
4
  command: 'npx',
5
- args: ['tsx', 'test-stdio-server/echo_server.ts'],
5
+ args: ['tsx', 'test-stdio-server/echoServer.ts'],
6
6
  };
7
7
  const mockContext = {
8
8
  callbackWaitsForEmptyEventLoop: true,
@@ -1,7 +1,7 @@
1
1
  import { Context } from 'aws-lambda';
2
2
  import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
3
3
  import { JSONRPCRequest, JSONRPCResponse, JSONRPCError } from '@modelcontextprotocol/sdk/types.js';
4
- import { RequestHandler } from '../handlers/request_handler.js';
4
+ import { RequestHandler } from '../handlers/requestHandler.js';
5
5
  /**
6
6
  * Generic Request Handler for MCP Stdio Server Adapter
7
7
  *
@@ -1,6 +1,6 @@
1
1
  import { isJSONRPCResponse, isJSONRPCError, ErrorCode, } from '@modelcontextprotocol/sdk/types.js';
2
2
  import { createLogger, format, transports } from 'winston';
3
- import { stdioServerAdapter } from './stdio_server_adapter.js';
3
+ import { stdioServerAdapter } from './stdioServerAdapter.js';
4
4
  const logger = createLogger({
5
5
  level: process.env.LOG_LEVEL?.toLowerCase() || 'info',
6
6
  format: format.simple(),
@@ -1,45 +1,45 @@
1
- import { ErrorCode, } from '@modelcontextprotocol/sdk/types.js';
2
- import { StdioServerAdapterRequestHandler } from './stdio_server_adapter_request_handler.js';
3
- import * as stdioServerAdapter from './stdio_server_adapter.js';
1
+ import { ErrorCode, } from "@modelcontextprotocol/sdk/types.js";
2
+ import { StdioServerAdapterRequestHandler } from "./stdioServerAdapterRequestHandler.js";
3
+ import * as stdioServerAdapter from "./stdioServerAdapter.js";
4
4
  // Mock the stdioServerAdapter function
5
- jest.mock('./stdio_server_adapter.js', () => ({
5
+ jest.mock("./stdioServerAdapter.js", () => ({
6
6
  stdioServerAdapter: jest.fn(),
7
7
  }));
8
8
  const mockStdioServerAdapter = stdioServerAdapter.stdioServerAdapter;
9
9
  const mockServerParams = {
10
- command: 'node',
11
- args: ['test-server.js'],
10
+ command: "node",
11
+ args: ["test-server.js"],
12
12
  };
13
13
  const mockContext = {
14
14
  callbackWaitsForEmptyEventLoop: true,
15
- functionName: 'test-function',
16
- functionVersion: '1',
17
- invokedFunctionArn: 'test-arn',
18
- memoryLimitInMB: '128',
19
- awsRequestId: 'test-id',
20
- logGroupName: 'test-group',
21
- logStreamName: 'test-stream',
15
+ functionName: "test-function",
16
+ functionVersion: "1",
17
+ invokedFunctionArn: "test-arn",
18
+ memoryLimitInMB: "128",
19
+ awsRequestId: "test-id",
20
+ logGroupName: "test-group",
21
+ logStreamName: "test-stream",
22
22
  getRemainingTimeInMillis: () => 1000,
23
23
  done: () => { },
24
24
  fail: () => { },
25
25
  succeed: () => { },
26
26
  };
27
- describe('StdioServerAdapterRequestHandler', () => {
27
+ describe("StdioServerAdapterRequestHandler", () => {
28
28
  let handler;
29
29
  beforeEach(() => {
30
30
  handler = new StdioServerAdapterRequestHandler(mockServerParams);
31
31
  jest.clearAllMocks();
32
32
  });
33
- describe('handleRequest', () => {
34
- test('should return JSONRPCResponse when stdioServerAdapter returns valid response', async () => {
33
+ describe("handleRequest", () => {
34
+ test("should return JSONRPCResponse when stdioServerAdapter returns valid response", async () => {
35
35
  const request = {
36
- jsonrpc: '2.0',
36
+ jsonrpc: "2.0",
37
37
  id: 1,
38
- method: 'test',
39
- params: { arg: 'value' },
38
+ method: "test",
39
+ params: { arg: "value" },
40
40
  };
41
41
  const expectedResponse = {
42
- jsonrpc: '2.0',
42
+ jsonrpc: "2.0",
43
43
  id: 1,
44
44
  result: { success: true },
45
45
  };
@@ -48,17 +48,17 @@ describe('StdioServerAdapterRequestHandler', () => {
48
48
  expect(mockStdioServerAdapter).toHaveBeenCalledWith(mockServerParams, request, mockContext);
49
49
  expect(result).toEqual(expectedResponse);
50
50
  });
51
- test('should return JSONRPCError when stdioServerAdapter returns error', async () => {
51
+ test("should return JSONRPCError when stdioServerAdapter returns error", async () => {
52
52
  const request = {
53
- jsonrpc: '2.0',
53
+ jsonrpc: "2.0",
54
54
  id: 1,
55
- method: 'test',
55
+ method: "test",
56
56
  };
57
57
  const expectedError = {
58
- jsonrpc: '2.0',
58
+ jsonrpc: "2.0",
59
59
  error: {
60
60
  code: ErrorCode.MethodNotFound,
61
- message: 'Method not found',
61
+ message: "Method not found",
62
62
  },
63
63
  id: 1,
64
64
  };
@@ -67,76 +67,76 @@ describe('StdioServerAdapterRequestHandler', () => {
67
67
  expect(mockStdioServerAdapter).toHaveBeenCalledWith(mockServerParams, request, mockContext);
68
68
  expect(result).toEqual(expectedError);
69
69
  });
70
- test('should return internal error when stdioServerAdapter returns unexpected format', async () => {
70
+ test("should return internal error when stdioServerAdapter returns unexpected format", async () => {
71
71
  const request = {
72
- jsonrpc: '2.0',
72
+ jsonrpc: "2.0",
73
73
  id: 1,
74
- method: 'test',
74
+ method: "test",
75
75
  };
76
- const unexpectedResponse = { invalid: 'response' };
76
+ const unexpectedResponse = { invalid: "response" };
77
77
  mockStdioServerAdapter.mockResolvedValue(unexpectedResponse);
78
78
  const result = await handler.handleRequest(request, mockContext);
79
79
  expect(result).toEqual({
80
- jsonrpc: '2.0',
80
+ jsonrpc: "2.0",
81
81
  error: {
82
82
  code: ErrorCode.InternalError,
83
- message: 'Internal error: Unexpected response format from MCP server',
84
- data: 'Expected JSONRPCResponse or JSONRPCError',
83
+ message: "Internal error: Unexpected response format from MCP server",
84
+ data: "Expected JSONRPCResponse or JSONRPCError",
85
85
  },
86
86
  id: 1,
87
87
  });
88
88
  });
89
- test('should return internal error when stdioServerAdapter throws exception', async () => {
89
+ test("should return internal error when stdioServerAdapter throws exception", async () => {
90
90
  const request = {
91
- jsonrpc: '2.0',
91
+ jsonrpc: "2.0",
92
92
  id: 1,
93
- method: 'test',
93
+ method: "test",
94
94
  };
95
- const error = new Error('Connection failed');
95
+ const error = new Error("Connection failed");
96
96
  mockStdioServerAdapter.mockRejectedValue(error);
97
97
  const result = await handler.handleRequest(request, mockContext);
98
98
  expect(result).toEqual({
99
- jsonrpc: '2.0',
99
+ jsonrpc: "2.0",
100
100
  error: {
101
101
  code: ErrorCode.InternalError,
102
- message: 'Internal error',
103
- data: 'Connection failed',
102
+ message: "Internal error",
103
+ data: "Connection failed",
104
104
  },
105
105
  id: 1,
106
106
  });
107
107
  });
108
- test('should handle non-Error exceptions', async () => {
108
+ test("should handle non-Error exceptions", async () => {
109
109
  const request = {
110
- jsonrpc: '2.0',
110
+ jsonrpc: "2.0",
111
111
  id: 1,
112
- method: 'test',
112
+ method: "test",
113
113
  };
114
- mockStdioServerAdapter.mockRejectedValue('String error');
114
+ mockStdioServerAdapter.mockRejectedValue("String error");
115
115
  const result = await handler.handleRequest(request, mockContext);
116
116
  expect(result).toEqual({
117
- jsonrpc: '2.0',
117
+ jsonrpc: "2.0",
118
118
  error: {
119
119
  code: ErrorCode.InternalError,
120
- message: 'Internal error',
121
- data: 'Unknown error',
120
+ message: "Internal error",
121
+ data: "Unknown error",
122
122
  },
123
123
  id: 1,
124
124
  });
125
125
  });
126
- test('should pass server parameters correctly to stdioServerAdapter', async () => {
126
+ test("should pass server parameters correctly to stdioServerAdapter", async () => {
127
127
  const customServerParams = {
128
- command: 'python',
129
- args: ['custom-server.py', '--port', '8080'],
130
- env: { NODE_ENV: 'test' },
128
+ command: "python",
129
+ args: ["custom-server.py", "--port", "8080"],
130
+ env: { hello: "world" },
131
131
  };
132
132
  const customHandler = new StdioServerAdapterRequestHandler(customServerParams);
133
133
  const request = {
134
- jsonrpc: '2.0',
134
+ jsonrpc: "2.0",
135
135
  id: 1,
136
- method: 'test',
136
+ method: "test",
137
137
  };
138
138
  const response = {
139
- jsonrpc: '2.0',
139
+ jsonrpc: "2.0",
140
140
  id: 1,
141
141
  result: {},
142
142
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aws/run-mcp-servers-with-aws-lambda",
3
3
  "description": "Run Model Context Protocol (MCP) servers with AWS Lambda",
4
- "version": "0.2.4",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "author": {
@@ -46,6 +46,7 @@
46
46
  "aws-sdk-client-mock": "^4.1.0",
47
47
  "aws-sdk-client-mock-jest": "^4.1.0",
48
48
  "eslint": "^9.30.1",
49
+ "eslint-plugin-check-file": "^3.3.0",
49
50
  "jest": "^30.0.4",
50
51
  "ts-jest": "^29.4.0",
51
52
  "tsx": "^4.20.3",