@thingd/sdk 0.71.0 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/package.json +2 -3
  2. package/dist/client/http-thing-store.d.ts +0 -55
  3. package/dist/client/http-thing-store.d.ts.map +0 -1
  4. package/dist/client/http-thing-store.js +0 -233
  5. package/dist/client/in-memory-thing-store.d.ts +0 -41
  6. package/dist/client/in-memory-thing-store.d.ts.map +0 -1
  7. package/dist/client/in-memory-thing-store.js +0 -292
  8. package/dist/client/index.d.ts +0 -5
  9. package/dist/client/index.d.ts.map +0 -1
  10. package/dist/client/index.js +0 -3
  11. package/dist/client/thingd.d.ts +0 -24
  12. package/dist/client/thingd.d.ts.map +0 -1
  13. package/dist/client/thingd.js +0 -27
  14. package/dist/constants.d.ts +0 -2
  15. package/dist/constants.d.ts.map +0 -1
  16. package/dist/constants.js +0 -1
  17. package/dist/index.d.ts +0 -13
  18. package/dist/index.d.ts.map +0 -1
  19. package/dist/index.js +0 -11
  20. package/dist/mcp/audit.d.ts +0 -27
  21. package/dist/mcp/audit.d.ts.map +0 -1
  22. package/dist/mcp/audit.js +0 -36
  23. package/dist/mcp/config.d.ts +0 -22
  24. package/dist/mcp/config.d.ts.map +0 -1
  25. package/dist/mcp/config.js +0 -52
  26. package/dist/mcp/index.d.ts +0 -6
  27. package/dist/mcp/index.d.ts.map +0 -1
  28. package/dist/mcp/index.js +0 -5
  29. package/dist/mcp/result.d.ts +0 -3
  30. package/dist/mcp/result.d.ts.map +0 -1
  31. package/dist/mcp/result.js +0 -10
  32. package/dist/mcp/server.d.ts +0 -19
  33. package/dist/mcp/server.d.ts.map +0 -1
  34. package/dist/mcp/server.js +0 -51
  35. package/dist/mcp/tools.d.ts +0 -10
  36. package/dist/mcp/tools.d.ts.map +0 -1
  37. package/dist/mcp/tools.js +0 -1033
  38. package/dist/memory/index.d.ts +0 -7
  39. package/dist/memory/index.d.ts.map +0 -1
  40. package/dist/memory/index.js +0 -7
  41. package/dist/rest/helpers.d.ts +0 -17
  42. package/dist/rest/helpers.d.ts.map +0 -1
  43. package/dist/rest/helpers.js +0 -60
  44. package/dist/rest/index.d.ts +0 -3
  45. package/dist/rest/index.d.ts.map +0 -1
  46. package/dist/rest/index.js +0 -2
  47. package/dist/rest/server.d.ts +0 -4
  48. package/dist/rest/server.d.ts.map +0 -1
  49. package/dist/rest/server.js +0 -472
  50. package/dist/scheduler.d.ts +0 -28
  51. package/dist/scheduler.d.ts.map +0 -1
  52. package/dist/scheduler.js +0 -451
  53. package/dist/stores/cloud-thing-store.d.ts +0 -63
  54. package/dist/stores/cloud-thing-store.d.ts.map +0 -1
  55. package/dist/stores/cloud-thing-store.js +0 -396
  56. package/dist/stores/in-memory-thing-store.d.ts +0 -62
  57. package/dist/stores/in-memory-thing-store.d.ts.map +0 -1
  58. package/dist/stores/in-memory-thing-store.js +0 -709
  59. package/dist/stores/native-thing-store.d.ts +0 -62
  60. package/dist/stores/native-thing-store.d.ts.map +0 -1
  61. package/dist/stores/native-thing-store.js +0 -374
  62. package/dist/thingd.d.ts +0 -87
  63. package/dist/thingd.d.ts.map +0 -1
  64. package/dist/thingd.js +0 -236
  65. package/dist/types/index.d.ts +0 -2
  66. package/dist/types/index.d.ts.map +0 -1
  67. package/dist/types/index.js +0 -1
  68. package/dist/types.d.ts +0 -435
  69. package/dist/types.d.ts.map +0 -1
  70. package/dist/types.js +0 -1
  71. package/dist/version.d.ts +0 -6
  72. package/dist/version.d.ts.map +0 -1
  73. package/dist/version.js +0 -5
@@ -1,3 +0,0 @@
1
- export { HttpThingStore } from "./http-thing-store.js";
2
- export { InMemoryThingStore } from "./in-memory-thing-store.js";
3
- export { openThingD, } from "./thingd.js";
@@ -1,24 +0,0 @@
1
- import { HttpThingStore } from "./http-thing-store.js";
2
- import { InMemoryThingStore } from "./in-memory-thing-store.js";
3
- export type { ThingDDriver, ThingDOpenConfig, ThingDOpenOptions, } from "../thingd.js";
4
- export type ThingDClientOptions = {
5
- driver?: "memory" | "cloud";
6
- url?: string;
7
- authToken?: string;
8
- apiKey?: string;
9
- };
10
- /**
11
- * Open a thingd connection from a browser/edge-compatible environment.
12
- *
13
- * Unlike ThingD.open() from the main entry point, this does NOT read from
14
- * process.env — all configuration must be passed explicitly.
15
- *
16
- * @example
17
- * ```ts
18
- * const db = await openThingD({ url: "http://localhost:8757" });
19
- * await db.put("notes", { id: "1", text: "hello" });
20
- * ```
21
- */
22
- export declare function openThingD(options?: ThingDClientOptions): Promise<HttpThingStore | InMemoryThingStore>;
23
- export { HttpThingStore, InMemoryThingStore };
24
- //# sourceMappingURL=thingd.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thingd.d.ts","sourceRoot":"","sources":["../../src/client/thingd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAMF;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAC9B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,cAAc,GAAG,kBAAkB,CAAC,CAS9C;AAED,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,27 +0,0 @@
1
- import { HttpThingStore } from "./http-thing-store.js";
2
- import { InMemoryThingStore } from "./in-memory-thing-store.js";
3
- function resolveToken(options) {
4
- return options.authToken ?? options.apiKey;
5
- }
6
- /**
7
- * Open a thingd connection from a browser/edge-compatible environment.
8
- *
9
- * Unlike ThingD.open() from the main entry point, this does NOT read from
10
- * process.env — all configuration must be passed explicitly.
11
- *
12
- * @example
13
- * ```ts
14
- * const db = await openThingD({ url: "http://localhost:8757" });
15
- * await db.put("notes", { id: "1", text: "hello" });
16
- * ```
17
- */
18
- export async function openThingD(options = {}) {
19
- if (options.driver === "memory" || !options.url) {
20
- return new InMemoryThingStore();
21
- }
22
- return HttpThingStore.open({
23
- url: options.url,
24
- authToken: resolveToken(options),
25
- });
26
- }
27
- export { HttpThingStore, InMemoryThingStore };
@@ -1,2 +0,0 @@
1
- export declare const MCP_TOOL_COUNT: 46;
2
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,EAAG,EAAW,CAAC"}
package/dist/constants.js DELETED
@@ -1 +0,0 @@
1
- export const MCP_TOOL_COUNT = 46;
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export { MCP_TOOL_COUNT } from "./constants.js";
2
- export { appendMcpAuditEvent, createThingdMcpServer, jsonResult, parseCollectionAllowlist, parsePayloadSizeLimit, type RegisterThingdToolsOptions, readMcpHardeningOptionsFromEnv, registerThingdTools, resolveThingdMcpAuditOptions, type ThingdMcpAuditMetadata, type ThingdMcpAuditOptions, type ThingdMcpHardeningOptions, type ThingdMcpServerOptions, } from "./mcp/index.js";
3
- export { handleRestRequest, parseFilter, parseIntParam, parseSortBy, readBody, sendData, sendDataList, sendError, sendJson, } from "./rest/index.js";
4
- export { Scheduler } from "./scheduler.js";
5
- export type { CloudThingStoreOptions } from "./stores/cloud-thing-store.js";
6
- export { CloudThingStore } from "./stores/cloud-thing-store.js";
7
- export { InMemoryThingStore } from "./stores/in-memory-thing-store.js";
8
- export { NativeThingStore } from "./stores/native-thing-store.js";
9
- export type { ThingDDriver, ThingDOpenConfig, ThingDOpenOptions } from "./thingd.js";
10
- export { ThingD } from "./thingd.js";
11
- export type { ConnectorAuth, ConnectorSchema, ConnectorSyncOptions, ConnectorSyncResult, Link, LinkDirection, LinkQueryOptions, ListEventsOptions, ListObjectsOptions, MemoryEvent, MemoryObject, MemoryQueue, MemorySearchOptions, MemorySearchResult, PutOptions, QueueClaimOptions, QueueJob, QueueJobOptions, QueueJobPayload, QueueJobResult, QueueJobStatus, QueueNackOptions, Schedule, ScheduleContext, ScheduleEvent, ScheduleHandler, ScheduleIntervalOptions, ScheduleOnceOptions, ScheduleOptions, SchedulerEventType, SchedulerFacade, SchedulerListener, SchedulerStats, SortBy, SortDirection, StoredMemoryEvent, StoredMemoryObject, ThingDConnection, ThingDeleteResult, ThingStore, } from "./types.js";
12
- export { SDK_VERSION } from "./version.js";
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,8BAA8B,EAC9B,mBAAmB,EACnB,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC5B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js DELETED
@@ -1,11 +0,0 @@
1
- // MCP server (tool handlers + factory)
2
- export { MCP_TOOL_COUNT } from "./constants.js";
3
- export { appendMcpAuditEvent, createThingdMcpServer, jsonResult, parseCollectionAllowlist, parsePayloadSizeLimit, readMcpHardeningOptionsFromEnv, registerThingdTools, resolveThingdMcpAuditOptions, } from "./mcp/index.js";
4
- // REST API (route handlers + helpers)
5
- export { handleRestRequest, parseFilter, parseIntParam, parseSortBy, readBody, sendData, sendDataList, sendError, sendJson, } from "./rest/index.js";
6
- export { Scheduler } from "./scheduler.js";
7
- export { CloudThingStore } from "./stores/cloud-thing-store.js";
8
- export { InMemoryThingStore } from "./stores/in-memory-thing-store.js";
9
- export { NativeThingStore } from "./stores/native-thing-store.js";
10
- export { ThingD } from "./thingd.js";
11
- export { SDK_VERSION } from "./version.js";
@@ -1,27 +0,0 @@
1
- import type { ThingD } from "../thingd.js";
2
- export type ThingdMcpAuditOptions = {
3
- enabled?: boolean;
4
- actor?: string;
5
- source?: string;
6
- stream?: string;
7
- };
8
- export type ThingdMcpAuditMetadata = {
9
- actor?: string;
10
- source?: string;
11
- };
12
- type ResolvedThingdMcpAuditOptions = {
13
- enabled: boolean;
14
- actor: string;
15
- source: string;
16
- stream: string;
17
- };
18
- type ThingdMcpAuditEventOptions = {
19
- action: string;
20
- target: Record<string, unknown>;
21
- metadata?: ThingdMcpAuditMetadata;
22
- result?: Record<string, unknown>;
23
- };
24
- export declare function resolveThingdMcpAuditOptions(options: ThingdMcpAuditOptions | false | undefined): ResolvedThingdMcpAuditOptions;
25
- export declare function appendMcpAuditEvent(db: ThingD, options: ResolvedThingdMcpAuditOptions, event: ThingdMcpAuditEventOptions): Promise<void>;
26
- export {};
27
- //# sourceMappingURL=audit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/mcp/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAMF,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,qBAAqB,GAAG,KAAK,GAAG,SAAS,GACjD,6BAA6B,CAgB/B;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,IAAI,CAAC,CAkBf"}
package/dist/mcp/audit.js DELETED
@@ -1,36 +0,0 @@
1
- const DEFAULT_AUDIT_STREAM = "__thingd:mcp:audit";
2
- const DEFAULT_AUDIT_ACTOR = "mcp-client";
3
- const DEFAULT_AUDIT_SOURCE = "thingd-mcp";
4
- export function resolveThingdMcpAuditOptions(options) {
5
- if (options === false || options?.enabled === false) {
6
- return {
7
- enabled: false,
8
- actor: DEFAULT_AUDIT_ACTOR,
9
- source: DEFAULT_AUDIT_SOURCE,
10
- stream: DEFAULT_AUDIT_STREAM,
11
- };
12
- }
13
- return {
14
- enabled: true,
15
- actor: options?.actor ?? DEFAULT_AUDIT_ACTOR,
16
- source: options?.source ?? DEFAULT_AUDIT_SOURCE,
17
- stream: options?.stream ?? DEFAULT_AUDIT_STREAM,
18
- };
19
- }
20
- export async function appendMcpAuditEvent(db, options, event) {
21
- if (!options.enabled) {
22
- return;
23
- }
24
- const actor = event.metadata?.actor ?? options.actor;
25
- const source = event.metadata?.source ?? options.source;
26
- const auditEvent = {
27
- type: `mcp.${event.action}`,
28
- text: `MCP ${event.action} by ${actor}`,
29
- actor,
30
- source,
31
- target: event.target,
32
- result: event.result,
33
- at: new Date().toISOString(),
34
- };
35
- await db.events.append(options.stream, auditEvent);
36
- }
@@ -1,22 +0,0 @@
1
- export type ThingdMcpHardeningOptions = {
2
- /** Comma-separated collection allowlist from THINGD_MCP_COLLECTIONS. Empty = all allowed. */
3
- collectionAllowlist?: Set<string>;
4
- /** When true, all write tools are rejected. Set via THINGD_MCP_READ_ONLY=true. */
5
- readOnly?: boolean;
6
- /** Maximum HTTP request body in bytes. Set via THINGD_MCP_MAX_PAYLOAD_BYTES. Default 512 KB. */
7
- maxPayloadBytes?: number;
8
- };
9
- /**
10
- * Parse THINGD_MCP_COLLECTIONS into a Set.
11
- * An empty string or missing env var means all collections are allowed.
12
- */
13
- export declare function parseCollectionAllowlist(value: string | undefined): Set<string> | undefined;
14
- /**
15
- * Parse THINGD_MCP_MAX_PAYLOAD_BYTES. Defaults to 512 KB if unset or zero.
16
- */
17
- export declare function parsePayloadSizeLimit(value: string | undefined, defaultBytes?: number): number;
18
- /**
19
- * Read all MCP hardening options from the environment.
20
- */
21
- export declare function readMcpHardeningOptionsFromEnv(env: Record<string, string | undefined>): ThingdMcpHardeningOptions;
22
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACtC,6FAA6F;IAC7F,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gGAAgG;IAChG,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAW3F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,SAAU,GAAG,MAAM,CAW/F;AAmBD;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,yBAAyB,CAQ3B"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Parse THINGD_MCP_COLLECTIONS into a Set.
3
- * An empty string or missing env var means all collections are allowed.
4
- */
5
- export function parseCollectionAllowlist(value) {
6
- if (!value?.trim()) {
7
- return undefined;
8
- }
9
- const names = value
10
- .split(",")
11
- .map((s) => s.trim())
12
- .filter(Boolean);
13
- return names.length > 0 ? new Set(names) : undefined;
14
- }
15
- /**
16
- * Parse THINGD_MCP_MAX_PAYLOAD_BYTES. Defaults to 512 KB if unset or zero.
17
- */
18
- export function parsePayloadSizeLimit(value, defaultBytes = 524_288) {
19
- if (!value) {
20
- return defaultBytes;
21
- }
22
- const n = Number.parseInt(value, 10);
23
- if (!Number.isInteger(n) || n <= 0) {
24
- throw new Error(`Invalid THINGD_MCP_MAX_PAYLOAD_BYTES: ${value}`);
25
- }
26
- return n;
27
- }
28
- function parseBooleanFlag(value, name) {
29
- if (!value) {
30
- return false;
31
- }
32
- const normalized = value.toLowerCase();
33
- if (["1", "true", "yes", "on"].includes(normalized)) {
34
- return true;
35
- }
36
- if (["0", "false", "no", "off"].includes(normalized)) {
37
- return false;
38
- }
39
- throw new Error(`Invalid ${name}: expected true or false`);
40
- }
41
- /**
42
- * Read all MCP hardening options from the environment.
43
- */
44
- export function readMcpHardeningOptionsFromEnv(env) {
45
- return {
46
- collectionAllowlist: parseCollectionAllowlist(env.THINGD_MCP_COLLECTIONS),
47
- readOnly: env.THINGD_MCP_READ_ONLY
48
- ? parseBooleanFlag(env.THINGD_MCP_READ_ONLY, "THINGD_MCP_READ_ONLY")
49
- : undefined,
50
- maxPayloadBytes: parsePayloadSizeLimit(env.THINGD_MCP_MAX_PAYLOAD_BYTES),
51
- };
52
- }
@@ -1,6 +0,0 @@
1
- export { appendMcpAuditEvent, resolveThingdMcpAuditOptions, type ThingdMcpAuditMetadata, type ThingdMcpAuditOptions, } from "./audit.js";
2
- export { parseCollectionAllowlist, parsePayloadSizeLimit, readMcpHardeningOptionsFromEnv, type ThingdMcpHardeningOptions, } from "./config.js";
3
- export { jsonResult } from "./result.js";
4
- export { createThingdMcpServer, type ThingdMcpServerOptions } from "./server.js";
5
- export { type RegisterThingdToolsOptions, registerThingdTools } from "./tools.js";
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,8BAA8B,EAC9B,KAAK,yBAAyB,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,KAAK,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
package/dist/mcp/index.js DELETED
@@ -1,5 +0,0 @@
1
- export { appendMcpAuditEvent, resolveThingdMcpAuditOptions, } from "./audit.js";
2
- export { parseCollectionAllowlist, parsePayloadSizeLimit, readMcpHardeningOptionsFromEnv, } from "./config.js";
3
- export { jsonResult } from "./result.js";
4
- export { createThingdMcpServer } from "./server.js";
5
- export { registerThingdTools } from "./tools.js";
@@ -1,3 +0,0 @@
1
- import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
- export declare function jsonResult(value: unknown): CallToolResult;
3
- //# sourceMappingURL=result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/mcp/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CASzD"}
@@ -1,10 +0,0 @@
1
- export function jsonResult(value) {
2
- return {
3
- content: [
4
- {
5
- type: "text",
6
- text: JSON.stringify(value, null, 2),
7
- },
8
- ],
9
- };
10
- }
@@ -1,19 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { ThingD } from "../thingd.js";
3
- import type { ThingdMcpAuditOptions } from "./audit.js";
4
- import type { ThingdMcpHardeningOptions } from "./config.js";
5
- export type ThingdMcpServerOptions = {
6
- audit?: ThingdMcpAuditOptions | false;
7
- hardening?: ThingdMcpHardeningOptions;
8
- };
9
- /**
10
- * Create a new McpServer with all thingd tools registered.
11
- *
12
- * Note: a new instance must be created per HTTP request because
13
- * @modelcontextprotocol/sdk's underlying Server.connect() throws if called
14
- * on an already-connected instance (stateless HTTP mode: one transport per
15
- * request lifecycle). Tool registration is cheap (Map insertions) so this
16
- * is not a meaningful overhead in practice.
17
- */
18
- export declare function createThingdMcpServer(db: ThingD, options?: ThingdMcpServerOptions): McpServer;
19
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC;IACtC,SAAS,CAAC,EAAE,yBAAyB,CAAC;CACvC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,SAAS,CAwDjG"}
@@ -1,51 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { SDK_VERSION } from "../version.js";
3
- import { registerThingdTools } from "./tools.js";
4
- /**
5
- * Create a new McpServer with all thingd tools registered.
6
- *
7
- * Note: a new instance must be created per HTTP request because
8
- * @modelcontextprotocol/sdk's underlying Server.connect() throws if called
9
- * on an already-connected instance (stateless HTTP mode: one transport per
10
- * request lifecycle). Tool registration is cheap (Map insertions) so this
11
- * is not a meaningful overhead in practice.
12
- */
13
- export function createThingdMcpServer(db, options = {}) {
14
- const server = new McpServer({
15
- name: "thingd",
16
- version: SDK_VERSION,
17
- }, {
18
- instructions: "Use thingd tools to search, read, write, and queue work in an object-shaped local memory store. Prefer searching before writing duplicate memory.",
19
- });
20
- registerThingdTools(server, db, {
21
- audit: options.audit,
22
- hardening: options.hardening,
23
- });
24
- // MCP resource: thingd://collections — list known collection names.
25
- // Registered as a static URI so it appears in resources/list.
26
- // Honours the collection allowlist: only allowed collections are surfaced.
27
- server.registerResource("thingd-collections", "thingd://collections", {
28
- title: "Collections",
29
- description: "Lists all known thingd object collections. If a collection allowlist is configured, only allowed collections appear.",
30
- mimeType: "application/json",
31
- }, async (_uri) => {
32
- const allCollections = (await db.listCollections?.()) ?? [];
33
- const allowlist = options.hardening?.collectionAllowlist;
34
- const collections = allowlist
35
- ? allCollections.filter((c) => allowlist.has(c))
36
- : allCollections;
37
- return {
38
- contents: [
39
- {
40
- uri: "thingd://collections",
41
- text: JSON.stringify(collections.map((name) => ({
42
- name,
43
- uri: `thingd://collections/${name}`,
44
- })), null, 2),
45
- mimeType: "application/json",
46
- },
47
- ],
48
- };
49
- });
50
- return server;
51
- }
@@ -1,10 +0,0 @@
1
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { ThingD } from "../thingd.js";
3
- import { type ThingdMcpAuditOptions } from "./audit.js";
4
- import type { ThingdMcpHardeningOptions } from "./config.js";
5
- export type RegisterThingdToolsOptions = {
6
- audit?: ThingdMcpAuditOptions | false;
7
- hardening?: ThingdMcpHardeningOptions;
8
- };
9
- export declare function registerThingdTools(server: McpServer, db: ThingD, options?: RegisterThingdToolsOptions): void;
10
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAW7D,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC;IACtC,SAAS,CAAC,EAAE,yBAAyB,CAAC;CACvC,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,0BAA+B,GACvC,IAAI,CA2xCN"}