|
1 | | -# MCP Run Python |
| 1 | +<div align="center"> |
| 2 | + <h1>MCP Run Python</h1> |
| 3 | +</div> |
| 4 | +<div align="center"> |
| 5 | + <a href="https://github.com/pydantic/mcp-run-python/actions/workflows/ci.yml?query=branch%3Amain"><img src="https://github.com/pydantic/mcp-run-python/actions/workflows/ci.yml/badge.svg?event=push" alt="CI"></a> |
| 6 | + <a href="https://pypi.python.org/pypi/mcp-run-python"><img src="https://img.shields.io/pypi/v/mcp-run-python.svg" alt="PyPI"></a> |
| 7 | + <a href="https://github.com/pydantic/mcp-run-python"><img src="https://img.shields.io/pypi/pyversions/mcp-run-python.svg" alt="versions"></a> |
| 8 | + <a href="https://github.com/pydantic/mcp-run-python/blob/main/LICENSE"><img src="https://img.shields.io/github/license/pydantic/mcp-run-python.svg" alt="license"></a> |
| 9 | + <a href="https://logfire.pydantic.dev/docs/join-slack/"><img src="https://img.shields.io/badge/Slack-Join%20Slack-4A154B?logo=slack" alt="Join Slack" /></a> |
| 10 | +</div> |
| 11 | +<br/> |
| 12 | +<div align="center"> |
| 13 | + MCP server to run Python code in a sandbox. |
| 14 | +</div> |
| 15 | +<br/> |
| 16 | + |
| 17 | +Code is executed using [Pyodide](https://pyodide.org) in [Deno](https://deno.com/) and is therefore isolated from |
| 18 | +the rest of the operating system. |
2 | 19 |
|
3 | | -[Model Context Protocol](https://modelcontextprotocol.io/) server to run Python code in a sandbox. |
| 20 | +## Features |
4 | 21 |
|
5 | | -The code is executed using [Pyodide](https://pyodide.org) in [Deno](https://deno.com/) and is therefore isolated from |
6 | | -the rest of the operating system. |
| 22 | +- **Secure Execution**: Run Python code in a sandboxed WebAssembly environment |
| 23 | +- **Package Management**: Automatically detects and installs required dependencies |
| 24 | +- **Complete Results**: Captures standard output, standard error, and return values |
| 25 | +- **Asynchronous Support**: Runs async code properly |
| 26 | +- **Error Handling**: Provides detailed error reports for debugging |
7 | 27 |
|
8 | | -**See <https://ai.pydantic.dev/mcp/run-python/> for complete documentation.** |
| 28 | +## Usage |
9 | 29 |
|
10 | | -To use this server, you must have both Python and [Deno](https://deno.com/) installed |
| 30 | +To use this server, you must have both Python and [Deno](https://deno.com/) installed. |
11 | 31 |
|
12 | 32 | The server can be run with `deno` installed using `uvx`: |
13 | 33 |
|
@@ -54,3 +74,11 @@ if __name__ == '__main__': |
54 | 74 | import asyncio |
55 | 75 | asyncio.run(main()) |
56 | 76 | ``` |
| 77 | + |
| 78 | +## Logging |
| 79 | + |
| 80 | +MCP Run Python supports emitting stdout and stderr from the python execution as [MCP logging messages](https://github.com/modelcontextprotocol/specification/blob/eb4abdf2bb91e0d5afd94510741eadd416982350/docs/specification/draft/server/utilities/logging.md?plain=1). |
| 81 | + |
| 82 | +For logs to be emitted you must set the logging level when connecting to the server. By default, the log level is set to the highest level, `emergency`. |
| 83 | + |
| 84 | +Currently, it's not possible to demonstrate this due to a bug in the Python MCP Client, see [modelcontextprotocol/python-sdk#201](https://github.com/modelcontextprotocol/python-sdk/issues/201#issuecomment-2727663121). |
0 commit comments