Skip to content

Commit 88036b0

Browse files
committed
Instructions for Typescript-based chatbot client
1 parent 1a616a1 commit 88036b0

File tree

3 files changed

+45
-168
lines changed

3 files changed

+45
-168
lines changed

README.md

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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
7272
The Lambda function bundles the [mcp-server-time package](https://pypi.org/project/mcp-server-time/).
7373
On each function invocation, the Lambda function will manage the lifecycle of the bundled MCP server.
7474
It will:
75+
7576
1. start the 'time' MCP server as a child process
7677
1. initialize the MCP server
7778
1. 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
107108
The Lambda function bundles the [openapi-mcp-server package](https://www.npmjs.com/package/openapi-mcp-server).
108109
On each function invocation, the Lambda function will manage the lifecycle of the bundled MCP server.
109110
It will:
111+
110112
1. start the 'openapi-mcp-server' MCP server as a child process
111113
1. initialize the MCP server
112114
1. forward the incoming request to the local server
113115
1. return the server's response to the function caller
114116
1. 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

120122
const 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

125127
export const handler: Handler = async (event, context: Context) => {
@@ -205,7 +207,7 @@ npm run build
205207
cdk 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
211213
cd examples/chatbot/
@@ -215,7 +217,22 @@ uv pip install -r requirements.txt
215217
python 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+
218234
The chatbot client will communicate with three servers:
235+
219236
1. the Lambda function-based 'time' MCP server
220237
2. the Lambda function-based 'weather-alerts' MCP server
221238
3. a [local 'fetch' MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch)

examples/chatbot-typescript/README.md

Lines changed: 0 additions & 71 deletions
This file was deleted.

examples/chatbot/README.md

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)