@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.
- package/dist/handlers/{api_gateway_proxy_event_handler.d.ts → apiGatewayProxyEventHandler.d.ts} +2 -2
- package/dist/handlers/{api_gateway_proxy_event_handler.js → apiGatewayProxyEventHandler.js} +1 -1
- package/dist/handlers/{api_gateway_proxy_event_v2_handler.d.ts → apiGatewayProxyEventV2Handler.d.ts} +2 -2
- package/dist/handlers/{api_gateway_proxy_event_v2_handler.js → apiGatewayProxyEventV2Handler.js} +1 -1
- package/dist/handlers/index.d.ts +4 -4
- package/dist/handlers/index.js +3 -3
- package/dist/handlers/{lambda_function_url_event_handler.d.ts → lambdaFunctionUrlEventHandler.d.ts} +2 -2
- package/dist/handlers/{lambda_function_url_event_handler.js → lambdaFunctionUrlEventHandler.js} +1 -1
- package/dist/handlers/{streamable_http_handler.d.ts → streamableHttpHandler.d.ts} +1 -1
- package/dist/server-adapter/index.d.ts +2 -2
- package/dist/server-adapter/index.js +2 -2
- package/dist/server-adapter/{stdio_server_adapter.test.js → stdioServerAdapter.test.js} +2 -2
- package/dist/server-adapter/{stdio_server_adapter_request_handler.d.ts → stdioServerAdapterRequestHandler.d.ts} +1 -1
- package/dist/server-adapter/{stdio_server_adapter_request_handler.js → stdioServerAdapterRequestHandler.js} +1 -1
- package/dist/server-adapter/{stdio_server_adapter_request_handler.test.js → stdioServerAdapterRequestHandler.test.js} +53 -53
- package/package.json +2 -1
- /package/dist/handlers/{request_handler.d.ts → requestHandler.d.ts} +0 -0
- /package/dist/handlers/{request_handler.js → requestHandler.js} +0 -0
- /package/dist/handlers/{streamable_http_handler.js → streamableHttpHandler.js} +0 -0
- /package/dist/server-adapter/{stdio_server_adapter.d.ts → stdioServerAdapter.d.ts} +0 -0
- /package/dist/server-adapter/{stdio_server_adapter.js → stdioServerAdapter.js} +0 -0
- /package/dist/server-adapter/{stdio_server_adapter.test.d.ts → stdioServerAdapter.test.d.ts} +0 -0
- /package/dist/server-adapter/{stdio_server_adapter_request_handler.test.d.ts → stdioServerAdapterRequestHandler.test.d.ts} +0 -0
package/dist/handlers/{api_gateway_proxy_event_handler.d.ts → apiGatewayProxyEventHandler.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
|
|
2
|
-
import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./
|
|
3
|
-
import { RequestHandler } from "./
|
|
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
|
*
|
package/dist/handlers/{api_gateway_proxy_event_v2_handler.d.ts → apiGatewayProxyEventV2Handler.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
|
|
2
|
-
import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./
|
|
3
|
-
import { RequestHandler } from "./
|
|
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
|
*
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RequestHandler } from "./
|
|
2
|
-
export { APIGatewayProxyEventHandler } from "./
|
|
3
|
-
export { APIGatewayProxyEventV2Handler } from "./
|
|
4
|
-
export { LambdaFunctionURLEventHandler } from "./
|
|
1
|
+
export { RequestHandler } from "./requestHandler.js";
|
|
2
|
+
export { APIGatewayProxyEventHandler } from "./apiGatewayProxyEventHandler.js";
|
|
3
|
+
export { APIGatewayProxyEventV2Handler } from "./apiGatewayProxyEventV2Handler.js";
|
|
4
|
+
export { LambdaFunctionURLEventHandler } from "./lambdaFunctionUrlEventHandler.js";
|
package/dist/handlers/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { APIGatewayProxyEventHandler } from "./
|
|
2
|
-
export { APIGatewayProxyEventV2Handler } from "./
|
|
3
|
-
export { LambdaFunctionURLEventHandler } from "./
|
|
1
|
+
export { APIGatewayProxyEventHandler } from "./apiGatewayProxyEventHandler.js";
|
|
2
|
+
export { APIGatewayProxyEventV2Handler } from "./apiGatewayProxyEventV2Handler.js";
|
|
3
|
+
export { LambdaFunctionURLEventHandler } from "./lambdaFunctionUrlEventHandler.js";
|
package/dist/handlers/{lambda_function_url_event_handler.d.ts → lambdaFunctionUrlEventHandler.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
|
|
2
|
-
import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./
|
|
3
|
-
import { RequestHandler } from "./
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { Context } from "aws-lambda";
|
|
2
2
|
import { ErrorCode } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
import { RequestHandler } from "./
|
|
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 "./
|
|
2
|
-
export { StdioServerAdapterRequestHandler } from "./
|
|
1
|
+
export { stdioServerAdapter } from "./stdioServerAdapter.js";
|
|
2
|
+
export { StdioServerAdapterRequestHandler } from "./stdioServerAdapterRequestHandler.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { stdioServerAdapter } from "./
|
|
2
|
-
export { StdioServerAdapterRequestHandler } from "./
|
|
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 './
|
|
2
|
+
import { stdioServerAdapter } from './stdioServerAdapter.js';
|
|
3
3
|
const serverParameters = {
|
|
4
4
|
command: 'npx',
|
|
5
|
-
args: ['tsx', 'test-stdio-server/
|
|
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/
|
|
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 './
|
|
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
|
|
2
|
-
import { StdioServerAdapterRequestHandler } from
|
|
3
|
-
import * as stdioServerAdapter from
|
|
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(
|
|
5
|
+
jest.mock("./stdioServerAdapter.js", () => ({
|
|
6
6
|
stdioServerAdapter: jest.fn(),
|
|
7
7
|
}));
|
|
8
8
|
const mockStdioServerAdapter = stdioServerAdapter.stdioServerAdapter;
|
|
9
9
|
const mockServerParams = {
|
|
10
|
-
command:
|
|
11
|
-
args: [
|
|
10
|
+
command: "node",
|
|
11
|
+
args: ["test-server.js"],
|
|
12
12
|
};
|
|
13
13
|
const mockContext = {
|
|
14
14
|
callbackWaitsForEmptyEventLoop: true,
|
|
15
|
-
functionName:
|
|
16
|
-
functionVersion:
|
|
17
|
-
invokedFunctionArn:
|
|
18
|
-
memoryLimitInMB:
|
|
19
|
-
awsRequestId:
|
|
20
|
-
logGroupName:
|
|
21
|
-
logStreamName:
|
|
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(
|
|
27
|
+
describe("StdioServerAdapterRequestHandler", () => {
|
|
28
28
|
let handler;
|
|
29
29
|
beforeEach(() => {
|
|
30
30
|
handler = new StdioServerAdapterRequestHandler(mockServerParams);
|
|
31
31
|
jest.clearAllMocks();
|
|
32
32
|
});
|
|
33
|
-
describe(
|
|
34
|
-
test(
|
|
33
|
+
describe("handleRequest", () => {
|
|
34
|
+
test("should return JSONRPCResponse when stdioServerAdapter returns valid response", async () => {
|
|
35
35
|
const request = {
|
|
36
|
-
jsonrpc:
|
|
36
|
+
jsonrpc: "2.0",
|
|
37
37
|
id: 1,
|
|
38
|
-
method:
|
|
39
|
-
params: { arg:
|
|
38
|
+
method: "test",
|
|
39
|
+
params: { arg: "value" },
|
|
40
40
|
};
|
|
41
41
|
const expectedResponse = {
|
|
42
|
-
jsonrpc:
|
|
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(
|
|
51
|
+
test("should return JSONRPCError when stdioServerAdapter returns error", async () => {
|
|
52
52
|
const request = {
|
|
53
|
-
jsonrpc:
|
|
53
|
+
jsonrpc: "2.0",
|
|
54
54
|
id: 1,
|
|
55
|
-
method:
|
|
55
|
+
method: "test",
|
|
56
56
|
};
|
|
57
57
|
const expectedError = {
|
|
58
|
-
jsonrpc:
|
|
58
|
+
jsonrpc: "2.0",
|
|
59
59
|
error: {
|
|
60
60
|
code: ErrorCode.MethodNotFound,
|
|
61
|
-
message:
|
|
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(
|
|
70
|
+
test("should return internal error when stdioServerAdapter returns unexpected format", async () => {
|
|
71
71
|
const request = {
|
|
72
|
-
jsonrpc:
|
|
72
|
+
jsonrpc: "2.0",
|
|
73
73
|
id: 1,
|
|
74
|
-
method:
|
|
74
|
+
method: "test",
|
|
75
75
|
};
|
|
76
|
-
const unexpectedResponse = { invalid:
|
|
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:
|
|
80
|
+
jsonrpc: "2.0",
|
|
81
81
|
error: {
|
|
82
82
|
code: ErrorCode.InternalError,
|
|
83
|
-
message:
|
|
84
|
-
data:
|
|
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(
|
|
89
|
+
test("should return internal error when stdioServerAdapter throws exception", async () => {
|
|
90
90
|
const request = {
|
|
91
|
-
jsonrpc:
|
|
91
|
+
jsonrpc: "2.0",
|
|
92
92
|
id: 1,
|
|
93
|
-
method:
|
|
93
|
+
method: "test",
|
|
94
94
|
};
|
|
95
|
-
const error = new Error(
|
|
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:
|
|
99
|
+
jsonrpc: "2.0",
|
|
100
100
|
error: {
|
|
101
101
|
code: ErrorCode.InternalError,
|
|
102
|
-
message:
|
|
103
|
-
data:
|
|
102
|
+
message: "Internal error",
|
|
103
|
+
data: "Connection failed",
|
|
104
104
|
},
|
|
105
105
|
id: 1,
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
|
-
test(
|
|
108
|
+
test("should handle non-Error exceptions", async () => {
|
|
109
109
|
const request = {
|
|
110
|
-
jsonrpc:
|
|
110
|
+
jsonrpc: "2.0",
|
|
111
111
|
id: 1,
|
|
112
|
-
method:
|
|
112
|
+
method: "test",
|
|
113
113
|
};
|
|
114
|
-
mockStdioServerAdapter.mockRejectedValue(
|
|
114
|
+
mockStdioServerAdapter.mockRejectedValue("String error");
|
|
115
115
|
const result = await handler.handleRequest(request, mockContext);
|
|
116
116
|
expect(result).toEqual({
|
|
117
|
-
jsonrpc:
|
|
117
|
+
jsonrpc: "2.0",
|
|
118
118
|
error: {
|
|
119
119
|
code: ErrorCode.InternalError,
|
|
120
|
-
message:
|
|
121
|
-
data:
|
|
120
|
+
message: "Internal error",
|
|
121
|
+
data: "Unknown error",
|
|
122
122
|
},
|
|
123
123
|
id: 1,
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
|
-
test(
|
|
126
|
+
test("should pass server parameters correctly to stdioServerAdapter", async () => {
|
|
127
127
|
const customServerParams = {
|
|
128
|
-
command:
|
|
129
|
-
args: [
|
|
130
|
-
env: {
|
|
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:
|
|
134
|
+
jsonrpc: "2.0",
|
|
135
135
|
id: 1,
|
|
136
|
-
method:
|
|
136
|
+
method: "test",
|
|
137
137
|
};
|
|
138
138
|
const response = {
|
|
139
|
-
jsonrpc:
|
|
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.
|
|
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",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/server-adapter/{stdio_server_adapter.test.d.ts → stdioServerAdapter.test.d.ts}
RENAMED
|
File without changes
|