@datarealiser/mcp-tools
v0.1.0
Published
A curated, tag-driven subset of @datarealiser/api-client — only kernel-api endpoints whose route is tagged @mcpTool are reachable through this package. See README.md.
Readme
@datarealiser/mcp-tools
A curated, tag-driven subset of @datarealiser/api-client
— only kernel-api endpoints whose route is explicitly tagged @mcpTool
are reachable through this package. Built for
mcp-server, so it can depend on this
instead of the full api-client surface: a consumer of this package
literally cannot call an endpoint nobody opted in, regardless of what
api-client itself exposes — the safety boundary is enforced by what
exists on McpToolsClient, not by code-review discipline in the
consumer.
Tagging an endpoint
Endpoints are not tagged by default. To expose one:
Make sure its
@datarealiser/api-clientmethod has a real signature insrc/types/apiClient.d.ts'sDatarealiserApiClientMethods— add one if it's missing.Add a tag directly above the route in
kernel/src/routes/*.routes.ts:/** * @mcpTool getQuery * @mcpDescription Fetches one saved query's sql and declared params by name. Needs queries:manage. */ router.get('/:name', ...);@mcpTool <name>must be the exact method name onDatarealiserApiClient(the two are 1:1 — this package only ever delegates, never reimplements).@mcpDescriptionis a single line; it becomes both the generated method's JSDoc and (conventionally) the MCP tool's own description inmcp-server/src/tools.ts.Regenerate:
npm run generateThis rewrites
src/index.jsandsrc/index.d.tsfrom scratch — never hand-edit either. The generator fails loudly (naming the file/tag) if a tag has no matching signature insrc/types/apiClient.d.ts, or if the same name is tagged twice.
Untagging: remove the @mcpTool/@mcpDescription comment and
regenerate — the method disappears from McpToolsClient entirely, not
just from wherever a consumer happened to be calling it.
Publishing
./publish.sh # regenerates, smoke-tests, then npm publish
./publish.sh --dry-runBump "version" in package.json first, same as api-client/publish.sh.
Design notes
- Delegates to
api-client, doesn't duplicate it.McpToolsClientwraps a realDatarealiserApiClientinstance internally (dependenciesinpackage.json); each generated method is a thin(...args) => this.#client.<name>(...args)passthrough. One HTTP/ auth/error-handling implementation to maintain (api-client's), not two. - No MCP SDK dependency. This package only narrows which kernel-api
calls are reachable — it knows nothing about the Model Context
Protocol itself (no zod schemas, no
registerToolwiring). That stays inmcp-server/src/tools.ts, which decides how each allowed method becomes an MCP tool (title, input schema, etc.). Keeping the layers separate means this package is reusable anywhere a curated kernel-api client is useful, not just from an MCP server. - Ships a real
.d.ts, unlikeapi-client(which ships none, by its own design choice — every consumer hand-maintains its own partial declaration). Since this package is generated, not hand-written, there was no reason to repeat that pattern:src/index.d.tsis always exactly in sync withsrc/index.js.
