Skip to main content
Glama
NazarLysyi

Brickognize MCP Server

by NazarLysyi

brickognize_identify

Identify LEGO items from photos to get part, set, or minifigure details with confidence scores and marketplace links.

Instructions

Identify any LEGO item (part, set, minifigure, or sticker) from a photograph. Use this when the item type is unknown or the image may contain multiple types.

Provide imagePath — absolute path to a local image file (JPEG, PNG, or WebP). Returns top matches with confidence scores, IDs, names, categories, and links to BrickLink/BrickOwl.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imagePathNoAbsolute path to a local image file (JPEG, PNG, or WebP).
includeRawNoWhen true, includes the raw Brickognize API response alongside formatted results. Useful for debugging.

Implementation Reference

  • The `brickognize_identify` tool is registered using `registerIdentifyTool`, which wraps the `createPredictTool` utility with the `/predict/` endpoint.
    export function registerIdentifyTool(server: McpServer): void {
      createPredictTool(
        server,
        "brickognize_identify",
        "Identify LEGO Item",
        "Identify any LEGO item (part, set, minifigure, or sticker) from a photograph. " +
          "Use this when the item type is unknown or the image may contain multiple types.\n\n" +
          "Provide imagePath — absolute path to a local image file (JPEG, PNG, or WebP).\n" +
          "Returns top matches with confidence scores, IDs, names, categories, and links to BrickLink/BrickOwl.",
        "/predict/",
      );
    }
  • The handler for the tool (within `createPredictTool`) processes the input image, calls the Brickognize API using the `predict` function, and maps the result.
    async (input) => {
      try {
        const { blob, filename } = await resolveImage(input);
        const raw = await predict(endpoint, blob, filename);
        const result = mapPredictionResult(raw, input.includeRaw ?? false);
    
        return {
          content: [
            {
              type: "text" as const,
              text: result.summary,
            },
            {
              type: "text" as const,
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text" as const,
              text: formatToolError(error),
            },
          ],
        };
      }
    },
  • The actual network request to the Brickognize API is performed by this function.
    export async function predict(
      endpoint: string,
      imageBlob: Blob,
      filename: string,
    ): Promise<RawSearchResults> {
      const form = new FormData();
      form.append("query_image", imageBlob, filename);
    
      const res = await fetch(`${BASE_URL}${endpoint}`, {
        method: "POST",
        body: form,
        signal: AbortSignal.timeout(60_000),
      });
    
      if (!res.ok) {
        const body = await res.text();
        throw apiError(res.status, body);
      }
    
      const data = await res.json();
    
      if (!data || typeof data.listing_id !== "string" || !Array.isArray(data.items)) {
        throw unexpectedResponse("missing listing_id or items array");
      }
    
      return data as RawSearchResults;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NazarLysyi/brickognize-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server