mcpField
E
Example MCP Server with image blocks

Example MCP Server with image blocks

Local
github.com/larryhudsonMedia & Design1Updated 79w ago

About Example MCP Server with image blocks

A small example MCP server that retrieves a random image from the Lorem Picsum API. It demonstrates how an MCP server can return image blocks and is intended for developers exploring MCP.

Key features

  1. 01Fetch a random Lorem Picsum image
  2. 02Return an MCP image block
  3. 03Single `get_random_image` tool
  4. 04TypeScript implementation

Use cases

  1. 01Study image-block responses in MCP
  2. 02Test an image-capable MCP client

MCP support

The server exposes `get_random_image` to MCP clients and returns the fetched image as an image block.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"example-image-block": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/inspector"
]
}
}
}
Run commandnpx -y @modelcontextprotocol/inspector

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@modelcontextprotocol/inspector

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Example MCP Server with image blocks

Overview

An example MCP server that returns a random image from the Lorem Picsum API. This is just an example to show how MCP servers can return image blocks.

See also: Image Content in the Model Context Protocol specification

Usage

Using with VS Code

Add this to your settings JSON file:

{
  "mcp": {
    "servers": {
      "random_image": {
        "command": "npx",
        "args": [
          "-y",
          "@larryhudson/mcp-server-example-image-block"
        ],
      }
    }
  }
}
Using with Claude or other MCP-compatible applications

Add this to your MCP configuration JSON file:

{
  "mcpServers": {
    "random_image": {
      "command": "npx",
      "args": ["-y", "@larryhudson/mcp-server-example-image-block"],
    }
  }
}

Available Tools

  • get_random_image - get a random image using the Lorem Picsum API.

Technical Details

Built with:

  • Model Context Protocol (MCP): Framework for allowing AI assistants to interact with external tools
  • TypeScript: For type safety and better developer experience

Development

You can use the Model Context Protocol inspector to try out the server:

npx @modelcontextprotocol/inspector npx tsx src/index.ts

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.