Skip to content

skeeto/sdmcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sdmcp

An MCP adaptor for a stable-diffusion.cpp (sd.cpp) server. It exposes a single generate_image tool over StreamableHTTP so that models in llama.cpp's webui can generate images inline in their responses.

The model controls only the prompt and negative prompt. Image size is fixed by a flag; everything else (seed, sampler, steps, cfg, model) is configured on the sd.cpp server. Requests are forwarded to sd.cpp's OpenAI-compatible /v1/images/generations endpoint; the PNG comes back as an MCP image content block that the webui renders inline.

Build & run

go build
./sdmcp -sd-url http://localhost:1234 -size 512x512 -listen :1235
Flag Default Description
-listen :1235 Address this MCP server listens on.
-sd-url http://localhost:1234 Base URL of the sd.cpp server.
-size 512x512 Fixed image size (WxH) sent to sd.cpp.
-path /mcp MCP endpoint path.

Connecting the llama.cpp webui

Add an MCP server with the full endpoint path (not just the host):

http://localhost:1235/mcp

sdmcp sends permissive CORS headers and answers preflight OPTIONS, so the browser-based webui connects directly with no proxy and no auth. Note: browsers block an https:// page from calling an http:// server — keep both on http (the usual localhost setup) or serve sdmcp over HTTPS.

Notes

  • The tool returns the image plus a short text instruction telling the model the image is already shown to the user, which stops models from echoing the attachment placeholder into their reply.
  • On any sd.cpp failure the tool returns an error result rather than a transport error.
  • Generation can be slow; sdmcp sets no request/write timeout and relies on the MCP client's per-tool timeout (the webui default is 300 s).

License

Public domain (The Unlicense). See UNLICENSE.

About

MCP server for stable-diffusion.cpp

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages