Skip to content

feat(examples): add Daytona code execution MCP server - #2512

Draft
khandrew1 wants to merge 2 commits into
mainfrom
codex/daytona-example
Draft

khandrew1 wants to merge 2 commits into
mainfrom
codex/daytona-example

Conversation

@khandrew1

@khandrew1 khandrew1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Changes

Add a runnable Daytona example that exposes a single run_code MCP tool. Developers can execute Python, TypeScript, or JavaScript in a fresh sandbox and inspect the output through the built-in Inspector.

Each call returns execution output and exit code, bounds execution time, and deletes the sandbox in finally, waiting for deletion to complete. Missing credentials, nonzero exits, provider failures, and cleanup failures are reported as tool errors.

Language / Project Scope

  • TypeScript
  • mcp-use server examples

Implementation Details

  • Add the example, .env.example, and concise local run instructions under packages/server/examples/daytona.
  • Use @daytona/[email protected], the current package name at a version allowed by the workspace release-age policy.
  • Register it for configuration verification; CI does not call the credential-dependent provider.
  • Preserve existing dependency resolutions; the lockfile additions are the Daytona SDK's dependency closure.
  • Include an empty changeset because this private example does not change a published package.

Review Readiness

  • Scoped to the Daytona example
  • Checked for an existing open Daytona PR
  • Formatting and lint checks passed
  • Local credentials remain ignored and are not included

Testing

  • pnpm typecheck, pnpm build, and pnpm verify in the example directory passed. verify checks configuration and intentionally skips live provider calls.
  • Frozen-lockfile validation and repository supply-chain validation passed.
  • Pre-commit formatting and ESLint checks passed.
  • Live MCP checks with a Daytona key: Python and TypeScript produced the expected output; JavaScript exit code 7 produced an MCP tool error.
  • Browser check: Inspector connected, listed run_code, and returned Hello from Daytona! with exit code 0. Sandbox cleanup completed successfully.

Related Issues

Supports MCP-2989. Cookbook pages and the public embedded demo are separate follow-ups.


Summary by cubic

Adds a runnable Daytona code execution example exposing a single run_code MCP tool. Developers can run Python, TypeScript, or JavaScript in a fresh sandbox and get output and exit code back.

  • Sandboxes are created per call and deleted in finally; cleanup failures return a tool error with the sandbox ID.
  • Uses @daytona/sdk 0.210.0 and is registered for configuration verification; CI does not call the credential-dependent provider.
  • Skips the protobufjs postinstall script in pnpm-workspace.yaml; the script only checks dependency version conventions and would otherwise run in CI.
  • Supports the Daytona cookbook (MCP-2989); includes local run instructions and a changeset, no published package changes.

Written for commit 841734f. Summary will update on new commits.

Review in cubic

@socket-security

socket-security Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​daytona/​sdk@​0.210.09710010098100

View full report

@socket-security

socket-security Bot commented Sep 10, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm @protobufjs/float is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: libraries/typescript/pnpm-lock.yamlnpm/@daytona/[email protected]npm/@protobufjs/[email protected]

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@protobufjs/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="libraries/typescript/packages/server/examples/daytona/src/index.ts">

<violation number="1" location="libraries/typescript/packages/server/examples/daytona/src/index.ts:46">
P2: Every `run_code` call creates a new Daytona client but only deletes its sandbox, so repeated calls in the long-lived server accumulate client connections and resources. Reuse one module-scoped `Daytona` client or explicitly dispose each client after sandbox deletion.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

let error: string | undefined;
let cleanupError: string | undefined;
try {
daytona = new Daytona();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Every run_code call creates a new Daytona client but only deletes its sandbox, so repeated calls in the long-lived server accumulate client connections and resources. Reuse one module-scoped Daytona client or explicitly dispose each client after sandbox deletion.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At libraries/typescript/packages/server/examples/daytona/src/index.ts, line 46:

<comment>Every `run_code` call creates a new Daytona client but only deletes its sandbox, so repeated calls in the long-lived server accumulate client connections and resources. Reuse one module-scoped `Daytona` client or explicitly dispose each client after sandbox deletion.</comment>

<file context>
@@ -0,0 +1,88 @@
+    let error: string | undefined;
+    let cleanupError: string | undefined;
+    try {
+      daytona = new Daytona();
+      // Auto-stop/delete also limits leftovers if the server exits unexpectedly.
+      sandbox = await daytona.create(
</file context>

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@mcp-use/agent

npm i https://pkg.pr.new/@mcp-use/agent@2512

@mcp-use/cli

npm i https://pkg.pr.new/@mcp-use/cli@2512

@mcp-use/client

npm i https://pkg.pr.new/@mcp-use/client@2512

create-mcp-use-app

npm i https://pkg.pr.new/create-mcp-use-app@2512

@mcp-use/inspector

npm i https://pkg.pr.new/@mcp-use/inspector@2512

mcp-use

npm i https://pkg.pr.new/mcp-use@2512

@mcp-use/tunnel

npm i https://pkg.pr.new/@mcp-use/tunnel@2512

commit: 841734f

@khandrew1
khandrew1 marked this pull request as draft September 10, 2026 21:09
@khandrew1
khandrew1 added this pull request to stack #2514 September 10, 2026 21:09
@khandrew1
khandrew1 marked this pull request as ready for review September 11, 2026 05:15
@khandrew1
khandrew1 marked this pull request as draft September 11, 2026 05:15

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant