Putting a Model Context Protocol server over a commercial POS
Before this, answering a question about the business meant writing a script. "Which outlet is losing the most on wastage this quarter" was twenty minutes of pulling the POS API, reshaping it in pandas, and printing a table. The script was then thrown away, because the next question was slightly different.
That is an enormous amount of work to answer a question that a person could ask in one sentence. So I built a Model Context Protocol server over the Petpooja POS cloud, and now the question is the one sentence.
What MCP actually is
MCP is a protocol for handing a model a set of callable tools, each with a declared JSON schema for its arguments and its return shape. The model does not see your API. It sees a menu of named operations with typed parameters, and it picks one.
The interesting part is not the plumbing — the SDK handles that. The interesting part is where you draw the tool boundary, because that decision determines whether the model is useful or dangerous.
Wrong boundary: mirror the REST API
My first attempt exposed the POS endpoints roughly one-to-one. Fourteen endpoints became fourteen tools. It worked, in the sense that calls succeeded, and it was close to useless.
The model would fetch a raw order list, get back several thousand records, and then
try to reason about them in the context window. It ran out of room, and the arithmetic it
did on the records it could see was arithmetic a database should have done. A model is a
bad place to do a GROUP BY.
Right boundary: expose the questions, not the endpoints
The tools that work are shaped like the questions people actually ask:
sales_by_outlet(date_from, date_to, segment=None)
wastage_summary(outlet_id, period)
item_movement(item_name, outlet_id=None, period="30d")
price_variance(outlet_id, period)
stock_on_hand(outlet_id, category=None)
Each one does its aggregation in PostgreSQL and returns tens of rows, not thousands. The model receives a small, already-correct result and spends its effort on interpretation, which is the part it is genuinely good at.
This is the whole lesson, and it transfers to any agent you build: a tool should return an answer, not a dataset. If the model has to aggregate what you handed back, you drew the boundary one level too low.
Schemas are a safety mechanism, not documentation
Every argument is validated before anything executes. outlet_id must be
an integer that exists. period must match a known pattern. Dates must
parse, and the range cannot exceed a year.
This matters more than it does in ordinary code, because the caller is a language
model and a language model will confidently pass outlet_id="the Prahlad Nagar
one". With a schema that is a clean validation error the model can read and
correct in one turn. Without one it is a confusing 500 from a vendor API, or worse, a
query that silently returns nothing and gets reported as "no wastage this quarter".
A tool that fails loudly is a tool a model can use. A tool that fails quietly is how you get a confidently wrong answer in front of a business owner.
Read-only, deliberately
Every tool on this server reads. None of them writes. No tool voids a bill, adjusts stock, or changes a price.
That was not a technical limitation and it would not have been hard to add. It is that the value here is entirely in the asking, and the risk of a write path is entirely asymmetric. The upside of "the model can also fix it" is small; the downside of a model confidently adjusting stock on a misparsed instruction is a corrupted inventory ledger that someone has to reconstruct by hand.
When write operations do become worth it, they go behind an explicit human approval step — the model drafts the mutation, a person confirms it, and only then does it execute. I use exactly that pattern in a vendor-payment bot elsewhere in the estate: it drafts the message from the bank statement, and a human presses send.
What changed
The scripts are gone. Questions that used to cost twenty minutes cost one sentence, and — more useful than the speed — people now ask questions they previously would not have bothered to ask, because the cost of asking fell to roughly zero.
That is the actual return on an MCP server. Not that it answers faster, but that it changes which questions are worth asking.