Skip to content

Commit 7b43188

Browse files
committed
Add consideration about existing MCP clients, move build/deploy instructions out into a separate guide
1 parent a40191f commit 7b43188

File tree

2 files changed

+137
-109
lines changed

2 files changed

+137
-109
lines changed

DEVELOP.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
## Deploy and run the examples
2+
3+
This guide will walk you through building the source code in this repository,
4+
deploying example MCP servers in Lambda functions,
5+
and using an example chatbot client to communicate with those Lambda-based MCP servers.
6+
7+
The example chatbot client will communicate with three servers:
8+
9+
1. a Lambda function-based 'time' MCP server (Python)
10+
2. a Lambda function-based 'weather-alerts' MCP server (Typescript)
11+
3. a [local 'fetch' MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch)
12+
13+
To use the remote 'time' server, you can ask the chatbot questions like "What is the current time?".
14+
15+
To use the remote 'weather-alerts' server, you can ask the chatbot questions like "Are there any weather alerts right now?".
16+
17+
To use the local 'fetch' server, you can ask questions like "Who is Tom Cruise?".
18+
19+
### Setup
20+
21+
First, install the [AWS CDK CLI](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install).
22+
23+
Request [Bedrock model access](https://us-west-2.console.aws.amazon.com/bedrock/home?region=us-west-2#/modelaccess)
24+
to Anthropic Claude 3.5 Sonnet v2 in region us-west-2.
25+
26+
Create an IAM role for the example Lambda functions and bootstrap the account for CDK:
27+
28+
```bash
29+
aws iam create-role \
30+
--role-name mcp-lambda-example-servers \
31+
--assume-role-policy-document file://examples/servers/lambda-assume-role-policy.json
32+
33+
aws iam attach-role-policy \
34+
--role-name mcp-lambda-example-servers \
35+
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
36+
37+
cdk bootstrap aws://<aws account id>/us-east-2
38+
```
39+
40+
### Build the Python module
41+
42+
Install the mcp-lambda Python module from source:
43+
44+
```bash
45+
cd src/python/
46+
47+
uv venv
48+
source .venv/bin/activate
49+
50+
uv sync --all-extras --dev
51+
52+
# For development
53+
uv run ruff check .
54+
uv run pyright
55+
uv run pytest
56+
```
57+
58+
### Build the Typescript package
59+
60+
Build the mcp-lambda Typescript module:
61+
62+
```bash
63+
cd src/typescript/
64+
65+
npm install
66+
67+
npm run build
68+
69+
npm link
70+
```
71+
72+
### Deploy the example Python server
73+
74+
Deploy the Lambda 'time' function - the deployed function will be named "mcp-server-time".
75+
76+
```bash
77+
cd examples/servers/time/
78+
79+
uv pip install -r requirements.txt
80+
81+
cdk deploy --app 'python3 cdk_stack.py'
82+
```
83+
84+
### Deploy the example Typescript server
85+
86+
Deploy the Lambda 'weather-alerts' function - the deployed function will be named "mcp-server-weather-alerts".
87+
88+
```bash
89+
cd examples/servers/weather-alerts/
90+
91+
npm install
92+
93+
npm link mcp-lambda
94+
95+
npm run build
96+
97+
cdk deploy --app 'node lib/weather-alerts-mcp-server.js'
98+
```
99+
100+
### Run the example Python client
101+
102+
Run the Python-based chatbot client:
103+
104+
```bash
105+
cd examples/chatbots/python/
106+
107+
uv pip install -r requirements.txt
108+
109+
python main.py
110+
```
111+
112+
### Run the example Typescript client
113+
114+
Run the Typescript-based chatbot client:
115+
116+
```bash
117+
cd examples/chatbots/typescript/
118+
119+
npm install
120+
121+
npm link mcp-lambda
122+
123+
npm run build
124+
125+
npm run start
126+
```

README.md

Lines changed: 11 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Utilities for Model Context Protocol (MCP) with AWS Lambda
1+
# Run Model Context Protocol (MCP) servers in AWS Lambda
22

3-
This project enables you to run [Model Context Protocol](https://modelcontextprotocol.io) servers in AWS Lambda functions.
3+
This project enables you to run [Model Context Protocol](https://modelcontextprotocol.io) stdio-based servers in AWS Lambda functions.
44

55
Currently, most implementations of MCP servers and clients are entirely local on a single machine.
66
A desktop application such as an IDE or Claude Desktop initiates MCP servers locally as child processes
@@ -22,7 +22,8 @@ You can invoke these function-based MCP servers from your application using the
2222
over short-lived connections.
2323
Your application can then be a desktop-based app, a distributed system running in the cloud,
2424
or any other architecture.
25-
The only requirement is that your application has access to invoke your Lambda functions.
25+
Your application must have access to invoke your Lambda functions,
26+
and use the custom MCP client transport that invokes the Lambda functions.
2627

2728
```mermaid
2829
flowchart LR
@@ -37,6 +38,12 @@ flowchart LR
3738

3839
## Considerations
3940

41+
- This package currently requires using a custom MCP client transport to communicate with the MCP
42+
server by invoking the Lambda function. Existing applications with MCP support such as
43+
Amazon Q Developer CLI, Cline, etc do not have this custom transport, and cannot communicate with
44+
MCP servers adapted into Lambda functions.
45+
Note: with [upcoming changes to the MCP protocol](https://github.com/modelcontextprotocol/specification/pull/206),
46+
we expect that this limitation will be removed in the future.
4047
- This package currently supports MCP servers and clients written in Python and Typescript.
4148
Other languages such as Kotlin are not supported.
4249
- The server adapters only adapt stdio MCP servers, not servers written for other protocols such as SSE.
@@ -176,112 +183,7 @@ await this.client.connect(transport);
176183

177184
### Deploy and run the examples
178185

179-
First, install the [AWS CDK CLI](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install).
180-
181-
Request [Bedrock model access](https://us-west-2.console.aws.amazon.com/bedrock/home?region=us-west-2#/modelaccess)
182-
to Anthropic Claude 3.5 Sonnet v2 in region us-west-2.
183-
184-
Install the mcp-lambda Python module from source:
185-
186-
```bash
187-
cd src/python/
188-
189-
uv venv
190-
source .venv/bin/activate
191-
192-
uv sync --all-extras --dev
193-
194-
# For development
195-
uv run ruff check .
196-
uv run pyright
197-
uv run pytest
198-
```
199-
200-
Create an IAM role for the example Lambda functions and bootstrap the account for CDK:
201-
202-
```bash
203-
aws iam create-role \
204-
--role-name mcp-lambda-example-servers \
205-
--assume-role-policy-document file://examples/servers/lambda-assume-role-policy.json
206-
207-
aws iam attach-role-policy \
208-
--role-name mcp-lambda-example-servers \
209-
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
210-
211-
cdk bootstrap aws://<aws account id>/us-east-2
212-
```
213-
214-
Deploy the Lambda 'time' function - the deployed function will be named "mcp-server-time".
215-
216-
```bash
217-
cd examples/servers/time/
218-
219-
uv pip install -r requirements.txt
220-
221-
cdk deploy --app 'python3 cdk_stack.py'
222-
```
223-
224-
Build the mcp-lambda Typescript module:
225-
226-
```bash
227-
cd src/typescript/
228-
229-
npm install
230-
231-
npm run build
232-
233-
npm link
234-
```
235-
236-
Deploy the Lambda 'weather-alerts' function - the deployed function will be named "mcp-server-weather-alerts".
237-
238-
```bash
239-
cd examples/servers/weather-alerts/
240-
241-
npm install
242-
243-
npm link mcp-lambda
244-
245-
npm run build
246-
247-
cdk deploy --app 'node lib/weather-alerts-mcp-server.js'
248-
```
249-
250-
Run the Python-based chatbot client:
251-
252-
```bash
253-
cd examples/chatbots/python/
254-
255-
uv pip install -r requirements.txt
256-
257-
python main.py
258-
```
259-
260-
Alternatively, run the Typescript-based chatbot client:
261-
262-
```bash
263-
cd examples/chatbots/typescript/
264-
265-
npm install
266-
267-
npm link mcp-lambda
268-
269-
npm run build
270-
271-
npm run start
272-
```
273-
274-
The chatbot client will communicate with three servers:
275-
276-
1. the Lambda function-based 'time' MCP server
277-
2. the Lambda function-based 'weather-alerts' MCP server
278-
3. a [local 'fetch' MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch)
279-
280-
To use the remote 'time' server, you can ask the chatbot questions like "What is the current time?".
281-
282-
To use the remote 'weather-alerts' server, you can ask the chatbot questions like "Are there any weather alerts right now?".
283-
284-
To use the local 'fetch' server, you can ask questions like "Who is Tom Cruise?".
186+
See the [development guide](DEVELOP.md) for instructions to deploy and run the examples in this repository.
285187

286188
## Security
287189

0 commit comments

Comments
 (0)