This is a Model Context Protocol (MCP) server that provides tools to convert base64-encoded images and image URLs into markdown-formatted image embeds for display in LLM chat interfaces (e.g., OpenWebUI chat).
- base64-to-url: Accepts base64-encoded image data (optionally prefixed with data URI), saves it as an image file, and returns a markdown snippet with a URL to display the image.
- display-url: Accepts an image URL and returns a markdown snippet to display the image.
-
Install dependencies:
npm install
-
Start the MCP server:
npm start
-
MCP endpoint:
- POST requests:
http://localhost:4000/mcp
- Static images served at:
http://localhost:4000/images/
- POST requests:
Clients (e.g., OpenWebUI chat) should always use the base64-to-url
tool when they have base64-encoded image data, and the display-url
tool when they have a direct image URL. The server will return a markdown snippet for the client to render as an image.
Here is an example of how an LLM client (e.g., Cursor) can invoke the base64-to-url
tool to upload base64 image data:
{
"jsonrpc": "2.0",
"id": 1,
"method": "base64-to-url",
"params": {
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA..."
}
}
To display an existing image URL using the display-url
tool:
{
"jsonrpc": "2.0",
"id": 2,
"method": "display-url",
"params": {
"url": "https://example.com/path/to/image.jpg"
}
}
Clients that support loading servers from a mcpservers.json
file (e.g., Cursor) can register this server with an entry like:
{
"mcpServers": {
"base64-to-url-mcp": {
"command": "npx",
"args": ["-y", "@cloudwerxlab/base64-to-url-mcp"],
"env": {
"BASE_URL": "http://localhost:4000"
}
}
}
}
Adjust the server name, package name, and BASE_URL
as needed based on your environment.