MCP server that converts base64 images and image URLs into markdown for display in chat
npm install @cloudwerxlab/base64-mcpbash
npm install
`
2. Start the MCP server:
`bash
npm start
`
3. MCP endpoint:
- POST requests: http://localhost:4000/mcp
- Static images served at: http://localhost:4000/images/
Tool Integration
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.
Example Cursor JSON
Here is an example of how an LLM client (e.g., Cursor) can invoke the base64-to-url tool to upload base64 image data:
`json
{
"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:
`json
{
"jsonrpc": "2.0",
"id": 2,
"method": "display-url",
"params": {
"url": "https://example.com/path/to/image.jpg"
}
}
`
Example mcpservers.json
Clients that support loading servers from a mcpservers.json file (e.g., Cursor) can register this server with an entry like:
`json
{
"mcpServers": {
"base64-mcp": {
"command": "npx",
"args": ["-y", "@cloudwerxlab/base64-mcp"],
"env": {
"BASE_URL": "http://localhost:4000"
}
}
}
}
`
Adjust the server name, package name, and BASE_URL` as needed based on your environment.