Add LM Studio ↔ SD WebUI MCP integration and dev server configs#1
Add LM Studio ↔ SD WebUI MCP integration and dev server configs#1Definitionist wants to merge 1 commit into
Conversation
- webui-api.bat: wrapper that starts SD WebUI with --api --listen (required for LM Studio MCP sd-webui server to connect to http://127.0.0.1:7860) - .lmstudio/mcp.json: updated SD_OUTPUT_DIR to SD's own outputs/txt2img-images folder - .claude/launch.json: dev server registry for all local projects (SD, Flask, FastAPI, Vite apps); corrected SD entry to use webui-api.bat instead of wrong python webui.py entrypoint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces configuration files for project launching and Model Context Protocol (MCP) servers, as well as a batch script to enable the Stable Diffusion WebUI API. Feedback highlights a typo in a project name and points out that hardcoded absolute user paths in the JSON configurations hinder portability, suggesting the use of environment variables instead.
| "name": "PeojectWebsite (Vite/React)", | ||
| "cwd": "C:/Users/Shadow/PeojectWebsite", |
There was a problem hiding this comment.
There appears to be a typo in PeojectWebsite. Assuming it should be ProjectWebsite.
Additionally, the cwd path is hardcoded to a specific user's directory (C:/Users/Shadow/...). This makes the configuration not portable for other developers. This issue is present for all configurations in this file. It's highly recommended to use environment variables. For example, in VS Code's launch.json, you can use ${env:USERPROFILE} which typically resolves to C:\Users\<username> on Windows.
| "name": "PeojectWebsite (Vite/React)", | |
| "cwd": "C:/Users/Shadow/PeojectWebsite", | |
| "name": "ProjectWebsite (Vite/React)", | |
| "cwd": "${env:USERPROFILE}/ProjectWebsite", |
| "mcpServers": { | ||
| "sd-webui": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\sd-webui\\server.js" | ||
| ], | ||
| "env": { | ||
| "SD_WEBUI_URL": "http://127.0.0.1:7860", | ||
| "SD_OUTPUT_DIR": "C:\\Users\\Shadow\\stable-diffusion-webui-master\\outputs\\txt2img-images" | ||
| } | ||
| }, | ||
| "filesystem": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | ||
| "C:\\Users\\Shadow", | ||
| "C:\\Users\\Shadow\\Downloads", | ||
| "C:\\Users\\Shadow\\Documents", | ||
| "C:\\Users\\Shadow\\Desktop", | ||
| "C:\\Users\\Shadow\\stable-diffusion-webui-master" | ||
| ] | ||
| }, | ||
| "memory": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\memory\\node_modules\\@modelcontextprotocol\\server-memory\\dist\\index.js" | ||
| ] | ||
| }, | ||
| "playwright": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\playwright\\node_modules\\@playwright\\mcp\\cli.js" | ||
| ] | ||
| }, | ||
| "fetch": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\fetch\\node_modules\\mcp-fetch-server\\dist\\index.js" | ||
| ] | ||
| }, | ||
| "github": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\github\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js" | ||
| ] | ||
| }, | ||
| "sequential-thinking": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\sequential-thinking\\node_modules\\@modelcontextprotocol\\server-sequential-thinking\\dist\\index.js" | ||
| ] | ||
| } | ||
| } |
There was a problem hiding this comment.
This configuration file contains multiple hardcoded absolute paths that include a specific username (C:\\Users\\Shadow\\...). This makes the configuration not portable for other developers. It's highly recommended to avoid user-specific absolute paths in version-controlled files. Consider using paths relative to a known location, or a mechanism that allows user-specific overrides (e.g., via environment variables). For example, the application consuming this file could be made to expand an environment variable like %USERPROFILE% on Windows.
There was a problem hiding this comment.
Pull request overview
Adds local integration scaffolding to run Stable Diffusion WebUI with its API enabled and wire it up to LM Studio’s sd-webui MCP server, plus a .claude dev-server launcher registry for common local projects.
Changes:
- Added a
webui-api.batwrapper to launch SD WebUI with--api(and--listen) for MCP connectivity. - Added LM Studio MCP server configuration (
.lmstudio/mcp.json), includingSD_WEBUI_URLandSD_OUTPUT_DIR. - Added a Claude dev server registry (
.claude/launch.json) with a corrected SD WebUI launch command.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| Users/Shadow/stable-diffusion-webui-master/webui-api.bat | Wrapper script to start SD WebUI with API flags for LM Studio MCP usage. |
| Users/Shadow/.lmstudio/mcp.json | LM Studio MCP server definitions, including SD WebUI env wiring and filesystem roots. |
| Users/Shadow/.claude/launch.json | Local dev server launch entries, including SD WebUI via the new wrapper script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| call webui.bat --api --listen |
There was a problem hiding this comment.
--listen typically binds the WebUI to all interfaces (0.0.0.0), which can unintentionally expose the SD WebUI + API to your LAN. If LM Studio connects via 127.0.0.1, consider removing --listen by default, or add a clearly documented opt-in / host-binding option to keep the API local-only.
| call webui.bat --api --listen | |
| rem Note: `--listen` is omitted to keep the WebUI/API bound to localhost only. | |
| rem If you intentionally want LAN access, add `--listen` to the command below. | |
| call webui.bat --api |
| rem Access WebUI at http://127.0.0.1:7860 | ||
| rem API docs at http://127.0.0.1:7860/docs | ||
|
|
||
| call webui.bat --api --listen |
There was a problem hiding this comment.
call webui.bat ... depends on the current working directory. To make this wrapper resilient when launched from elsewhere (double-clicked, scheduled task, etc.), call webui.bat via %~dp0 (the script directory) and quote the path.
| call webui.bat --api --listen | |
| call "%~dp0webui.bat" --api --listen |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\sd-webui\\server.js" | ||
| ], | ||
| "env": { | ||
| "SD_WEBUI_URL": "http://127.0.0.1:7860", | ||
| "SD_OUTPUT_DIR": "C:\\Users\\Shadow\\stable-diffusion-webui-master\\outputs\\txt2img-images" | ||
| } | ||
| }, | ||
| "filesystem": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | ||
| "C:\\Users\\Shadow", | ||
| "C:\\Users\\Shadow\\Downloads", | ||
| "C:\\Users\\Shadow\\Documents", | ||
| "C:\\Users\\Shadow\\Desktop", | ||
| "C:\\Users\\Shadow\\stable-diffusion-webui-master" | ||
| ] | ||
| }, | ||
| "memory": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\memory\\node_modules\\@modelcontextprotocol\\server-memory\\dist\\index.js" | ||
| ] | ||
| }, | ||
| "playwright": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\playwright\\node_modules\\@playwright\\mcp\\cli.js" | ||
| ] | ||
| }, | ||
| "fetch": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\fetch\\node_modules\\mcp-fetch-server\\dist\\index.js" | ||
| ] | ||
| }, | ||
| "github": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\github\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js" | ||
| ] | ||
| }, | ||
| "sequential-thinking": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\sequential-thinking\\node_modules\\@modelcontextprotocol\\server-sequential-thinking\\dist\\index.js" |
There was a problem hiding this comment.
This config hard-codes machine-specific absolute paths (including a specific Windows username) for both the MCP server entrypoint and SD_OUTPUT_DIR. If this repo is intended to be used on other machines, consider parameterizing these via environment variables (e.g., %USERPROFILE%) or checking in a template file and keeping the real mcp.json untracked.
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\sd-webui\\server.js" | |
| ], | |
| "env": { | |
| "SD_WEBUI_URL": "http://127.0.0.1:7860", | |
| "SD_OUTPUT_DIR": "C:\\Users\\Shadow\\stable-diffusion-webui-master\\outputs\\txt2img-images" | |
| } | |
| }, | |
| "filesystem": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | |
| "C:\\Users\\Shadow", | |
| "C:\\Users\\Shadow\\Downloads", | |
| "C:\\Users\\Shadow\\Documents", | |
| "C:\\Users\\Shadow\\Desktop", | |
| "C:\\Users\\Shadow\\stable-diffusion-webui-master" | |
| ] | |
| }, | |
| "memory": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\memory\\node_modules\\@modelcontextprotocol\\server-memory\\dist\\index.js" | |
| ] | |
| }, | |
| "playwright": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\playwright\\node_modules\\@playwright\\mcp\\cli.js" | |
| ] | |
| }, | |
| "fetch": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\fetch\\node_modules\\mcp-fetch-server\\dist\\index.js" | |
| ] | |
| }, | |
| "github": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\github\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js" | |
| ] | |
| }, | |
| "sequential-thinking": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\sequential-thinking\\node_modules\\@modelcontextprotocol\\server-sequential-thinking\\dist\\index.js" | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\sd-webui\\server.js" | |
| ], | |
| "env": { | |
| "SD_WEBUI_URL": "http://127.0.0.1:7860", | |
| "SD_OUTPUT_DIR": "%USERPROFILE%\\stable-diffusion-webui-master\\outputs\\txt2img-images" | |
| } | |
| }, | |
| "filesystem": { | |
| "command": "node", | |
| "args": [ | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | |
| "%USERPROFILE%", | |
| "%USERPROFILE%\\Downloads", | |
| "%USERPROFILE%\\Documents", | |
| "%USERPROFILE%\\Desktop", | |
| "%USERPROFILE%\\stable-diffusion-webui-master" | |
| ] | |
| }, | |
| "memory": { | |
| "command": "node", | |
| "args": [ | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\memory\\node_modules\\@modelcontextprotocol\\server-memory\\dist\\index.js" | |
| ] | |
| }, | |
| "playwright": { | |
| "command": "node", | |
| "args": [ | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\playwright\\node_modules\\@playwright\\mcp\\cli.js" | |
| ] | |
| }, | |
| "fetch": { | |
| "command": "node", | |
| "args": [ | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\fetch\\node_modules\\mcp-fetch-server\\dist\\index.js" | |
| ] | |
| }, | |
| "github": { | |
| "command": "node", | |
| "args": [ | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\github\\node_modules\\@modelcontextprotocol\\server-github\\dist\\index.js" | |
| ] | |
| }, | |
| "sequential-thinking": { | |
| "command": "node", | |
| "args": [ | |
| "%USERPROFILE%\\.lmstudio\\mcp-servers\\sequential-thinking\\node_modules\\@modelcontextprotocol\\server-sequential-thinking\\dist\\index.js" |
| "filesystem": { | ||
| "command": "node", | ||
| "args": [ | ||
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | ||
| "C:\\Users\\Shadow", | ||
| "C:\\Users\\Shadow\\Downloads", | ||
| "C:\\Users\\Shadow\\Documents", | ||
| "C:\\Users\\Shadow\\Desktop", | ||
| "C:\\Users\\Shadow\\stable-diffusion-webui-master" | ||
| ] | ||
| }, |
There was a problem hiding this comment.
The filesystem MCP server is granted access to the entire user home directory (C:\\Users\\Shadow) plus other subfolders. This is a very broad permission set for an LLM tool; consider restricting the allowed roots to only what’s required for this workflow (e.g., the SD WebUI folder and a dedicated workspace/output directory).
| "filesystem": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | |
| "C:\\Users\\Shadow", | |
| "C:\\Users\\Shadow\\Downloads", | |
| "C:\\Users\\Shadow\\Documents", | |
| "C:\\Users\\Shadow\\Desktop", | |
| "C:\\Users\\Shadow\\stable-diffusion-webui-master" | |
| ] | |
| }, | |
| "filesystem": { | |
| "command": "node", | |
| "args": [ | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-servers\\filesystem\\node_modules\\@modelcontextprotocol\\server-filesystem\\dist\\index.js", | |
| "C:\\Users\\Shadow\\stable-diffusion-webui-master", | |
| "C:\\Users\\Shadow\\stable-diffusion-webui-master\\outputs\\txt2img-images", | |
| "C:\\Users\\Shadow\\.lmstudio\\mcp-workspace" | |
| ] | |
| }, |
| "name": "PeojectWebsite (Vite/React)", | ||
| "cwd": "C:/Users/Shadow/PeojectWebsite", |
There was a problem hiding this comment.
Possible typo in the project name/path: "PeojectWebsite" looks like it should be "ProjectWebsite". If this is unintended, correct it so the entry is easier to find and doesn’t point at a non-existent directory.
| "name": "PeojectWebsite (Vite/React)", | |
| "cwd": "C:/Users/Shadow/PeojectWebsite", | |
| "name": "ProjectWebsite (Vite/React)", | |
| "cwd": "C:/Users/Shadow/ProjectWebsite", |
Summary
webui-api.bat— new launcher wrapper for SD WebUI that passes--api --listenflags, enabling LM Studio'ssd-webuiMCP server to connect athttp://127.0.0.1:7860.lmstudio/mcp.json— updatedSD_OUTPUT_DIRfrom Downloads to SD's ownoutputs/txt2img-images/folder so generated images land in the right place.claude/launch.json— dev server registry for all local projects; corrected SD entry from wrongpython webui.pyentrypoint tocmd /c webui-api.batTest plan
webui-api.bat— confirm SD WebUI starts and API is accessible athttp://127.0.0.1:7860/docssd-webuiMCP tool (e.g.txt2img) — confirm image generates and saves tooutputs/txt2img-images/launch.jsonentries match actual project start commands🤖 Generated with Claude Code