Repository navigation
fix(mcp): unwrap i3X envelopes, surface errors, read components, real in-process routes - #3
Merged
Merged
Conversation
The client read bare keys (res.objects, res.values, ...) while node-i3x
answers { success, result } and bulk { success, results: [...] }, so every
tool returned empty lists without error. Unwrap both envelopes; a
success:false envelope or a failed bulk item now throws with its
responseDetail, and getObjectById returns null only for a 404 item.
Also: strip a trailing /v1 from the base URL (was /v1/v1), send elementIds
to /objects/related and read .object, keep the parent out of inspect's
subComponents, read inspect values with maxDepth 2 (an Object's readings
are its components), and take the advertised version from package.json.
…ess routes
Values/history now come back per element ({elementId, result|error}), so
history reports keep their own elementId after a failure; stats are per
series including components; GoodNoData is not bad; invalid or inverted
times are errors. maxDepth (default 2) is exposed on inspect, telemetry and
monitor, since an Object's readings are its components. Related results keep
sourceRelationship; explore follows children by parentId. Suggestions match
displayName and reuse the object list for 60 s. monitor_asset_events is a
one-shot snapshot with quality alerts: it no longer claims a subscription.
InProcessConnectorBinding now runs the real rest-server routes via inject()
(createApp gains a logger option: Fastify logs to stdout, the MCP channel).
Contract tests drive those routes; they fail on the previous sources.
…shared children - monitor_asset_events alerts on an element read that is Bad with value null (how a failed read looks); the value guard skipped exactly those. - InProcessConnectorBinding moves to the mcp package's in-process subpath export, and the rest-server package becomes an optional peer dependency, so the REST-only CLI no longer installs Fastify and its plugins. - explore/inspect drop reverse relationships instead of filtering on parentId, which names a single parent: a shared component now shows under each parent. - A successful bulk item without result becomes a per-element error instead of an entry with neither result nor error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom: against a real node-i3x server every
@node-i3x/mcptool returned empty without error:i3x_explore_plant_hierarchyreported 0 roots (server has 84),i3x_inspect_assetsaid "not found" for existing assets, history and types came back empty. A base URL ending in/v1gave/v1/v1/...404s.Cause: the REST client read bare keys (
res.objects,res.values, ...) while the server wraps every payload in{success, result}/{success, results: [...]}, and it swallowed every error intonull/[]. The in-process binding re-implemented the routes and diverged (parentIdundefined, hardcoded info).Fix:
success:falseraises an error carrying itsresponseDetail; only a per-item 404 means "not found".{elementId, result | error})./v1from the base URL./objects/relatednow sendselementIdsand keepssourceRelationship.maxDepth(default 2) on inspect, telemetry and monitor: an Object's readings are its components.displayName(cached for 60 s).InProcessConnectorBindingnow runs the real rest-server routes throughinject(). Version comes frompackage.json.Tests:
tests/rest-binding.test.ts(fetch stub: envelopes, error envelopes, both URL forms) andtests/contract.test.ts(real rest-server throughinject(), no port). Run againstmain's sources, 24 of them fail.Checked manually over stdio against a portal instance: 84 roots, and CoffeeMachineA returns its sub-components and component values.
Caveats:
I3XClientBindinginterface (related, values, history and suggestion return shapes).InProcessConnectorBindingnow takesRestServerDepsinstead ofI3xStack, and is no longer exported from the package root.InProcessConnectorBinding(andinjectFetch) moved to the@node-i3x/mcp/in-processsubpath export;@node-i3x/rest-serveris an optional peer dependency, so the REST-only CLI installs no Fastify.createAppgained an optional{ logger }argument, because Fastify logs to stdout, which is the MCP stdio channel.i3x_monitor_asset_eventskeeps its name but is now an honest one-shot snapshot with quality alerts. It never subscribed; real streaming over/v1/subscriptionsis not implemented.