-
Notifications
You must be signed in to change notification settings - Fork 211
Container server fixes #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
332aa4a
add deploy and improved size dockerfile
cmsparks 99fc385
Add newly build docker image
cmsparks a535e88
modify configs
cmsparks 6f9fd32
Add user based container
cmsparks 1271f04
fixup container server and improve descriptions
cmsparks 6d29355
linting
cmsparks bc3347f
Merge branch 'main' into csparks/docker-image-fixes
cmsparks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Container MCP Server | ||
|
||
This is a simple MCP-based interface for a sandboxed development environment. | ||
|
||
## Local dev | ||
|
||
Cloudchamber local dev isn't implemented yet, so we are doing a bit of a hack to just run the server in your local environment. Because of this, testing the container(s) and container manager locally is not possible at this time. | ||
|
||
Do the following from within the sandbox-container app: | ||
|
||
1. Copy the `.dev.vars.example` file to a new `.dev.vars` file. | ||
2. Get the Cloudflare client id and secret from a team member and add them to the `.dev.vars` file. | ||
3. Run `pnpm i` then `pnpm dev` to start the MCP server. | ||
4. Run `pnpx @modelcontextprotocol/inspector` to start the MCP inspector client. | ||
5. Open the inspector client in your browser and connect to the server via `http://localhost:8976/sse`. | ||
|
||
Note: Temporary files created through files tool calls are stored in the workdir folder of this app. | ||
|
||
## Deploying | ||
|
||
1. Make sure the docker daemon is running | ||
|
||
2. Disable WARP and run | ||
|
||
``` | ||
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14387504770/npm-package-wrangler-8740 deploy | ||
``` | ||
|
||
3. Add to your Claude config. If using with Claude, you'll need to disable WARP: | ||
|
||
``` | ||
{ | ||
"mcpServers": { | ||
"container": { | ||
"command": "npx", | ||
"args": [ | ||
"mcp-remote", | ||
// this is my deployed instance | ||
"https://container-starter-2.cmsparks.workers.dev/sse" | ||
] | ||
} | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,49 @@ | ||
# Container MCP Server | ||
# Cloudflare Container Sandbox MCP Server | ||
|
||
This is a simple MCP-based interface for a sandboxed development environment. | ||
This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that supports remote MCP connections, with Cloudflare OAuth built-in. | ||
|
||
## Local dev | ||
It integrates tools for running a sandbox container with your MCP client. With this server you can allow your LLM to run arbitrary code, such as Node or Python, in a secure, sandboxed environment. | ||
|
||
Cloudchamber local dev isn't implemented yet, so we are doing a bit of a hack to just run the server in your local environment. Because of this, testing the container(s) and container manager locally is not possible at this time. | ||
## Tools | ||
|
||
Do the following from within the sandbox-container app: | ||
| **Category** | **Tool** | **Description** | | ||
| ----------------- | -------------------------- | ----------------------------------------------------------------------------- | | ||
| **Container Lifecycle** | `container_initialize` | (Re)start a container. Containers are intended to be ephemeral and don't save any state. Containers are only guaranteed to last ~10m.| | ||
| | `container_ping` | Ping a container for connectivity | | ||
| **Filesystem** | `container_file_write` | Write to a file | | ||
| | `container_files_list` | List all files in the work directory | | ||
| | `container_file_read` | Read the contents of a single file or directory | | ||
| | `container_file_delete` | Delete a single file or directory | | ||
| **Execution** | `container_exec` | Run a command in the shell | | ||
|
||
1. Copy the `.dev.vars.example` file to a new `.dev.vars` file. | ||
2. Get the Cloudflare client id and secret from a team member and add them to the `.dev.vars` file. | ||
3. Run `pnpm i` then `pnpm dev` to start the MCP server. | ||
4. Run `pnpx @modelcontextprotocol/inspector` to start the MCP inspector client. | ||
5. Open the inspector client in your browser and connect to the server via `http://localhost:8976/sse`. | ||
This MCP server is still a work in progress, and we plan to add more tools in the future. | ||
|
||
Note: Temporary files created through files tool calls are stored in the workdir folder of this app. | ||
|
||
## Deploying | ||
### Prompt Examples | ||
|
||
1. Make sure the docker daemon is running | ||
- `Create a visualization using matplotlib. Run it in the container that you can start` | ||
- `Clone and explore this github repo: [repo link]. Setup and run the tests in your development environment` | ||
- `Analyze this data using Python` | ||
|
||
2. Disable WARP and run | ||
## Access the remote MCP server from from any MCP Client | ||
|
||
``` | ||
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14387504770/npm-package-wrangler-8740 deploy | ||
``` | ||
If your MCP client has first class support for remote MCP servers, the client will provide a way to accept the server URL (`https://bindings.mcp.cloudflare.com`) directly within its interface (for example in [Cloudflare AI Playground](https://playground.ai.cloudflare.com/)). | ||
|
||
3. Add to your Claude config. If using with Claude, you'll need to disable WARP: | ||
If your client does not yet support remote MCP servers, you will need to set up its respective configuration file using [mcp-remote](https://www.npmjs.com/package/mcp-remote) to specify which servers your client can access. | ||
|
||
``` | ||
Replace the content with the following configuration: | ||
|
||
```json | ||
{ | ||
"mcpServers": { | ||
"container": { | ||
"command": "npx", | ||
"args": [ | ||
"mcp-remote", | ||
// this is my deployed instance | ||
"https://container-starter-2.cmsparks.workers.dev/sse" | ||
] | ||
} | ||
} | ||
"mcpServers": { | ||
"cloudflare": { | ||
"command": "npx", | ||
"args": ["mcp-remote", "https://containers.mcp.cloudflare.com/sse"] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Tools | ||
|
||
- `container_initialize`: (Re)start a container. Containers are intended to be ephemeral and don't save any state. Containers are only guaranteed to last 10m (this is just because I have a max of like ~5 containers per account). | ||
- `container_ping`: Ping a container for connectivity | ||
- `container_exec`: Run a command in the shell | ||
- `container_file_write`: Write to a file | ||
- `container_files_list`: List all files in the work directory | ||
- `container_file_read`: Read the contents of a single file or directory | ||
- `container_file_delete`: Delete a single file or directory | ||
|
||
## Resources | ||
|
||
TODO | ||
|
||
Tried implementing these, but MCP clients don't support resources well at all. | ||
|
||
## Prompts | ||
|
||
TODO | ||
|
||
## Container support | ||
Once you've set up your configuration file, restart MCP client and a browser window will open showing your OAuth login page. Proceed through the authentication flow to grant the client access to your MCP server. After you grant access, the tools will become available for you to use. | ||
|
||
The container currently runs python and node. It's connected to the internet and LLMs can install whatever packages. | ||
Interested in contributing, and running this server locally? See [CONTRIBUTING.md](CONTRIBUTING.md) to get started. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.