PRIMS is a lightweight, open-source Model Context Protocol (MCP) server that lets LLM agents execute arbitrary Python code in a secure, throw-away sandbox.
Purpose PRIMS is aimed at scenarios that require letting LLM agents run Python code, providing an isolated and reproducible execution environment. It exposes code execution capabilities to agents through the MCP protocol, enabling agents to submit and run user-provided Python code and obtain execution output.
Key capabilities
- Single tool: exposes only one MCP tool, run_code, used to execute user-provided Python code and stream stdout / stderr.
- Isolated and reproducible: each call starts a brand-new virtual environment, installs the requested pip packages, mounts optional read-only files as needed, and then destroys the workspace.
- Zero configuration: can be used directly via MCP/stdio, or run inside Docker.
- File and artifact operations: provides the list_dir and preview_file tools for browsing files in the session workspace generated by code; provides the persist_artifact tool to upload files from the output/ directory to a presigned URL; small artifacts can be downloaded directly.
- Data mount reuse: data files (such as CSV) can be mounted via mount_file and then read in run_code, without needing to provide the source again.
Usage
- Prepare the local development environment.
- Start the server.
- List available tools: you can use the provided script to list all tools exposed by the server; expected output (tool names and descriptions may differ).
- Run code through the MCP server, i.e. call run_code.
- Mount a dataset once and reuse it: use mount_file to mount a CSV, then read it inside run_code without providing the URL again.
- Inspect the session workspace: use the list_dir and preview_file tools to browse files created by the code.
- Persist artifacts to permanent storage: use the persist_artifact tool to upload files from the output/ directory to a presigned URL (example is Python).
- Download artifacts: small artifactscan be obtained directly. More end-to-end demos can be found in the repository's examples/ directory. The project welcomes contributions; you can submit issues, suggest features, or open pull requests.
Applicable scenarios Suitable for applications and development scenarios that want LLM agents to execute Python code, process data files, and generate persistable artifacts in a controlled environment.
Limitations The materials do not provide more details about specific runtime environment requirements, dependency versions, performance, quotas, fees, pricing, or supported platforms; this content is not yet available.