Studio: add stdio MCP server support#5863
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
Code Review
This pull request adds support for local stdio Model Context Protocol (MCP) servers alongside remote HTTP servers, restricted by a security gate (UNSLOTH_STUDIO_ALLOW_STDIO_MCP) that is enabled by default on the desktop app. Key feedback includes fixing a validation bug in the frontend that rejects local commands containing '://' in their arguments, stripping preserved quotes from parsed command tokens on Windows to prevent subprocess execution failures, and defensively handling empty command lists in the client initialization to avoid an IndexError.
danielhanchen
left a comment
There was a problem hiding this comment.
Tested locally: the stdio gate holds at create, test, refresh, discovery and execute, a real stdio server (npx filesystem) works end to end, and the live Studio UI checks out. CI is green. Approving.

Remote (HTTP) MCP support was added in #5750; stdio (local) servers are the other transport. The official reference servers (filesystem, git, fetch, memory) and most community ones run locally as a subprocess via npx/uvx, not over HTTP.
This PR adds stdio MCP support by accepting a local command in place of a URL in the MCP Servers dialog.
How to use
Example:
npx -y @modelcontextprotocol/server-filesystem /tmp(the directory must exist).API_KEY, valuesk-...What files are in /tmp?(callslist_directory), orWrite a file /tmp/notes.txt containing "hello"(callswrite_file).The command's runtime must be installed and on PATH. The example above needs npx, a uvx server needs uv, a python3 -m server needs Python, etc.
Policy (gating)
stdio servers run an arbitrary local subprocess as the backend user, so they are gated by deployment, not by login:
UNSLOTH_STUDIO_ALLOW_STDIO_MCP=1to override. The flag is process-wide with no bind check, so it grants every user who can log into the backend the ability to run commands on the machine. Only enable it when you trust everyone with access.When disabled, stdio servers cannot be created, tested, refreshed, discovered, or executed (enforced at all five points). A DB carried from a desktop install won't spawn anything on a hosted instance.
Implementation
Reuses the existing HTTP MCP path to keep the change small. A non-HTTP address is treated as a stdio command. The command rides the existing
urlfield and env vars ride theheaders_jsoncolumn. No new DB column, no migration, no new model or route. 5 files changed, transport built with fastmcp'sStdioTransport. The HTTP path is untouched.