npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcpc-tech/plugin-code-execution-sampling

v0.0.2

Published

[![JSR](https://jsr.io/badges/@mcpc/plugin-code-execution-sampling)](https://jsr.io/@mcpc/plugin-code-execution-sampling) [![npm](https://img.shields.io/npm/v/@mcpc-tech/plugin-code-execution-sampling)](https://www.npmjs.com/package/@mcpc-tech/plugin-code

Readme

@mcpc/plugin-code-execution-sampling

JSR npm

Combine secure sandboxed code execution with MCP sampling-backed model calls. This package adds a sampling() host handler to the sandbox so code can call back into the connected MCP client's model while still using MCP tools.

Features

  • Secure sandbox execution via @mcpc/plugin-code-execution
  • Model calls from sandbox code via sampling()
  • Full tool loop support by reusing @mcpc/mcp-sampling-ai-provider and AI SDK
  • Selective tool exposure for sampling requests with toolNames

Installation

# npm
npm install @mcpc-tech/plugin-code-execution-sampling
pnpm add @mcpc-tech/plugin-code-execution-sampling

# jsr
npx jsr add @mcpc/plugin-code-execution-sampling
pnpm add jsr:@mcpc/plugin-code-execution-sampling

Usage

import { mcpc } from "@mcpc/core";
import { createCodeExecutionSamplingPlugin } from "@mcpc/plugin-code-execution-sampling";

const server = await mcpc(
  [{ name: "my-agent", version: "1.0.0" }, {
    capabilities: { tools: {} },
  }],
  [{
    name: "my-agent",
    description: `
      You can execute JavaScript code and call the connected model.
      <tool name="filesystem.read_file"/>
      <tool name="filesystem.write_file"/>
    `,
    deps: {
      mcpServers: {
        filesystem: {
          command: "npx",
          args: ["-y", "@wonderwhy-er/desktop-commander@latest"],
          transportType: "stdio",
        },
      },
    },
    plugins: [
      createCodeExecutionSamplingPlugin({
        sandbox: {
          timeout: 30_000,
          permissions: [],
        },
        sampling: {
          maxSteps: 8,
          maxTokens: 4096,
        },
      }),
    ],
    options: {
      mode: "code_execution_sampling",
    },
  }],
);

Inside sandboxed JavaScript, you can now do both:

const file = await callMCPTool("filesystem.read_file", { path: "README.md" });
const summary = await sampling({
  prompt: `Summarize this file:\n${JSON.stringify(file)}`,
  toolNames: ["filesystem.read_file"],
});
console.log(summary.text);

sampling() API

String shorthand

const result = await sampling("Summarize the latest output");
console.log(result.text);

Object form

const result = await sampling({
  prompt: "Investigate the failing test and explain the root cause",
  systemPrompt: "You are a concise coding assistant",
  toolNames: ["filesystem.read_file", "terminal.execute_command"],
  maxSteps: 6,
  maxTokens: 4096,
  context: { cwd: "/repo" },
});

Returned shape:

interface SandboxSamplingResult {
  text: string;
  finishReason: string;
  steps: unknown[];
  toolCalls: unknown[];
  toolResults: unknown[];
  usage: unknown;
}

Notes

  • sampling() requires the connected MCP client to advertise sampling support.
  • Tool execution during sampling reuses the agent's tool set and host-side MCP calls.
  • @mcpc/plugin-code-execution is still the right package when you only need sandbox execution without model calls.

Examples

See examples/basic-usage.ts for a self-contained stdio server example built around code_execution_sampling. It is designed to pair with any MCP client that already supports sampling.

deno run --allow-all packages/plugin-code-execution-sampling/examples/basic-usage.ts