Local tool server package / 2026 / In progress · Anonymized work
Research MCP Service.
A local tool server that checks every research tool call on the way in and on the way out
Part of the Research Workflow Engine journey- Role
- Software engineering
- Built with
- TypeScript · Node.js · MCP SDK · Zod · SQLite · esbuild · Vitest
01What I built
The problem.
A program calling a tool can send badly formed input. It may also try again when something fails. A tool might accept junk, send back an answer in a shape the caller didn’t expect, or leak a raw error. Then the caller can’t tell what to do next. And a retry must not be mistaken for a second, separate attempt.
What I built.
Research A technical wordMCPModel Context Protocol. A standard way for AI apps to find and use tools that other programs offer. Service is an MCP server. It offers the engine’s actions to AI apps as tools, each with a fixed shape. Programs talk to it through standard input and output, the plain text channels a command-line program uses. A registry, a list of every tool, holds each tool’s version and its input and output rules. One shared service handles every call. It reads the input, sent as A technical wordJSONA common text format that programs use to send each other structured data. text, and limits how deeply data can sit inside other data. Then it hands the work to the engine’s own code, and checks the result before it goes back. The research rules and the saved data stay with the engine.
The server
TypeScript, Node.js, MCP SDK, Zod, esbuild, Vitest
- Tool registry
- Holds each tool’s version, its strict input rules and output rules, and short notes that describe it.
- Error mapping
- Sorts known failures into types, each with retry advice. Any unknown failure becomes one fixed internal error.The storyReturning useful errors without recording a failed save twice
- Output streams
- Sends protocol messages on the standard output channel, and start and stop logs on the error channel. The logs leave out file paths and the computer’s settings.
- Packaged process
- Ships as one bundle, with the piece that lets it use SQLite and the steps that set up the database. It keeps saved data away from the installed code.
Confidential work. Names and identifying business details have been changed.
02The journey
What broke, and what changed.
Broke, then fixedA decisionA milestone
- 01 of 04Decided
One service behind both the protocol and the tests
The questionThe tools can be reached through A technical wordMCPModel Context Protocol. A standard way for AI apps to find and use tools that other programs offer., the Model Context Protocol, or called directly in tests. Two separate routes through the code would mean two sets of checks.
What I choseSo one shared serviceResearch MCP Service · The serverShared serviceReads the input and limits how deeply data can sit inside other data. Then it hands the work to the engine and checks the result.See it in the map above sits behind both routes. Every caller gets the same checks and the same code doing the work. Separate protocol tests still check how tools are listed and how messages travel. A direct call can’t reach those parts.
- 02 of 04Decided
Check what goes out, not just what comes in
The questionGood input doesn’t stop a tool’s code from sending back an answer in a new shape the caller isn’t expecting.
What I choseSo every successful answer is checked against its tool’s output rulesResearch MCP Service · The serverTool registryHolds each tool’s version, its strict input rules and output rules, and short notes that describe it.See it in the map above before it reaches the caller. Each tool’s rules have their own version, separate from the version of the whole package.
- 03 of 04Decided
Useful errors, and no second record of one failed save
The questionAn error message has to tell the caller how to retry. It must not show the raw error from inside the code. A save can carry a retry key. A retry that reuses that key with changed input shouldn’t look like another first attempt.
What I choseBadly formed calls stop before any tool code runs. Known failuresResearch MCP Service · The serverError mappingSorts known failures into types, each with retry advice. Any unknown failure becomes one fixed internal error.See it in the map above keep their type and their retry advice. Unknown ones get one fixed internal error. A retry that reuses an old key with changed input adds no extra record of the failure.
- 04 of 04Decided
Ship one bundle, and treat it as a real running program
The questionA single bundleResearch MCP Service · The serverPackaged processShips as one bundle, with the piece that lets it use SQLite and the steps that set up the database. It keeps saved data away from the installed code.See it in the map above, one package to install, is easy to hand out. But the piece that lets it use SQLite still has to load and run.
What I choseThe bundle carries that SQLite piece and the steps that set up the database. It keeps saved data out of the installed code. When it shuts down, it closes the server and the database. Tests of the tool code can’t cover any of this. So the packaging, and how the program starts and stops, need tests of their own.
03Today
Where it stands.
Tests that call the code directly don’t cover the packaged program or the protocol. I haven’t compared the installed plugin with this code. The server can’t tell whether an observation it is given is true. Known error messages are passed on as they are. So the code that writes them has to keep private details out.