Skip to content

feat(mcp): add way to deny certain commands for MCP mode #19334

Open

Description

@mkatychev

Basics

  • I have done a basic search through the issue tracker to find similar or related issues.
  • I have made myself familiar with the available features of Nushell for the particular area this enhancement request touches.

Related problem

There isn't much in the MCP spec relating to permissions so models can sometimes inadvertenly use destructive or undesired commands that bypass agent restrictions.

Describe the solution you'd like

One approach is to mimic opencode's permission scheme and pass it in as a configuration:

--mcp-config oneof<path, record>, however

Describe alternatives you've considered

Short term, it would be nice if something akin to nu --mcp --env-config mcp-permissions.nu could work though I have not thought through how a nushell script could do this in a legible way.

Additional context and details

I don't want to have an agent use nushell MCP and rm -rf :D

Activity

  1. added
    category:enhancement
    status:needs-triage
    on Oct 23, 2026
  2. changed the title [-]feat(mcp): add way to scope permissions for MCP mode[/-] [+]feat(mcp): add way to deny certain commands for MCP mode[/+] on Oct 23, 2026
  3. fdncred commented on Oct 27, 2026

    @fdncred
    Contributor

    I generally think this is a good idea but has potential to be expanded a bit along these lines. These are just ideas to be discussed at this point.

    Nushell runs every built-in in-process, so it can know what a script is about to do before the OS does.

    Today. Category in crates/nu-protocol/src/signature.rs groups commands for help pages, not by effect. ls and rm are both FileSystem. Safety features live in single commands: rm --trash with rm.always_trash, mktemp --dry, save --force. nu --mcp gives an agent three tools (list_commands, command_help, evaluate), and evaluate runs anything with the user's full rights.

    The leap. Add an effects list to each built-in's Signature: fs-read, fs-write, net, spawn, env, plugin. External calls count as spawn. That one annotation pays for five features.

    • Permissions in the Deno style: nu --allow fs-read=. --allow net=api.github.com script.nu, or with-permissions {fs-write: [./out]} { ... }. The REPL asks once on first use. Externals are allowed by name, and on Linux and macOS the spawn can run inside Landlock or Seatbelt so the OS enforces the same rules.
    • dry-run { ... } makes every fs-write command return a plan table (op, path, size) instead of acting.
    • A journal of the last command's file operations, so undo can reverse mv, cp, mkdir, save and a trashed rm.
    • nu --mcp --tools deploy.nu --allow ... exposes a module's exported commands as typed MCP tools, with JSON Schema built from their signatures. The agent calls deploy --env staging inside the permission set rather than sending free-form code to evaluate.
    • A secret value type that prints as <secret> in tables, errors, $ans, history and MCP output, and becomes a plain string only when passed to an external, $env or an http header.
  4. mkatychev commented on Oct 27, 2026

    @mkatychev
    ContributorAuthor
    • Permissions in the Deno style: nu --allow fs-read=. --allow net=api.github.com script.nu, or with-permissions {fs-write: [./out]} { ... }.

    It looks like the MCP spec does support a similar scoping..

    Tools - Model Context Protocol

    • Servers MUST:
      • Validate all tool inputs
      • Implement proper access controls
      • Rate limit tool invocations
      • Sanitize tool outputs
    • Clients SHOULD:
      • Prompt for user confirmation on sensitive operations

    In a case like "allow git fetch and git show but deny git commit and git push I'm not sure keys like network.allowedDomains touch on this.

    The approach/proposal does not guarantee any safeguards especially when an LLM is particularly deluded/malicious but merely means to discourage some common behaviour.

    this is really meant to cover the spawn example, to my understanding this correlates best with NushellMcpServer::evaluate:

    async fn evaluate(
    &self,
    ctx: RequestContext<RoleServer>,
    Parameters(NuSourceRequest { input }): Parameters<NuSourceRequest>,
    ) -> CallToolResult {
    self.evaluator.eval_async(&input, ctx.ct).await
    }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:enhancementstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions