|
1 | 1 | # Python Workers: FastAPI-MCP Example |
2 | 2 |
|
3 | | -This is an example of a Python Worker that uses the FastAPI-MCP package. |
| 3 | +This is an example of a Model Context Protocol (MCP) Server that uses the [FastAPI-MCP package](https://github.com/tadata-org/fastapi_mcp), that you can deploy to Cloudflare. This example MCP server supports the [SSE remote transport](https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse). It does not handle authentication or authorization. |
4 | 4 |
|
5 | | -## Adding Packages |
| 5 | +## Get Started |
6 | 6 |
|
7 | | -Vendored packages are added to your source files and need to be installed in a special manner. The Python Workers team plans to make this process automatic in the future, but for now, manual steps need to be taken. |
| 7 | +> [!NOTE] |
| 8 | +> [Python Workers](https://developers.cloudflare.com/workers/languages/python/) on Cloudflare are currently in beta. There are a few extra steps required to add external packages to your Worker, which will be simpler in the future. |
8 | 9 |
|
9 | | -### Vendoring Packages |
| 10 | +1. `git clone https://github.com/danlapid/python-workers-mcp/` |
| 11 | +2. Install Python3.12 and pip for Python 3.12. (*Currently, other versions of Python will not work - you must use 3.12*) |
| 12 | +3. Then create a virtual environment and activate it from your shell: |
10 | 13 |
|
11 | | -First, install Python3.12 and pip for Python 3.12. |
12 | | - |
13 | | -*Currently, other versions of Python will not work - use 3.12!* |
14 | | - |
15 | | -Then create a virtual environment and activate it from your shell: |
16 | 14 | ```console |
17 | 15 | python3.12 -m venv .venv |
18 | 16 | source .venv/bin/activate |
19 | 17 | ``` |
20 | 18 |
|
21 | | -Within our virtual environment, install the pyodide CLI: |
| 19 | +4. Within your virtual environment, install the pyodide CLI: |
| 20 | + |
22 | 21 | ```console |
23 | 22 | .venv/bin/pip install pyodide-build |
24 | 23 | .venv/bin/pyodide venv .venv-pyodide |
25 | 24 | ``` |
26 | 25 |
|
27 | | -Lastly, download the vendored packages. For any additional packages, re-run this command. |
| 26 | +5. Download the vendored packages. For any additional packages, re-run this command. |
| 27 | + |
28 | 28 | ```console |
29 | 29 | .venv-pyodide/bin/pip install -t src/vendor -r vendor.txt |
30 | 30 | ``` |
|
0 commit comments