Skip to content

Commit 204e0eb

Browse files
raman325claude
andcommitted
feat: add introspect module with commands endpoint
Add a new `introspect` command module that returns the JSON Schema describing all incoming message types. The `introspect.commands` command works before `initialize`, enabling API discovery pre-negotiation. - Create `src/lib/introspect/` module (command, incoming_message, outgoing_message, message_handler) following existing patterns - Register in Instance enum and wire into server.ts - Add `ts-json-schema-generator` for build-time schema generation - Rename interfaces for `$ref` reuse (node, driver, controller, multicast_group incoming messages) - Add introspection section to README with tool recommendations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eac2df0 commit 204e0eb

17 files changed

+449
-95
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ config.json
88
*.tgz
99
cache
1010
.claude
11+
/src/lib/generated/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,33 @@ interface {
181181
}
182182
```
183183

184+
### Introspection
185+
186+
The server supports introspection commands that allow clients to discover the API at runtime. These commands work **before `initialize`**, so clients can explore the API before negotiating a schema version.
187+
188+
#### Get command schema
189+
190+
Returns the full [JSON Schema](https://json-schema.org/) describing all incoming message types. The schema uses `$ref` pointers and a shared `definitions` dictionary for compact representation.
191+
192+
```ts
193+
interface {
194+
messageId: string;
195+
command: "introspect.commands";
196+
}
197+
```
198+
199+
Returns a JSON Schema (Draft 7) object describing all valid incoming messages.
200+
201+
**Exploring the schema**
202+
203+
The returned schema can be explored with any JSON Schema-compatible tool:
204+
205+
- **[jq](https://jqlang.org/)** — Query the schema from the command line (e.g. `jq '.definitions.IncomingMessageNode'`)
206+
- **[JSON Schema Viewer](https://json-schema.app/)** — Paste the schema into the online viewer for interactive exploration
207+
- **[JSON Crack](https://jsoncrack.com/)** — Visualize the schema as an interactive graph
208+
- **VS Code** — Extensions like [JSON Schema Viewer](https://marketplace.visualstudio.com/items?itemName=jock.svg) provide in-editor navigation
209+
- **[jsonschema](https://python-jsonschema.readthedocs.io/) (Python)** / **[ajv](https://ajv.js.org/) (JS)** — Validate messages programmatically against the schema
210+
184211
### Driver level commands
185212

186213
#### Get the config of the driver

0 commit comments

Comments
 (0)