Inspiration

Food waste usually starts small: a bag of spinach, half a litre of milk, chicken that was "meant for tonight". People forget what they have, buy duplicates, and throw food away. I wanted a pantry tracker that answers the real question, "what can I cook with what is about to expire?", and then turns the gaps into a shopping list.

What it does

ShelfSense is a pantry and meal-planning app with a conversational assistant.

  • Dashboard shows real pantry stats, expiring and expired items, recent additions, meal ideas and shopping status.
  • Pantry supports add, edit, delete, search, filter and sort. Items with different expiry dates are stored as separate batches.
  • Meal planner ranks a hand-curated recipe set by how much soon-to-expire food each recipe uses, and shows what is available and what is missing. Matching is deterministic and the recipes are not AI-generated.
  • Shopping list lets you add recipe ingredients without duplicates. Adding the same recipe twice never inflates quantities.
  • Assistant handles requests such as "What can I cook using ingredients that will expire soon?" and "I used one liter of milk". Each answer comes from a real MCP tool call, and a chip appears only after the call actually finishes.
  • Settings stores a dietary restriction, preferred cuisine and default servings.

How I built it

The architecture is: React UI, official MCP client, Streamable HTTP /mcp, MCP tools, shared services, MongoDB Atlas.

  • MCP server (Node.js, Express, official MCP TypeScript SDK) exposes 18 Zod-validated tools over Streamable HTTP, protocol version 2025-11-25. It is stateless: each request gets a fresh server and transport.
  • Web client (React, Vite, Tailwind) talks to the server with the official MCP client. There are no REST shims.
  • Data integrity: consuming stock uses the earliest-expiring batch first with an atomic guard so quantities can never go negative. Unit conversion happens only within the same dimension (g/kg, ml/l), so pieces are never mixed with weights. Expired items never count as available for a recipe.
  • Security: every /mcp request needs a bearer token, compared in constant time, plus rate limiting, Helmet, explicit CORS and a request size limit. The access code is typed at runtime and never bundled into the frontend.
  • Assistant: a deterministic intent router, so the app works with no AI key. Ambiguous requests get a clarifying question instead of an action.

Verification

  • Automated tests for dates and expiry, unit conversion, recipe matching and assistant intent parsing.
  • An integration test that drives a real MCP client against MongoDB (auth rejection, tool discovery, validation errors, never-negative stock, idempotent shopping updates, persistence across a fresh connection).
  • The official MCP Inspector: initialize, tool discovery (18 tools), tool calls, error handling and 401 without a token.
  • A manual pass through every page, including mobile layout and a production build.

Challenges

  • Auth with the Inspector. A bearer-token server returned 401 and then triggered OAuth discovery requests that all 404ed. The header field was not in the server edit dialog, so I had to find where custom headers go.
  • Keeping inventory correct. Preventing negative stock, merging identical batches, and keeping shopping updates idempotent under repeated calls took careful atomic MongoDB operations.
  • Windows tooling. PowerShell 5.1 does not support &&, and an ESM "run this file directly" check failed on Windows paths, which silently stopped the seed script from running.
  • Atlas connection issues. A leftover <cluster> placeholder and a stale password produced EBADNAME and bad auth.

What I learned

Stateless Streamable HTTP keeps a server simple to deploy. Validating every tool input with Zod and returning structured errors makes an MCP server much easier to test and debug, and showing only completed tool calls in the UI makes the assistant trustworthy.

What's next

Real per-user accounts, so data is isolated per household. OAuth-style account linking, so it can be tested with Alexa+. Barcode or receipt entry, and expiry-reminder notifications.

Honest limitations

ShelfSense is a self-hosted MCP server with a simulated conversational web layer. It is not a native Alexa+ skill, and Alexa+ account linking and certification have not been tested. The demo uses one shared access token and one shared dataset, with no user accounts.

Code and setup instructions: https://github.com/hassanshahid5218/shelfsense

Built With

Share this project:

Updates

Submission history