Back to the journal

MCP and REST APIs, part 1: expose warehouse operations as tools

Build the service boundary first: FastAPI operations, Redis data, MCP tools, and direct inspection before adding a model.

MCP / FastAPI / AI architecture

An existing application already knows how to validate and perform its business operations. An MCP integration can expose selected operations to an AI application while keeping that service boundary in place.

The first part of this series built a small warehouse-order API with FastAPI and Redis, then connected it to an MCP server using fastapi-mcp. The exercise made it possible to compare a conventional API request with an invocation through an MCP client.

Start with operations you can test directly

The service created, retrieved, listed, updated, and deleted orders. Each order included an identifier, a customer name, items, and a status. Redis hashes held the order data, with a set tracking order identifiers and a counter supplying new IDs.

POST   /orders             create an order
GET    /orders             list orders
GET    /orders/{order_id}  retrieve an order
PUT    /orders/{order_id}  update an order
DELETE /orders/{order_id}  delete an order

Test those operations through the API before adding a model. A tool wrapper cannot repair incorrect validation or an inconsistent data update. The storage example also needs an explicit persistence configuration if data must survive a Redis restart.

Expose a deliberate tool surface

The integration mapped API operations into MCP tools. This gives a client structured descriptions and inputs to work with; it does not make every generated argument valid or every available operation appropriate for every user.

In this example, the application layer is a useful place to retain business rules. That is a design choice for the warehouse service, not a claim that every database-backed MCP server must use a REST intermediary.

Inspect the MCP connection independently

The original walkthrough used MCP Inspector to list tools and invoke a read operation. That separates server connectivity from model behaviour. Compare the result with a direct request to the API before trying natural-language interaction.

The historical setup used SSE and an MCP endpoint mounted on the FastAPI application. Transport and mounting APIs vary by library version, so consult the original project files when studying that implementation.

Adding MCP does not supply authorization automatically. Decide who may read or modify an order at the service boundary. In part 2, the same tools are connected to a local model; part 3 moves the workflow into a Python agent.

Keep following your curiosity.

Back to the journal.
MCP and REST APIs, part 1: expose warehouse operations as tools | Timur Isachenko