@@ -37,29 +37,29 @@ flowchart LR
3737
3838## Considerations
3939
40- * This package currently supports MCP servers and clients written in Python and Typescript.
41- Other languages such as Kotlin are not supported.
42- * The server adapters only adapt stdio MCP servers, not servers written for other protocols such as SSE.
43- * The server adapters does not maintain any MCP server state across Lambda function invocations.
44- Only stateless MCP servers are a good fit for using this adapter. For example, MCP servers
45- that invoke stateless tools like the [ time MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/time )
46- or make stateless web requests like the [ fetch MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/fetch ) .
47- Stateful MCP servers are not a good fit, because they will lose their state on every request.
48- For example, MCP servers that manage data on disk or in memory such as
49- the [ sqlite MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite ) ,
50- the [ filesystem MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem ) ,
51- and the [ git MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/git ) .
52- * The server adapters ignore any MCP protocol notifications from the client to the server.
53- * The server adapters do not provide mechanisms for managing any secrets needed by the wrapped
54- MCP server. For example, the [ GitHub MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/github )
55- and the [ Brave search MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search )
56- require API keys to make requests to third-party APIs.
57- You can configure these API keys as
58- [ encrypted environment variables] ( https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars-encryption.html )
59- in the Lambda function's configuration. However, note that anyone with access to invoke the Lambda function
60- will then have access to use your API key to call the third-party APIs by invoking the function.
61- We recommend limiting access to the Lambda function using
62- [ least-privilege IAM policies] ( https://docs.aws.amazon.com/lambda/latest/dg/security-iam.html ) .
40+ - This package currently supports MCP servers and clients written in Python and Typescript.
41+ Other languages such as Kotlin are not supported.
42+ - The server adapters only adapt stdio MCP servers, not servers written for other protocols such as SSE.
43+ - The server adapters does not maintain any MCP server state across Lambda function invocations.
44+ Only stateless MCP servers are a good fit for using this adapter. For example, MCP servers
45+ that invoke stateless tools like the [ time MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/time )
46+ or make stateless web requests like the [ fetch MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/fetch ) .
47+ Stateful MCP servers are not a good fit, because they will lose their state on every request.
48+ For example, MCP servers that manage data on disk or in memory such as
49+ the [ sqlite MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite ) ,
50+ the [ filesystem MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem ) ,
51+ and the [ git MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/git ) .
52+ - The server adapters ignore any MCP protocol notifications from the client to the server.
53+ - The server adapters do not provide mechanisms for managing any secrets needed by the wrapped
54+ MCP server. For example, the [ GitHub MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/github )
55+ and the [ Brave search MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search )
56+ require API keys to make requests to third-party APIs.
57+ You can configure these API keys as
58+ [ encrypted environment variables] ( https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars-encryption.html )
59+ in the Lambda function's configuration. However, note that anyone with access to invoke the Lambda function
60+ will then have access to use your API key to call the third-party APIs by invoking the function.
61+ We recommend limiting access to the Lambda function using
62+ [ least-privilege IAM policies] ( https://docs.aws.amazon.com/lambda/latest/dg/security-iam.html ) .
6363
6464## Examples
6565
@@ -72,6 +72,7 @@ that runs the simple
7272The Lambda function bundles the [ mcp-server-time package] ( https://pypi.org/project/mcp-server-time/ ) .
7373On each function invocation, the Lambda function will manage the lifecycle of the bundled MCP server.
7474It will:
75+
75761 . start the 'time' MCP server as a child process
76771 . initialize the MCP server
77781 . forward the incoming request to the local server
@@ -107,19 +108,20 @@ to provide a single API from [weather.gov](https://www.weather.gov/documentation
107108The Lambda function bundles the [ openapi-mcp-server package] ( https://www.npmjs.com/package/openapi-mcp-server ) .
108109On each function invocation, the Lambda function will manage the lifecycle of the bundled MCP server.
109110It will:
111+
1101121 . start the 'openapi-mcp-server' MCP server as a child process
1111131 . initialize the MCP server
1121141 . forward the incoming request to the local server
1131151 . return the server's response to the function caller
1141161 . shut down the MCP server child process
115117
116118``` typescript
117- import { Handler , Context } from ' aws-lambda' ;
118- import { stdioServerAdapter } from ' mcp-lambda' ;
119+ import { Handler , Context } from " aws-lambda" ;
120+ import { stdioServerAdapter } from " mcp-lambda" ;
119121
120122const serverParams = {
121- command: ' npx' ,
122- args: [' --offline' , ' openapi-mcp-server' , ' ./weather-alerts-openapi.json' ],
123+ command: " npx" ,
124+ args: [" --offline" , " openapi-mcp-server" , " ./weather-alerts-openapi.json" ],
123125};
124126
125127export const handler: Handler = async (event , context : Context ) => {
@@ -205,7 +207,7 @@ npm run build
205207cdk deploy --app ' node lib/weather-alerts-mcp-server.js'
206208```
207209
208- Run the chatbot client:
210+ Run the Python-based chatbot client:
209211
210212``` bash
211213cd examples/chatbot/
@@ -215,7 +217,22 @@ uv pip install -r requirements.txt
215217python main.py
216218```
217219
220+ Alternatively, run the Typescript-based chatbot client:
221+
222+ ``` bash
223+ cd examples/chatbot-typescript/
224+
225+ npm install
226+
227+ npm link mcp-lambda
228+
229+ npm run build
230+
231+ npm run start
232+ ```
233+
218234The chatbot client will communicate with three servers:
235+
2192361 . the Lambda function-based 'time' MCP server
2202372 . the Lambda function-based 'weather-alerts' MCP server
2212383 . a [ local 'fetch' MCP server] ( https://github.com/modelcontextprotocol/servers/tree/main/src/fetch )
0 commit comments