Skip to content

Commit 7c46144

Browse files
committed
feat: Python function handlers for streamable HTTP
Plus, Python-based dad jokes MCP server that is authenticated with OAuth
1 parent 11ab57c commit 7c46144

28 files changed

+2183
-13
lines changed

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ updates:
7070
prefix: "chore(deps)"
7171
rebase-strategy: "disabled"
7272

73+
- package-ecosystem: pip
74+
directory: "/examples/servers/dad-jokes"
75+
schedule:
76+
interval: monthly
77+
open-pull-requests-limit: 10
78+
versioning-strategy: increase
79+
commit-message:
80+
prefix: "chore(deps)"
81+
rebase-strategy: "disabled"
82+
83+
- package-ecosystem: pip
84+
directory: "/examples/servers/dad-jokes/function"
85+
schedule:
86+
interval: monthly
87+
open-pull-requests-limit: 10
88+
versioning-strategy: increase
89+
commit-message:
90+
prefix: "chore(deps)"
91+
rebase-strategy: "disabled"
92+
7393
- package-ecosystem: npm
7494
directory: "/src/typescript"
7595
schedule:

.github/workflows/cdk-checks.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,42 @@ jobs:
7676
env:
7777
CDK_DEFAULT_ACCOUNT: "000000000000"
7878

79+
check_dad_jokes_server:
80+
name: Check Python-based Dad Jokes Server
81+
runs-on: ubuntu-latest
82+
permissions:
83+
contents: read
84+
timeout-minutes: 15
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- name: "Set up Typescript"
89+
uses: actions/setup-node@v4
90+
with:
91+
node-version: 20
92+
93+
- name: "Set up Python"
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version-file: "src/python/.python-version"
97+
98+
- name: Install CDK CLI
99+
run: npm install -g aws-cdk
100+
101+
- name: Install dependencies
102+
run: pip install -r requirements.txt
103+
working-directory: ./examples/servers/dad-jokes
104+
105+
- uses: pypa/gh-action-pip-audit@v1.1.0
106+
with:
107+
inputs: ./examples/servers/dad-jokes/requirements.txt
108+
109+
- name: Synthesize CDK stack
110+
run: cdk synth --app 'python3 cdk_stack.py'
111+
working-directory: ./examples/servers/dad-jokes
112+
env:
113+
CDK_DEFAULT_ACCOUNT: "000000000000"
114+
79115
check_auth_stack:
80116
name: Check Typescript-based Cognito stack
81117
runs-on: ubuntu-latest

DEVELOP.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ 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 five servers:
9+
The example chatbot client will communicate with seven servers:
1010

1111
1. a Lambda function-based **time** MCP server (Python). Ask questions like "What is the current time?".
1212
2. a Lambda function-based **mcpdoc** MCP server (Python). Ask questions like "What documentation sources do you have access to?".
13-
3. a Lambda function-based **weather-alerts** MCP server (Typescript). Ask questions like "Are there any weather alerts right now?".
14-
4. a Lambda function-based **cat-facts** MCP server (Typescript). Ask questions like "Tell me something about cats".
15-
5. a Lambda function-based **dog-facts** MCP server (Typescript). Ask questions like "Tell me something about dogs".
16-
6. a [local **fetch** MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch). Ask questions like "Who is Tom Cruise?".
13+
3. a Lambda function-based **dad-jokes** MCP server (Python). Ask questions like "Tell me a good dad joke."
14+
4. a Lambda function-based **weather-alerts** MCP server (Typescript). Ask questions like "Are there any weather alerts right now?".
15+
5. a Lambda function-based **cat-facts** MCP server (Typescript). Ask questions like "Tell me something about cats".
16+
6. a Lambda function-based **dog-facts** MCP server (Typescript). Ask questions like "Tell me something about dogs".
17+
7. a [local **fetch** MCP server](https://github.com/modelcontextprotocol/servers/tree/main/src/fetch). Ask questions like "Who is Tom Cruise?".
1718

1819
### Setup
1920

@@ -121,6 +122,16 @@ uv pip install -r requirements.txt
121122
cdk deploy --app 'python3 cdk_stack.py'
122123
```
123124

125+
Deploy the Lambda 'dad-jokes' function - the deployed function will be named "mcp-server-dad-jokes".
126+
127+
```bash
128+
cd examples/servers/dad-jokes/
129+
130+
uv pip install -r requirements.txt
131+
132+
cdk deploy --app 'python3 cdk_stack.py'
133+
```
134+
124135
### Deploy the example Typescript servers
125136

126137
Deploy the Lambda 'weather-alerts' function - the deployed function will be named "mcp-server-weather-alerts".

e2e_tests/clean_up_integ_test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ cdk destroy --force --app 'python3 cdk_stack.py'
1818
cd ../mcpdoc
1919
cdk destroy --force --app 'python3 cdk_stack.py'
2020

21+
cd ../dad-jokes
22+
cdk destroy --force --app 'python3 cdk_stack.py'
23+
2124
cd ../weather-alerts/
2225
cdk destroy --force --app 'node lib/weather-alerts-mcp-server.js'
2326

e2e_tests/python/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ async def main() -> None:
8989
"What is the current time in Seattle?",
9090
"Are there any weather alerts right now?",
9191
"List your available documentation sources.",
92+
"Tell me a dad joke.",
9293
"Tell me a dog fact.",
9394
"Tell me a cat fact.",
9495
"Who is Tom Cruise?",

e2e_tests/run_integ_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ cd ../mcpdoc
2222
uv pip install -r requirements.txt
2323
cdk deploy --app 'python3 cdk_stack.py' --require-approval never
2424

25+
# Deploy Python-based Dad jokes MCP server
26+
cd ../dad-jokes
27+
uv pip install -r requirements.txt
28+
cdk deploy --app 'python3 cdk_stack.py' --require-approval never
29+
2530
# Deploy Typescript-based example MCP server
2631
cd ../../../src/typescript/
2732
npm ci

e2e_tests/typescript/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async function main(): Promise<void> {
4747
"What is the current time in Seattle?",
4848
"Are there any weather alerts right now?",
4949
"List your available documentation sources.",
50+
"Tell me a dad joke.",
5051
"Tell me a dog fact.",
5152
"Tell me a cat fact.",
5253
"Who is Tom Cruise?",

examples/servers/dad-jokes/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Dad Jokes MCP Server
2+
3+
This is an MCP (Model Context Protocol) server that provides access to dad jokes via the icanhazdadjoke.com API. It uses the mcp-openapi-proxy package to expose the API as MCP tools.

0 commit comments

Comments
 (0)