Skip to content

Commit 30fe751

Browse files
committed
feat: Examples for Bedrock AgentCore Gateway
1 parent 4c88ea4 commit 30fe751

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6423
-248
lines changed

.github/dependabot.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,46 @@ updates:
9090
prefix: "chore(deps)"
9191
rebase-strategy: "disabled"
9292

93+
- package-ecosystem: pip
94+
directory: "/examples/servers/book-search"
95+
schedule:
96+
interval: monthly
97+
open-pull-requests-limit: 10
98+
versioning-strategy: increase
99+
commit-message:
100+
prefix: "chore(deps)"
101+
rebase-strategy: "disabled"
102+
103+
- package-ecosystem: pip
104+
directory: "/examples/servers/book-search/function"
105+
schedule:
106+
interval: monthly
107+
open-pull-requests-limit: 10
108+
versioning-strategy: increase
109+
commit-message:
110+
prefix: "chore(deps)"
111+
rebase-strategy: "disabled"
112+
113+
- package-ecosystem: pip
114+
directory: "/examples/servers/book-search/gateway_setup"
115+
schedule:
116+
interval: monthly
117+
open-pull-requests-limit: 10
118+
versioning-strategy: increase
119+
commit-message:
120+
prefix: "chore(deps)"
121+
rebase-strategy: "disabled"
122+
123+
- package-ecosystem: pip
124+
directory: "/examples/servers/inspiration"
125+
schedule:
126+
interval: monthly
127+
open-pull-requests-limit: 10
128+
versioning-strategy: increase
129+
commit-message:
130+
prefix: "chore(deps)"
131+
rebase-strategy: "disabled"
132+
93133
- package-ecosystem: npm
94134
directory: "/src/typescript"
95135
schedule:
@@ -150,6 +190,26 @@ updates:
150190
prefix: "chore(deps)"
151191
rebase-strategy: "disabled"
152192

193+
- package-ecosystem: npm
194+
directory: "/examples/servers/dictionary"
195+
schedule:
196+
interval: monthly
197+
open-pull-requests-limit: 10
198+
versioning-strategy: increase
199+
commit-message:
200+
prefix: "chore(deps)"
201+
rebase-strategy: "disabled"
202+
203+
- package-ecosystem: npm
204+
directory: "/examples/servers/dictionary/gateway_setup"
205+
schedule:
206+
interval: monthly
207+
open-pull-requests-limit: 10
208+
versioning-strategy: increase
209+
commit-message:
210+
prefix: "chore(deps)"
211+
rebase-strategy: "disabled"
212+
153213
- package-ecosystem: npm
154214
directory: "/e2e_tests/typescript"
155215
schedule:

.github/workflows/cdk-checks.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,72 @@ jobs:
112112
env:
113113
CDK_DEFAULT_ACCOUNT: "000000000000"
114114

115+
check_book_search_server:
116+
name: Check Python-based Book Search Server
117+
runs-on: ubuntu-latest
118+
permissions:
119+
contents: read
120+
timeout-minutes: 15
121+
steps:
122+
- uses: actions/checkout@v4
123+
124+
- name: "Set up Typescript"
125+
uses: actions/setup-node@v4
126+
with:
127+
node-version: 20
128+
129+
- name: "Set up Python"
130+
uses: actions/setup-python@v5
131+
with:
132+
python-version-file: "src/python/.python-version"
133+
134+
- name: Install CDK CLI
135+
run: npm install -g aws-cdk
136+
137+
- name: Install dependencies
138+
run: pip install -r requirements.txt
139+
working-directory: ./examples/servers/book-search
140+
141+
- uses: pypa/[email protected]
142+
with:
143+
inputs: ./examples/servers/book-search/requirements.txt
144+
145+
- name: Synthesize CDK stack
146+
run: cdk synth --app 'python3 cdk_stack.py'
147+
working-directory: ./examples/servers/book-search
148+
env:
149+
CDK_DEFAULT_ACCOUNT: "000000000000"
150+
151+
- name: Install gateway setup dependencies
152+
run: pip install -r requirements.txt
153+
working-directory: ./examples/servers/book-search/gateway_setup
154+
155+
- uses: pypa/[email protected]
156+
with:
157+
inputs: ./examples/servers/book-search/gateway_setup/requirements.txt
158+
159+
check_inspiration_server:
160+
name: Check Python-based Inspiration Server
161+
runs-on: ubuntu-latest
162+
permissions:
163+
contents: read
164+
timeout-minutes: 15
165+
steps:
166+
- uses: actions/checkout@v4
167+
168+
- name: "Set up Python"
169+
uses: actions/setup-python@v5
170+
with:
171+
python-version-file: "src/python/.python-version"
172+
173+
- name: Install gateway setup dependencies
174+
run: pip install -r requirements.txt
175+
working-directory: ./examples/servers/inspiration
176+
177+
- uses: pypa/[email protected]
178+
with:
179+
inputs: ./examples/servers/inspiration/requirements.txt
180+
115181
check_auth_stack:
116182
name: Check Typescript-based Cognito stack
117183
runs-on: ubuntu-latest
@@ -273,3 +339,55 @@ jobs:
273339
working-directory: ./examples/servers/dog-facts
274340
env:
275341
CDK_DEFAULT_ACCOUNT: "000000000000"
342+
343+
check_dictionary_server:
344+
name: Check Typescript-based Dictionary Server
345+
runs-on: ubuntu-latest
346+
permissions:
347+
contents: read
348+
timeout-minutes: 15
349+
steps:
350+
- uses: actions/checkout@v4
351+
352+
- name: "Set up Typescript"
353+
uses: actions/setup-node@v4
354+
with:
355+
node-version: 20
356+
357+
- name: Install CDK CLI
358+
run: npm install -g aws-cdk
359+
360+
- name: Build and link local package
361+
run: |
362+
npm ci
363+
npm audit --audit-level critical
364+
npm run build
365+
npm link
366+
working-directory: ./src/typescript
367+
368+
- name: Install dependencies
369+
run: |
370+
npm ci
371+
npm audit --audit-level critical
372+
npm link @aws/run-mcp-servers-with-aws-lambda
373+
working-directory: ./examples/servers/dictionary
374+
375+
- name: Build
376+
run: npm run build
377+
working-directory: ./examples/servers/dictionary
378+
379+
- name: Synthesize CDK stack
380+
run: cdk synth --app 'node lib/dictionary-mcp-server.js'
381+
working-directory: ./examples/servers/dictionary
382+
env:
383+
CDK_DEFAULT_ACCOUNT: "000000000000"
384+
385+
- name: Install gateway dependencies
386+
run: |
387+
npm ci
388+
npm audit --audit-level critical
389+
working-directory: ./examples/servers/dictionary/gateway_setup
390+
391+
- name: Build gateway scripts
392+
run: npm run build
393+
working-directory: ./examples/servers/dictionary/gateway_setup

.versionrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@
5858
"filename": "examples/servers/dog-facts/package-lock.json",
5959
"type": "json"
6060
},
61+
{
62+
"filename": "examples/servers/dictionary/package.json",
63+
"type": "json"
64+
},
65+
{
66+
"filename": "examples/servers/dictionary/package-lock.json",
67+
"type": "json"
68+
},
69+
{
70+
"filename": "examples/servers/dictionary/gateway_setup/package.json",
71+
"type": "json"
72+
},
73+
{
74+
"filename": "examples/servers/dictionary/gateway_setup/package-lock.json",
75+
"type": "json"
76+
},
6177
{
6278
"filename": "examples/chatbots/typescript/package.json",
6379
"type": "json"

DEVELOP.md

Lines changed: 94 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,34 @@ This guide will walk you through building the source code in this repository,
66
deploying example MCP servers in Lambda functions,
77
and using an example chatbot client to communicate with those Lambda-based MCP servers.
88

9-
The example chatbot client will communicate with seven servers:
9+
The example chatbot client will communicate with ten servers:
1010

1111
1. **dad-jokes**: Ask "Tell me a good dad joke."
1212
2. **dog-facts**: Ask "Tell me something about dogs."
13-
3. **mcpdoc**: Ask "Summarize the first page of the Strands Agents documentation."
14-
4. **cat-facts**: Ask "Tell me something about cats."
15-
5. **time**: Ask "What is the current time?".
16-
6. **weather-alerts**: Ask "Are there any weather alerts right now?".
17-
7. **fetch**: Ask "Who is Tom Cruise?".
18-
19-
| MCP server | Language | Runtime | MCP transport | Authentication | Endpoint |
20-
| --------------------------------------------------- | ---------- | ------------- | --------------------------------------------------- | -------------- | ------------------- |
21-
| [dad-jokes](/examples/servers/dad-jokes/) | Python | Lambda | Streamable HTTP transport | OAuth | API Gateway |
22-
| [dog-facts](/examples/servers/dog-facts/) | Typescript | Lambda | Streamable HTTP transport | OAuth | API Gateway |
23-
| [mcpdoc ](/examples/servers/mcpdoc/) | Python | Lambda | Custom Streamable HTTP transport with SigV4 support | AWS IAM | Lambda Function URL |
24-
| [cat-facts](/examples/servers/cat-facts/) | Typescript | Lambda | Custom Streamable HTTP transport with SigV4 support | AWS IAM | Lambda Function URL |
25-
| [time](/examples/servers/time/) | Python | Lambda | Custom Lambda Invoke transport | AWS IAM | Lambda Invoke API |
26-
| [weather-alerts](/examples/servers/weather-alerts/) | Typescript | Lambda | Custom Lambda Invoke transport | AWS IAM | Lambda Invoke API |
27-
| [fetch](https://pypi.org/project/mcp-server-fetch/) | Python | Local process | stdio | N/A | N/A |
13+
3. **book-search**: Ask "Who wrote the book Pride and Prejudice?"
14+
4. **dictionary**: Ask "How do you pronounce the word 'onomatopoeia'?"
15+
5. **inspiration**: Ask "Tell me the inspirational quote of the day."
16+
6. **mcpdoc**: Ask "Summarize the first page of the Strands Agents documentation."
17+
7. **cat-facts**: Ask "Tell me something about cats."
18+
8. **time**: Ask "What is the current time?".
19+
9. **weather-alerts**: Ask "Are there any weather alerts right now?".
20+
10. **fetch**: Ask "Who is Tom Cruise?".
21+
22+
| MCP server | Language | Runtime | MCP transport | Authentication | Endpoint |
23+
| --------------------------------------------------- | ---------- | ------------- | --------------------------------------------------- | -------------- | ------------------------- |
24+
| [dad-jokes](/examples/servers/dad-jokes/) | Python | Lambda | Streamable HTTP transport | OAuth | API Gateway |
25+
| [dog-facts](/examples/servers/dog-facts/) | Typescript | Lambda | Streamable HTTP transport | OAuth | API Gateway |
26+
| [book-search](/examples/servers/book-search/) | Python | Lambda | Streamable HTTP transport | OAuth | Bedrock AgentCore Gateway |
27+
| [dictionary](/examples/servers/dictionary/) | Typescript | Lambda | Streamable HTTP transport | OAuth | Bedrock AgentCore Gateway |
28+
| [inspiration](/examples/servers/inspiration/) | N/A | None | Streamable HTTP transport | OAuth | Bedrock AgentCore Gateway |
29+
| [mcpdoc](/examples/servers/mcpdoc/) | Python | Lambda | Custom Streamable HTTP transport with SigV4 support | AWS IAM | Lambda Function URL |
30+
| [cat-facts](/examples/servers/cat-facts/) | Typescript | Lambda | Custom Streamable HTTP transport with SigV4 support | AWS IAM | Lambda Function URL |
31+
| [time](/examples/servers/time/) | Python | Lambda | Custom Lambda Invoke transport | AWS IAM | Lambda Invoke API |
32+
| [weather-alerts](/examples/servers/weather-alerts/) | Typescript | Lambda | Custom Lambda Invoke transport | AWS IAM | Lambda Invoke API |
33+
| [fetch](https://pypi.org/project/mcp-server-fetch/) | Python | Local process | stdio | N/A | N/A |
34+
35+
Note: The 'inspiration' MCP server uses Bedrock AgentCore Gateway's built-in support for OpenAPI targets,
36+
so there is no Lambda function in that example.
2837

2938
### Setup
3039

@@ -47,6 +56,15 @@ aws iam attach-role-policy \
4756
--role-name mcp-lambda-example-servers \
4857
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
4958

59+
aws iam create-role \
60+
--role-name mcp-lambda-example-agentcore-gateways \
61+
--assume-role-policy-document file://examples/servers/bedrock-agentcore-gateway-assume-role-policy.json
62+
63+
aws iam put-role-policy \
64+
--role-name mcp-lambda-example-agentcore-gateways \
65+
--policy-name bedrock-agentcore-full-access \
66+
--policy-document file://examples/servers/bedrock-agentcore-gateway-role-policy.json
67+
5068
cdk bootstrap aws://<aws account id>/us-west-2
5169
```
5270

@@ -148,6 +166,66 @@ npm run build
148166
cdk deploy --app 'node lib/dog-facts-mcp-server.js'
149167
```
150168

169+
#### Deploy book-search MCP server
170+
171+
Deploy the Lambda 'book-search' function - the deployed function will be named "mcp-server-book-search".
172+
173+
```bash
174+
cd examples/servers/book-search/
175+
176+
uv pip install -r requirements.txt
177+
178+
cdk deploy --app 'python3 cdk_stack.py'
179+
```
180+
181+
Then, deploy the Bedrock AgentCore Gateway:
182+
183+
```bash
184+
cd gateway_setup/
185+
186+
uv pip install -r requirements.txt
187+
188+
python setup_gateway.py
189+
```
190+
191+
#### Deploy dictionary MCP server
192+
193+
Deploy the Lambda 'dictionary' function - the deployed function will be named "mcp-server-dictionary".
194+
195+
```bash
196+
cd examples/servers/dictionary/
197+
198+
npm install
199+
200+
npm link @aws/run-mcp-servers-with-aws-lambda
201+
202+
npm run build
203+
204+
cdk deploy --app 'node lib/dictionary-mcp-server.js'
205+
```
206+
207+
Them, deploy the Bedrock AgentCore Gateway:
208+
209+
```bash
210+
cd gateway_setup/
211+
212+
npm install
213+
214+
npm run setup
215+
```
216+
217+
#### Deploy inspiration MCP server
218+
219+
Deploy the 'inspiration' Bedrock AgentCore Gateway.
220+
221+
```bash
222+
cd examples/servers/inspiration/
223+
224+
uv pip install -r requirements.txt
225+
226+
python setup_gateway.py
227+
```
228+
151229
#### Deploy the mcpdoc MCP server
152230

153231
Deploy the Lambda 'mcpdoc' function - the deployed function will be named "mcp-server-mcpdoc".

0 commit comments

Comments
 (0)