Back to the journal

MCP and REST APIs, part 2: connect a local model to the service

Connect Ollama and mcp-cli to the warehouse example, then separate tool discovery from correct execution.

MCP / Ollama / FastAPI

With the warehouse API and MCP server working, the next step is to place a local model in the loop. The second part of the series used Ollama and mcp-cli to translate natural-language requests into calls to the exposed tools.

The original experiment used a tool-capable model such as Qwen 2.5. Choosing a model that can chat is not enough to establish that it supports the tool-calling interface required by the client.

Verify discovery before interpretation

Start the API and its backing Redis instance. Configure the MCP client to reach the server, start local inference, and inspect the available tool list. In the historical client, the chat command /tools displayed those capabilities.

Then ask for all warehouse orders. Compare the returned records with a direct API query. Follow with a narrower request, such as listing orders in a pending state. These checks reveal whether the model selected a suitable tool and interpreted its result correctly.

Treat writes as a separate capability

The original demonstration also included deleting an order by customer name. A name can match more than one record, so a dependable application should resolve the intended order IDs before performing the operation.

For an illustrative cancellation flow, first retrieve candidate orders, display their identifiers and statuses, and obtain confirmation for the specific records to change. The service must still enforce the caller’s permissions. A persuasive natural-language request does not replace that boundary.

Understand the container network

The article packaged FastAPI and Redis in Docker Compose. Inside that Compose network, the application addressed Redis using its service hostname. A model server running on the host is a different connection and needs its own reachable address.

Local model ↔ MCP client ↔ MCP server / FastAPI ↔ Redis

Keep each connection independently testable. If the database is unavailable, inspect the API-to-Redis path. If no tools appear, inspect the MCP connection. If the wrong tool is chosen, examine the model interaction and tool descriptions.

The original FastAPI files and mcp-cli project document the historical setup. Local inference gives control over where model requests run; it does not by itself establish reliability or privacy for every connected component.

Continue to part 3 to make this interaction an explicit Python workflow, or revisit the service foundation.

Keep following your curiosity.

Back to the journal.
MCP and REST APIs, part 2: connect a local model to the service | Timur Isachenko