@aws/run-mcp-servers-with-aws-lambda 0.2.1 → 0.2.2
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 +31 -0
- package/dist/handlers/api_gateway_proxy_event_handler.js +43 -0
- package/dist/handlers/api_gateway_proxy_event_v2_handler.d.ts +30 -0
- package/dist/handlers/api_gateway_proxy_event_v2_handler.js +42 -0
- package/dist/handlers/handlers.test.js +629 -0
- package/dist/handlers/index.d.ts +4 -0
- package/dist/handlers/index.js +3 -0
- package/dist/handlers/lambda_function_url_event_handler.d.ts +30 -0
- package/dist/handlers/lambda_function_url_event_handler.js +42 -0
- package/dist/handlers/request_handler.d.ts +43 -0
- package/dist/handlers/request_handler.js +1 -0
- package/dist/handlers/streamable_http_handler.d.ts +81 -0
- package/dist/handlers/streamable_http_handler.js +234 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/server-adapter/index.d.ts +2 -4
- package/dist/server-adapter/index.js +2 -110
- package/dist/server-adapter/stdio_server_adapter.d.ts +17 -0
- package/dist/server-adapter/stdio_server_adapter.js +118 -0
- package/dist/server-adapter/stdio_server_adapter.test.d.ts +1 -0
- package/dist/server-adapter/{index.test.js → stdio_server_adapter.test.js} +1 -1
- package/dist/server-adapter/stdio_server_adapter_request_handler.d.ts +26 -0
- package/dist/server-adapter/stdio_server_adapter_request_handler.js +66 -0
- package/dist/server-adapter/stdio_server_adapter_request_handler.test.d.ts +1 -0
- package/dist/server-adapter/stdio_server_adapter_request_handler.test.js +148 -0
- package/package.json +12 -12
- /package/dist/{server-adapter/index.test.d.ts → handlers/handlers.test.d.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
|
|
2
|
+
import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamable_http_handler.js";
|
|
3
|
+
import { RequestHandler } from "./request_handler.js";
|
|
4
|
+
/**
|
|
5
|
+
* Handler for API Gateway V1 events (REST APIs)
|
|
6
|
+
*
|
|
7
|
+
* This handler processes APIGatewayProxyEvent events (Lambda proxy integration behind API Gateway REST API)
|
|
8
|
+
* and returns APIGatewayProxyResult responses.
|
|
9
|
+
*
|
|
10
|
+
* This class handles all the generic JSON-RPC protocol aspects of the MCP Streamable HTTP transport:
|
|
11
|
+
* - HTTP method validation (POST, OPTIONS, GET)
|
|
12
|
+
* - Content-Type and Accept header validation
|
|
13
|
+
* - JSON parsing and validation
|
|
14
|
+
* - Batch request handling
|
|
15
|
+
* - CORS headers
|
|
16
|
+
* - Error response formatting
|
|
17
|
+
* This class does not implement session management.
|
|
18
|
+
*
|
|
19
|
+
* The specific business logic is delegated to a provided RequestHandler implementation.
|
|
20
|
+
*/
|
|
21
|
+
export declare class APIGatewayProxyEventHandler extends StreamableHttpHandler<APIGatewayProxyEvent, APIGatewayProxyResult> {
|
|
22
|
+
constructor(requestHandler: RequestHandler);
|
|
23
|
+
/**
|
|
24
|
+
* Parse APIGatewayProxyEvent into common HTTP request format
|
|
25
|
+
*/
|
|
26
|
+
protected parseEvent(event: APIGatewayProxyEvent): ParsedHttpRequest;
|
|
27
|
+
/**
|
|
28
|
+
* Format HTTP response as APIGatewayProxyResult
|
|
29
|
+
*/
|
|
30
|
+
protected formatResponse(response: HttpResponse): APIGatewayProxyResult;
|
|
31
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StreamableHttpHandler, } from "./streamable_http_handler.js";
|
|
2
|
+
/**
|
|
3
|
+
* Handler for API Gateway V1 events (REST APIs)
|
|
4
|
+
*
|
|
5
|
+
* This handler processes APIGatewayProxyEvent events (Lambda proxy integration behind API Gateway REST API)
|
|
6
|
+
* and returns APIGatewayProxyResult responses.
|
|
7
|
+
*
|
|
8
|
+
* This class handles all the generic JSON-RPC protocol aspects of the MCP Streamable HTTP transport:
|
|
9
|
+
* - HTTP method validation (POST, OPTIONS, GET)
|
|
10
|
+
* - Content-Type and Accept header validation
|
|
11
|
+
* - JSON parsing and validation
|
|
12
|
+
* - Batch request handling
|
|
13
|
+
* - CORS headers
|
|
14
|
+
* - Error response formatting
|
|
15
|
+
* This class does not implement session management.
|
|
16
|
+
*
|
|
17
|
+
* The specific business logic is delegated to a provided RequestHandler implementation.
|
|
18
|
+
*/
|
|
19
|
+
export class APIGatewayProxyEventHandler extends StreamableHttpHandler {
|
|
20
|
+
constructor(requestHandler) {
|
|
21
|
+
super(requestHandler);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse APIGatewayProxyEvent into common HTTP request format
|
|
25
|
+
*/
|
|
26
|
+
parseEvent(event) {
|
|
27
|
+
return {
|
|
28
|
+
method: event.httpMethod,
|
|
29
|
+
headers: event.headers || {},
|
|
30
|
+
body: event.body || null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Format HTTP response as APIGatewayProxyResult
|
|
35
|
+
*/
|
|
36
|
+
formatResponse(response) {
|
|
37
|
+
return {
|
|
38
|
+
statusCode: response.statusCode,
|
|
39
|
+
headers: response.headers,
|
|
40
|
+
body: response.body,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from "aws-lambda";
|
|
2
|
+
import { StreamableHttpHandler, ParsedHttpRequest, HttpResponse } from "./streamable_http_handler.js";
|
|
3
|
+
import { RequestHandler } from "./request_handler.js";
|
|
4
|
+
/**
|
|
5
|
+
* Handler for API Gateway V2 events (HTTP APIs)
|
|
6
|
+
*
|
|
7
|
+
* This handler processes APIGatewayProxyEventV2 events and returns APIGatewayProxyResultV2 responses.
|
|
8
|
+
*
|
|
9
|
+
* This class handles all the generic JSON-RPC protocol aspects of the MCP Streamable HTTP transport:
|
|
10
|
+
* - HTTP method validation (POST, OPTIONS, GET)
|
|
11
|
+
* - Content-Type and Accept header validation
|
|
12
|
+
* - JSON parsing and validation
|
|
13
|
+
* - Batch request handling
|
|
14
|
+
* - CORS headers
|
|
15
|
+
* - Error response formatting
|
|
16
|
+
* This class does not implement session management.
|
|
17
|
+
*
|
|
18
|
+
* The specific business logic is delegated to a provided RequestHandler implementation.
|
|
19
|
+
*/
|
|
20
|
+
export declare class APIGatewayProxyEventV2Handler extends StreamableHttpHandler<APIGatewayProxyEventV2, APIGatewayProxyResultV2> {
|
|
21
|
+
constructor(requestHandler: RequestHandler);
|
|
22
|
+
/**
|
|
23
|
+
* Parse APIGatewayProxyEventV2 into common HTTP request format
|
|
24
|
+
*/
|
|
25
|
+
protected parseEvent(event: APIGatewayProxyEventV2): ParsedHttpRequest;
|
|
26
|
+
/**
|
|
27
|
+
* Format HTTP response as APIGatewayProxyResultV2
|
|
28
|
+
*/
|
|
29
|
+
protected formatResponse(response: HttpResponse): APIGatewayProxyResultV2;
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StreamableHttpHandler, } from "./streamable_http_handler.js";
|
|
2
|
+
/**
|
|
3
|
+
* Handler for API Gateway V2 events (HTTP APIs)
|
|
4
|
+
*
|
|
5
|
+
* This handler processes APIGatewayProxyEventV2 events and returns APIGatewayProxyResultV2 responses.
|
|
6
|
+
*
|
|
7
|
+
* This class handles all the generic JSON-RPC protocol aspects of the MCP Streamable HTTP transport:
|
|
8
|
+
* - HTTP method validation (POST, OPTIONS, GET)
|
|
9
|
+
* - Content-Type and Accept header validation
|
|
10
|
+
* - JSON parsing and validation
|
|
11
|
+
* - Batch request handling
|
|
12
|
+
* - CORS headers
|
|
13
|
+
* - Error response formatting
|
|
14
|
+
* This class does not implement session management.
|
|
15
|
+
*
|
|
16
|
+
* The specific business logic is delegated to a provided RequestHandler implementation.
|
|
17
|
+
*/
|
|
18
|
+
export class APIGatewayProxyEventV2Handler extends StreamableHttpHandler {
|
|
19
|
+
constructor(requestHandler) {
|
|
20
|
+
super(requestHandler);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parse APIGatewayProxyEventV2 into common HTTP request format
|
|
24
|
+
*/
|
|
25
|
+
parseEvent(event) {
|
|
26
|
+
return {
|
|
27
|
+
method: event.requestContext.http.method,
|
|
28
|
+
headers: event.headers || {},
|
|
29
|
+
body: event.body || null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Format HTTP response as APIGatewayProxyResultV2
|
|
34
|
+
*/
|
|
35
|
+
formatResponse(response) {
|
|
36
|
+
return {
|
|
37
|
+
statusCode: response.statusCode,
|
|
38
|
+
headers: response.headers,
|
|
39
|
+
body: response.body,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|