Skip to content

Run the image, OCR, redaction and Office engines in Node, for the MCP server #61

Open

Description

@kingrishabdugar

Part of #57.

Background

These engines use browser-only APIs, so the MCP server can't call them yet:

  • compress.ts: OffscreenCanvas, createImageBitmap
  • raster.ts: pdf.js rendering to a canvas (redaction and scanned PDF)
  • ocr.ts: Tesseract with a canvas
  • stamp.ts, convert.ts, office.ts

Goal

Introduce a small canvas/image interface that the browser implements with its native APIs and Node implements with a library such as @napi-rs/canvas or sharp. The website should keep working exactly as today, with no new code shipped to browsers.

Once that works, add MCP tools for:

  • compressing an image, including to a target size in KB;
  • resizing and converting images;
  • compressing a PDF;
  • PDF to text or Markdown;
  • OCR;
  • redacting a PDF;
  • removing Office metadata.

Done when

  • The Node backend has unit tests that run the engines on the fixtures.
  • The existing web e2e suite still passes unchanged.
  • Adding the new tools to the MCP server is a small follow-up (or part of the same PR if it stays reviewable).

This one is best split into several PRs, one engine at a time. Comment with which engine you're picking.

Activity

  1. avanithumballi commented on Oct 1, 2026

    @avanithumballi
    Contributor

    Hi! @kingrishabdugar I'd like to contribute to this issue as part of Hacktoberfest 2026. I have experience with Node.js, TypeScript, backend development, and AI-based applications, and I'm interested in working on one of the engines for the Node/MCP implementation.

    I'll first go through the existing browser implementation and the Node-side abstraction to understand the architecture, then I can take up an individual engine and add the corresponding Node implementation and unit tests.

    I'd be happy to take an engine that is still unassigned. Please let me know if there is a particular engine you'd prefer me to work on.

  2. kingrishabdugar commented on Oct 1, 2026

    @kingrishabdugar
    OwnerAuthor

    Hi @avanithumballi, thanks a lot for offering, and welcome! It's yours: I'll assign this to you.

    Since this is best done one engine at a time, here's the order I'd suggest:

    1. Start with the engines that need no canvas. These already run in Node as plain functions, so they can become MCP tools right away:

    • cleanOffice in src/engine/local.ts: remove Office metadata (.docx/.xlsx/.pptx)
    • xlsxToJson, jsonToXlsx, xlsxToCsv and csvToXlsx in src/engine/convert.ts

    The pattern to follow is the one the PDF and audio tools use in mcp/src/tools.ts. Read the file from disk, call the engine, write the result next to the input, and never overwrite a file. Then register the tools in mcp/src/server.ts and add tests to tests/mcp.test.ts that open the written file and check its contents, not just that it exists.

    2. Then the canvas interface, starting with image compress/resize/convert in compress.ts. Keep the browser path exactly as it is today, and make sure no Node code ends up in the website bundle. @napi-rs/canvas is a good fit: it ships prebuilt binaries and needs no system libraries. Please open a draft PR early for this one so we can agree on the interface before you go far.

    Before you open a PR:

    • npm install && npm run build:mcp, then npx tsc --noEmit && npx vitest run
    • npm run build && npx playwright test: the web e2e suite must pass unchanged
    • One engine per PR, with tests that use the fixtures in tests/fixtures/
    • Anything a tool can't carry over should be reported in plain words, not dropped silently (the existing tools show how)

    The contributing guide covers setup and conventions. If anything is unclear, ask here and I'll help. Looking forward to your PR! 🎃

  3. avanithumballi commented on Oct 2, 2026

    @avanithumballi
    Contributor

    @kingrishabdugar thanks for assigning . i will start working and i will let you know if i have any sorts of doubts

  4. kingrishabdugar commented on Oct 8, 2026

    @kingrishabdugar
    OwnerAuthor

    Hi @avanithumballi, hope you're doing well! Just checking in to see how it's going with the Node engines. No rush at all.

    If anything is unclear or you're stuck anywhere (setting up the repo, running the tests, or picking which engine to start with), just ask here and I'll help. It's also completely fine to open a small draft PR with one engine first, even if it's not finished, so I can give early feedback.

    Thanks again for picking this up!

  5. avanithumballi commented on Oct 9, 2026

    @avanithumballi
    Contributor

    Hi, Sorry for replying late i had my final exams going on. I am done with it. If i have any doubts i will be asking you. Thank you

  6. kingrishabdugar commented on Oct 9, 2026

    @kingrishabdugar
    OwnerAuthor

    Welcome back, @avanithumballi! Thanks for #93, I've left a short review there. Take your time with the next ones, one tool per PR works great.

  7. added a commit that references this issue on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions