@aws/run-mcp-servers-with-aws-lambda 0.4.6 → 0.4.8

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/README.md CHANGED
@@ -53,6 +53,103 @@ This library supports connecting to Lambda-based MCP servers in four ways:
53
53
  1. A custom Streamable HTTP transport with support for SigV4, using a Lambda function URL. Authenticated with AWS IAM.
54
54
  1. A custom Lambda invocation transport, using the Lambda Invoke API directly. Authenticated with AWS IAM.
55
55
 
56
+ ## Determine your server parameters
57
+
58
+ Many stdio-based MCP servers's documentation encourages using tools that download and run the server on-demand.
59
+ For example, `uvx my-mcp-server` or `npx my-mcp-server`.
60
+ These tools are often not pre-packaged in the Lambda environment, and it can be inefficient to
61
+ re-download the server on every Lambda invocation.
62
+
63
+ Instead, the examples in this repository show how to package the MCP server along with
64
+ the Lambda function code, then start it with `python` or `node` (or `npx --offline`) directly.
65
+
66
+ You will need to determine the right parameters depending on your MCP server's package.
67
+ This can often be a trial and error process locally, since MCP server packaging varies.
68
+
69
+ <details>
70
+
71
+ <summary><b>Python server examples</b></summary>
72
+
73
+ Basic example:
74
+
75
+ ```python
76
+ from mcp.client.stdio import StdioServerParameters
77
+
78
+ server_params = StdioServerParameters(
79
+ command=sys.executable,
80
+ args=[
81
+ "-m",
82
+ "my_mcp_server_python_module",
83
+ "--my-server-command-line-parameter",
84
+ "some_value",
85
+ ],
86
+ )
87
+ ```
88
+
89
+ Locally, you would run this module using:
90
+
91
+ ```bash
92
+ python -m my_mcp_server_python_module --my-server-command-line-parameter some_value
93
+ ```
94
+
95
+ Other examples:
96
+
97
+ ```bash
98
+ python -m mcpdoc.cli # Note the sub-module
99
+
100
+ python -c "from mcp_openapi_proxy import main; main()"
101
+
102
+ python -c "import asyncio; from postgres_mcp.server import main; asyncio.run(main())"
103
+ ```
104
+
105
+ If you use Lambda layers, you need to also set the PYTHONPATH for the python sub-process:
106
+
107
+ ```python
108
+ lambda_paths = ["/opt/python"] + sys.path
109
+ env_config = {"PYTHONPATH": ":".join(lambda_paths)}
110
+
111
+ server_params = StdioServerParameters(
112
+ command=sys.executable,
113
+ args=[
114
+ "-c",
115
+ "from mcp_openapi_proxy import main; main()",
116
+ ],
117
+ env=env_config,
118
+ )
119
+ ```
120
+ </details>
121
+
122
+ <details>
123
+
124
+ <summary><b>Typescript server examples</b></summary>
125
+
126
+ Basic example:
127
+
128
+ ```typescript
129
+ const serverParams = {
130
+ command: "npx",
131
+ args: [
132
+ "--offline",
133
+ "my-mcp-server-typescript-module",
134
+ "--my-server-command-line-parameter",
135
+ "some_value",
136
+ ],
137
+ };
138
+ ```
139
+
140
+ Locally, you would run this module using:
141
+
142
+ ```bash
143
+ npx --offline my-mcp-server-typescript-module --my-server-command-line-parameter some_value
144
+ ```
145
+
146
+ Other examples:
147
+ ```bash
148
+ node /var/task/node_modules/@ivotoby/openapi-mcp-server/bin/mcp-server.js
149
+ ```
150
+
151
+ </details>
152
+
56
153
  ## Use API Gateway
57
154
 
58
155
  ```mermaid
@@ -72,21 +72,8 @@ function createMockAPIGatewayProxyEvent(httpMethod, body = null, headers = {}) {
72
72
  requestTimeEpoch: 1672531200,
73
73
  authorizer: {},
74
74
  identity: {
75
- cognitoIdentityPoolId: null,
76
- accountId: null,
77
- cognitoIdentityId: null,
78
- caller: null,
79
75
  sourceIp: "127.0.0.1",
80
- principalOrgId: null,
81
- accessKey: null,
82
- cognitoAuthenticationType: null,
83
- cognitoAuthenticationProvider: null,
84
- userArn: null,
85
76
  userAgent: "test-agent",
86
- user: null,
87
- apiKey: null,
88
- apiKeyId: null,
89
- clientCert: null,
90
77
  },
91
78
  resourceId: "test-resource",
92
79
  resourcePath: "/test",
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.6",
4
+ "version": "0.4.8",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "author": {
@@ -39,11 +39,11 @@
39
39
  "dist"
40
40
  ],
41
41
  "devDependencies": {
42
- "@eslint/js": "^9.37.0",
43
- "@tsconfig/recommended": "^1.0.10",
44
- "@types/aws-lambda": "^8.10.156",
42
+ "@eslint/js": "^9.39.0",
43
+ "@tsconfig/recommended": "^1.0.11",
44
+ "@types/aws-lambda": "^8.10.157",
45
45
  "@types/jest": "^30.0.0",
46
- "@types/node": "^24.7.2",
46
+ "@types/node": "^24.9.2",
47
47
  "aws-sdk-client-mock": "^4.1.0",
48
48
  "aws-sdk-client-mock-jest": "^4.1.0",
49
49
  "eslint": "^9.37.0",
@@ -52,16 +52,16 @@
52
52
  "ts-jest": "^29.4.5",
53
53
  "tsx": "^4.20.6",
54
54
  "typescript": "^5.9.3",
55
- "typescript-eslint": "^8.46.1"
55
+ "typescript-eslint": "^8.46.2"
56
56
  },
57
57
  "dependencies": {
58
58
  "@aws-crypto/sha256-js": "^5.2.0",
59
- "@aws-sdk/client-lambda": "^3.913.0",
59
+ "@aws-sdk/client-lambda": "^3.922.0",
60
60
  "@aws-sdk/credential-provider-node": "^3.913.0",
61
61
  "@aws-sdk/protocol-http": "^3.374.0",
62
62
  "@aws-sdk/types": "^3.910.0",
63
- "@modelcontextprotocol/sdk": "^1.20.0",
63
+ "@modelcontextprotocol/sdk": "^1.20.2",
64
64
  "@smithy/signature-v4": "^5.3.3",
65
- "winston": "^3.17.0"
65
+ "winston": "^3.18.3"
66
66
  }
67
67
  }