@dxos/introspect-mcp 0.8.4-main.abd8ff62ef → 0.8.4-main.bc2380dfbc

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.
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -179,7 +179,12 @@ The package.json `exports` field has a `source` condition pointing at `src/index
179
179
 
180
180
  ## Cache
181
181
 
182
- The indexer stores extracted symbols at `<repo-root>/node_modules/.cache/dxos-introspect/cache.json` (~13 MB for 250 packages). Following the babel/swc/eslint convention so it's auto-gitignored and gets nuked by `pnpm clean`. Saves are atomic (write-temp-then-rename), so concurrent introspector processes can't corrupt each other.
182
+ The indexer writes two files under `<repo-root>/node_modules/.cache/dxos-introspect/`:
183
+
184
+ - `core.json` — symbol cache (~13 MB for 250 packages), reused across runs and invalidated per-package by git tree SHA.
185
+ - `plugins.json` — plugin metadata sidecar (~200 KB), regenerated every run since plugin extraction is cheap.
186
+
187
+ Following the babel/swc/eslint convention so the directory is auto-gitignored and gets nuked by `pnpm clean`. Saves are atomic (write-temp-then-rename), so concurrent introspector processes can't corrupt each other.
183
188
 
184
189
  ### Invalidation
185
190
 
@@ -98,7 +98,9 @@ var shapeListPlugins = (all, opts = {}) => shapeList(all, opts, {
98
98
  name: p.name,
99
99
  description: p.description,
100
100
  icon: p.icon,
101
- iconHue: p.iconHue
101
+ iconHue: p.iconHue,
102
+ tags: p.tags,
103
+ dependsOn: p.dependsOn
102
104
  }),
103
105
  compact: (p) => ({
104
106
  id: p.id,
@@ -114,6 +116,8 @@ var shapePluginDetail = (detail) => ({
114
116
  description: detail.description,
115
117
  icon: detail.icon,
116
118
  iconHue: detail.iconHue,
119
+ tags: detail.tags,
120
+ dependsOn: detail.dependsOn,
117
121
  metaLocation: detail.metaLocation,
118
122
  surfaces: detail.surfaces.map((s) => ({
119
123
  id: s.id,
@@ -182,6 +186,29 @@ var shapeListSchemas = (all, opts = {}) => shapeList(all, opts, {
182
186
  }),
183
187
  truncationHint: "raise `limit` (max 200) or filter by plugin `id`."
184
188
  });
189
+ var shapeListIdioms = (all, opts = {}) => shapeList(all, opts, {
190
+ full: (idiom) => ({
191
+ slug: idiom.slug,
192
+ summary: idiom.summary,
193
+ applies: idiom.applies,
194
+ insteadOf: idiom.insteadOf,
195
+ uses: idiom.uses,
196
+ related: idiom.related,
197
+ host: {
198
+ file: idiom.host.file,
199
+ line: idiom.host.line,
200
+ symbol: idiom.host.symbol,
201
+ kind: idiom.host.kind
202
+ }
203
+ }),
204
+ compact: (idiom) => ({
205
+ slug: idiom.slug,
206
+ kind: idiom.host.kind,
207
+ file: idiom.host.file,
208
+ symbol: idiom.host.symbol
209
+ }),
210
+ truncationHint: "raise `limit` (max 200), refine with `slug`, or filter by `hostKind`."
211
+ });
185
212
 
186
213
  // src/tools/tools.ts
187
214
  var pickListOptions = (args) => ({
@@ -342,6 +369,23 @@ var createToolDefinitions = (introspector, log) => ({
342
369
  });
343
370
  return shaped;
344
371
  }
372
+ },
373
+ list_idioms: {
374
+ ...TOOL_METADATA.list_idioms,
375
+ handler: (args) => {
376
+ const result = introspector.listIdioms({
377
+ slug: args.slug,
378
+ hostKind: args.hostKind
379
+ });
380
+ const shaped = shapeListIdioms(result, pickListOptions(args));
381
+ log({
382
+ tool: "list_idioms",
383
+ args,
384
+ count: result.length,
385
+ truncated: shaped.truncated
386
+ });
387
+ return shaped;
388
+ }
345
389
  }
346
390
  });
347
391
 
@@ -397,4 +441,4 @@ export {
397
441
  registerLogger,
398
442
  fileLogger
399
443
  };
400
- //# sourceMappingURL=chunk-63HTIHM3.mjs.map
444
+ //# sourceMappingURL=chunk-RWYFJ2XT.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/tools/tools.ts", "../../../src/tools/shaping.ts", "../../../src/tools/logger.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\n// Tool definitions — the metadata + handler body for every MCP tool the\n// introspect-mcp server exposes.\n//\n// Centralizing this map gives us:\n//\n// - One place to read when wondering \"what tools does this server expose?\"\n// - A simple shape for `server.ts` to iterate when registering tools, so the\n// server's only job is wiring (transport, error handling, readiness gate).\n// - A natural surface to extend without touching server-construction logic\n// — adding a tool is a single new entry in this map.\n//\n// Input schemas are authored in Effect Schema (see `@dxos/introspect-tools`)\n// so that downstream consumers like `react-ui-form` can render forms from\n// the same definitions. The MCP SDK requires zod, so the server converts at\n// registration time via `inputSchemaToZod` from `@dxos/introspect-tools`.\n//\n// Each handler returns a `ToolResult` (data + optional note + optional\n// truncated marker); the server wraps that in the MCP `content` envelope.\n// Handlers DO NOT call `await introspector.ready` themselves — the server\n// applies that gate uniformly via `withReady`, so a future tool can't\n// accidentally skip it.\n\nimport type * as Schema from 'effect/Schema';\n\nimport type { Introspector } from '@dxos/introspect';\nimport {\n TOOL_METADATA,\n type FindSymbolArgs,\n type GetPackageArgs,\n type GetSymbolArgs,\n type ListCapabilitiesArgs,\n type ListIdiomsArgs,\n type ListOperationsArgs,\n type ListOptions,\n type ListPackagesArgs,\n type ListPluginsArgs,\n type ListSchemasArgs,\n type ListSurfacesArgs,\n type ListSymbolsArgs,\n} from '@dxos/introspect-tools';\n\nimport type { ToolLogger } from './logger';\nimport {\n shapeFindSymbol,\n shapeGetPackage,\n shapeGetSymbol,\n shapeListCapabilities,\n shapeListIdioms,\n shapeListOperations,\n shapeListPackages,\n shapeListPlugins,\n shapeListSchemas,\n shapeListSurfaces,\n type ToolResult,\n} from './shaping';\n\n/** Pull the list-options bag out of an args object before forwarding to a shaper. */\nconst pickListOptions = (args: { limit?: number; compact?: boolean }): ListOptions => ({\n limit: args.limit,\n compact: args.compact,\n});\n\n/**\n * A single MCP tool — metadata + handler. The `inputSchema` field is the\n * Effect `Schema.Struct` that defines the input shape; the server converts\n * it to zod at registration via `effectFieldsToZod`. Authoring in Effect\n * Schema gives `react-ui-form` and other downstream consumers a single\n * source of truth.\n */\nexport type ToolDefinition<TArgs = Record<string, unknown>> = {\n /** Human-readable title surfaced by Inspector / Composer. */\n title: string;\n\n /**\n * LLM-targeted description. Models read this to decide WHEN to call the\n * tool — write it for trigger accuracy, not for human reading. State both\n * what the tool does and the situations it's the right answer for.\n */\n description: string;\n\n /**\n * Effect Schema struct describing the tool's input. The server converts\n * to zod for the MCP SDK; downstream consumers (react-ui-form, etc.) can\n * use this directly.\n */\n inputSchema: Schema.Struct<any>;\n\n /** Tool body. Must NOT await `introspector.ready` — the server gates that uniformly. */\n handler: (args: TArgs) => ToolResult | Promise<ToolResult>;\n};\n\n/**\n * Build the tool map for a given introspector. Returning a map (rather than a\n * static const) lets the handlers close over the introspector instance and\n * the per-process logger. Title / description / inputSchema all come from the\n * shared `TOOL_METADATA` map in `@dxos/introspect-tools` so the contract is\n * authored once and consumed by both server (here) and browser callers.\n */\nexport const createToolDefinitions = (\n introspector: Introspector,\n log: ToolLogger,\n): Record<string, ToolDefinition<any>> => ({\n list_packages: {\n ...TOOL_METADATA.list_packages,\n handler: (args: ListPackagesArgs) => {\n const result = introspector.listPackages({\n name: args.name,\n pathPrefix: args.pathPrefix,\n privateOnly: args.privateOnly,\n });\n const shaped = shapeListPackages(result, pickListOptions(args));\n log({ tool: 'list_packages', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListPackagesArgs>,\n\n get_package: {\n ...TOOL_METADATA.get_package,\n handler: (args: GetPackageArgs) => {\n const detail = introspector.getPackage(args.name);\n log({ tool: 'get_package', args, found: detail !== null });\n if (!detail) {\n return { data: null, note: `No package named ${args.name}` };\n }\n return shapeGetPackage(detail);\n },\n } satisfies ToolDefinition<GetPackageArgs>,\n\n list_symbols: {\n ...TOOL_METADATA.list_symbols,\n handler: (args: ListSymbolsArgs) => {\n const matches = introspector.listSymbols(args.package, args.kind);\n const shaped = shapeFindSymbol(matches, pickListOptions(args));\n log({ tool: 'list_symbols', args, count: matches.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListSymbolsArgs>,\n\n find_symbol: {\n ...TOOL_METADATA.find_symbol,\n handler: (args: FindSymbolArgs) => {\n const matches = introspector.findSymbol(args.query, args.kind);\n const shaped = shapeFindSymbol(matches, pickListOptions(args));\n log({ tool: 'find_symbol', args, count: matches.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<FindSymbolArgs>,\n\n get_symbol: {\n ...TOOL_METADATA.get_symbol,\n handler: (args: GetSymbolArgs) => {\n const detail = introspector.getSymbol(args.ref, args.include as Array<'source' | 'jsdoc'> | undefined);\n log({ tool: 'get_symbol', args, found: detail !== null });\n if (!detail) {\n return { data: null, note: `No symbol with ref ${args.ref}` };\n }\n return shapeGetSymbol(detail);\n },\n } satisfies ToolDefinition<GetSymbolArgs>,\n\n list_plugins: {\n ...TOOL_METADATA.list_plugins,\n handler: (args: ListPluginsArgs) => {\n const result = introspector.listPlugins(args.id !== undefined ? { id: args.id } : undefined);\n const shaped = shapeListPlugins(result, pickListOptions(args));\n log({ tool: 'list_plugins', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListPluginsArgs>,\n\n list_surfaces: {\n ...TOOL_METADATA.list_surfaces,\n handler: (args: ListSurfacesArgs) => {\n const result = introspector.listSurfaces(args.id);\n const shaped = shapeListSurfaces(result, pickListOptions(args));\n log({ tool: 'list_surfaces', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListSurfacesArgs>,\n\n list_capabilities: {\n ...TOOL_METADATA.list_capabilities,\n handler: (args: ListCapabilitiesArgs) => {\n const result = introspector.listCapabilities(args.id);\n const shaped = shapeListCapabilities(result, pickListOptions(args));\n log({ tool: 'list_capabilities', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListCapabilitiesArgs>,\n\n list_operations: {\n ...TOOL_METADATA.list_operations,\n handler: (args: ListOperationsArgs) => {\n const result = introspector.listOperations(args.id);\n const shaped = shapeListOperations(result, pickListOptions(args));\n log({ tool: 'list_operations', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListOperationsArgs>,\n\n list_schemas: {\n ...TOOL_METADATA.list_schemas,\n handler: (args: ListSchemasArgs) => {\n const result = introspector.listSchemas(args.id);\n const shaped = shapeListSchemas(result, pickListOptions(args));\n log({ tool: 'list_schemas', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListSchemasArgs>,\n\n list_idioms: {\n ...TOOL_METADATA.list_idioms,\n handler: (args: ListIdiomsArgs) => {\n const result = introspector.listIdioms({ slug: args.slug, hostKind: args.hostKind });\n const shaped = shapeListIdioms(result, pickListOptions(args));\n log({ tool: 'list_idioms', args, count: result.length, truncated: shaped.truncated });\n return shaped;\n },\n } satisfies ToolDefinition<ListIdiomsArgs>,\n});\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// Response shaping for token budgets.\n//\n// Tool responses target a sane default size for the LLM context (~30 list\n// items, single-record fetches kept compact via `include` opt-ins). Callers\n// that legitimately need a longer list pass `limit`; callers in \"discovery\n// mode\" (just want to see what exists) pass `compact: true` for a refs/ids-\n// only projection at roughly 1/4 the wire size.\n\nimport type {\n Capability,\n Idiom,\n Operation,\n Package,\n PackageDetail,\n Plugin,\n PluginDetail,\n Schema,\n Surface,\n SymbolDetail,\n SymbolMatch,\n} from '@dxos/introspect';\nimport { DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, type ListOptions } from '@dxos/introspect-tools';\n\nconst SOURCE_PREVIEW = 1200;\nconst JSDOC_PREVIEW = 600;\n\nexport type ToolResult = {\n data: unknown;\n note?: string;\n truncated?: string;\n};\n\ntype ShapeListConfig<T> = {\n /** Full projection — what an LLM gets when `compact` is false/omitted. */\n full: (item: T) => Record<string, unknown>;\n /** Compact projection — ids / typenames / names only. */\n compact: (item: T) => Record<string, unknown>;\n /** Suffix for the `truncated` note: \"<N> more results — <hint>\". */\n truncationHint: string;\n};\n\nconst shapeList = <T>(all: readonly T[], opts: ListOptions, config: ShapeListConfig<T>): ToolResult => {\n const requested = opts.limit ?? DEFAULT_LIST_LIMIT;\n const limit = Math.min(Math.max(0, Math.floor(requested)), MAX_LIST_LIMIT);\n const project = opts.compact ? config.compact : config.full;\n const data = all.slice(0, limit).map(project);\n if (all.length > limit) {\n return {\n data,\n truncated: `${all.length - limit} more results — ${config.truncationHint}`,\n };\n }\n return { data };\n};\n\n//\n// Packages\n//\n\nexport const shapeListPackages = (all: Package[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (p) => ({\n name: p.name,\n version: p.version,\n private: p.private,\n path: p.path,\n description: p.description,\n }),\n compact: (p) => ({ name: p.name, path: p.path }),\n truncationHint: 'raise `limit` (max 200), refine with `name`/`pathPrefix`, or call get_package directly.',\n });\n\nexport const shapeGetPackage = (detail: PackageDetail): ToolResult => ({\n data: {\n name: detail.name,\n version: detail.version,\n private: detail.private,\n path: detail.path,\n description: detail.description,\n workspaceDependencies: detail.workspaceDependencies,\n externalDependencies: detail.externalDependencies,\n entryPoints: detail.entryPoints,\n // Surfaced so callers can decide whether to call find_symbol against this package.\n exportCount: detail.exportCount,\n },\n});\n\n//\n// Symbols\n//\n\nexport const shapeFindSymbol = (matches: SymbolMatch[], opts: ListOptions = {}): ToolResult =>\n shapeList(matches, opts, {\n full: (m) => ({ ref: m.ref, name: m.name, package: m.package, kind: m.kind, summary: m.summary }),\n compact: (m) => ({ ref: m.ref, name: m.name }),\n truncationHint: 'raise `limit` (max 200), refine the query, or filter by `kind`.',\n });\n\nexport const shapeGetSymbol = (detail: SymbolDetail): ToolResult => {\n const result: Record<string, unknown> = {\n ref: detail.ref,\n package: detail.package,\n name: detail.name,\n kind: detail.kind,\n signature: detail.signature,\n summary: detail.summary,\n location: detail.location,\n };\n if (detail.jsdoc) {\n result.jsdoc = truncate(detail.jsdoc, JSDOC_PREVIEW);\n }\n if (detail.source !== undefined) {\n result.source = truncate(detail.source, SOURCE_PREVIEW);\n }\n return { data: result };\n};\n\nconst truncate = (s: string, limit: number): string => {\n if (s.length <= limit) {\n return s;\n }\n return `${s.slice(0, limit)}\\n... (truncated, ${s.length - limit} more chars)`;\n};\n\n//\n// Plugin / surface / capability / operation / schema (main's flatter types)\n//\n\nexport const shapeListPlugins = (all: Plugin[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (p) => ({\n id: p.id,\n package: p.package,\n name: p.name,\n description: p.description,\n icon: p.icon,\n iconHue: p.iconHue,\n tags: p.tags,\n dependsOn: p.dependsOn,\n }),\n compact: (p) => ({ id: p.id, name: p.name }),\n truncationHint: 'raise `limit` (max 200) or filter with `id` substring.',\n });\n\n/**\n * `PluginDetail` is the same shape as `Plugin` plus arrays of contributions.\n * Returned by what would be `get_plugin` if the introspector exposed it; we\n * synthesize this on the MCP side by combining `listPlugins` + the per-id\n * `listSurfaces` / `listCapabilities` / `listOperations` / `listSchemas` calls.\n */\nexport const shapePluginDetail = (detail: PluginDetail): ToolResult => ({\n data: {\n id: detail.id,\n package: detail.package,\n name: detail.name,\n description: detail.description,\n icon: detail.icon,\n iconHue: detail.iconHue,\n tags: detail.tags,\n dependsOn: detail.dependsOn,\n metaLocation: detail.metaLocation,\n surfaces: detail.surfaces.map((s) => ({ id: s.id, role: s.role })),\n capabilities: detail.capabilities.map((c) => ({ type: c.type })),\n operations: detail.operations.map((o) => ({ type: o.type })),\n schemas: detail.schemas.map((s) => ({ name: s.name, typename: s.typename })),\n },\n});\n\nexport const shapeListSurfaces = (all: Surface[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (s) => ({ pluginId: s.pluginId, id: s.id, role: s.role, location: s.location }),\n compact: (s) => ({ pluginId: s.pluginId, id: s.id }),\n truncationHint: 'raise `limit` (max 200) or filter by plugin `id`.',\n });\n\nexport const shapeListCapabilities = (all: Capability[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (c) => ({ pluginId: c.pluginId, type: c.type, location: c.location }),\n compact: (c) => ({ pluginId: c.pluginId, type: c.type }),\n truncationHint: 'raise `limit` (max 200) or filter by plugin `id`.',\n });\n\nexport const shapeListOperations = (all: Operation[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (o) => ({ pluginId: o.pluginId, type: o.type, location: o.location }),\n compact: (o) => ({ pluginId: o.pluginId, type: o.type }),\n truncationHint: 'raise `limit` (max 200) or filter by plugin `id`.',\n });\n\nexport const shapeListSchemas = (all: Schema[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (s) => ({ pluginId: s.pluginId, name: s.name, typename: s.typename, location: s.location }),\n compact: (s) => ({ pluginId: s.pluginId, name: s.name, typename: s.typename }),\n truncationHint: 'raise `limit` (max 200) or filter by plugin `id`.',\n });\n\n//\n// Idioms\n//\n\nexport const shapeListIdioms = (all: Idiom[], opts: ListOptions = {}): ToolResult =>\n shapeList(all, opts, {\n full: (idiom) => ({\n slug: idiom.slug,\n summary: idiom.summary,\n applies: idiom.applies,\n insteadOf: idiom.insteadOf,\n uses: idiom.uses,\n related: idiom.related,\n host: {\n file: idiom.host.file,\n line: idiom.host.line,\n symbol: idiom.host.symbol,\n kind: idiom.host.kind,\n },\n }),\n compact: (idiom) => ({\n slug: idiom.slug,\n kind: idiom.host.kind,\n file: idiom.host.file,\n symbol: idiom.host.symbol,\n }),\n truncationHint: 'raise `limit` (max 200), refine with `slug`, or filter by `hostKind`.',\n });\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// Tool-call logging — drives future tool prioritization.\n//\n// Every tool call is logged; failed structured queries that fall through to\n// search_code (when added in a later phase) get logged separately. This is\n// intentionally minimal — appending JSONL is enough for the analysis we want\n// to do later, and keeps the runtime dependency surface small.\n\nimport { appendFile, mkdir } from 'node:fs/promises';\nimport { dirname } from 'node:path';\n\nexport type ToolLogEntry = {\n tool: string;\n args?: unknown;\n count?: number;\n found?: boolean;\n truncated?: string;\n};\n\nexport type ToolLogger = (entry: ToolLogEntry) => void;\n\nexport const noopLogger: ToolLogger = () => {};\n\n/**\n * Wrap a logger so failures inside it never throw into the caller. Returns the\n * wrapped logger; if `inner` is undefined, returns a no-op. Timestamp injection\n * is the responsibility of concrete sinks (see `fileLogger`).\n */\nexport const registerLogger = (inner?: ToolLogger): ToolLogger => {\n if (!inner) {\n return noopLogger;\n }\n return (entry) => {\n try {\n inner(entry);\n } catch {\n // Logger failures must not break tool calls.\n }\n };\n};\n\n/**\n * Append-only JSONL logger. Creates the parent directory on first write.\n */\nexport const fileLogger = (path: string): ToolLogger => {\n let ensured = false;\n return (entry) => {\n const line = `${JSON.stringify({ ts: new Date().toISOString(), ...entry })}\\n`;\n void (async () => {\n if (!ensured) {\n await mkdir(dirname(path), { recursive: true });\n ensured = true;\n }\n await appendFile(path, line, 'utf8');\n })().catch(() => undefined);\n };\n};\n"],
5
+ "mappings": ";;;AA6BA,SACEA,qBAaK;;;AClBP,SAASC,oBAAoBC,sBAAwC;AAErE,IAAMC,iBAAiB;AACvB,IAAMC,gBAAgB;AAiBtB,IAAMC,YAAY,CAAIC,KAAmBC,MAAmBC,WAAAA;AAC1D,QAAMC,YAAYF,KAAKG,SAAST;AAChC,QAAMS,QAAQC,KAAKC,IAAID,KAAKE,IAAI,GAAGF,KAAKG,MAAML,SAAAA,CAAAA,GAAaP,cAAAA;AAC3D,QAAMa,UAAUR,KAAKS,UAAUR,OAAOQ,UAAUR,OAAOS;AACvD,QAAMC,OAAOZ,IAAIa,MAAM,GAAGT,KAAA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,CAACG,SAAS;AACZ,cAAMR,MAAMC,QAAQM,IAAAA,GAAO;UAAEQ,WAAW;QAAK,CAAA;AAC7CP,kBAAU;MACZ;AACA,YAAMT,WAAWQ,MAAME,MAAM,MAAA;IAC/B,GAAA,EAAKO,MAAM,MAAMC,MAAAA;EACnB;AACF;",
6
+ "names": ["TOOL_METADATA", "DEFAULT_LIST_LIMIT", "MAX_LIST_LIMIT", "SOURCE_PREVIEW", "JSDOC_PREVIEW", "shapeList", "all", "opts", "config", "requested", "limit", "Math", "min", "max", "floor", "project", "compact", "full", "data", "slice", "map", "length", "truncated", "truncationHint", "shapeListPackages", "p", "name", "version", "private", "path", "description", "shapeGetPackage", "detail", "workspaceDependencies", "externalDependencies", "entryPoints", "exportCount", "shapeFindSymbol", "matches", "m", "ref", "package", "kind", "summary", "shapeGetSymbol", "result", "signature", "location", "jsdoc", "truncate", "source", "undefined", "s", "shapeListPlugins", "id", "icon", "iconHue", "tags", "dependsOn", "shapePluginDetail", "metaLocation", "surfaces", "role", "capabilities", "c", "type", "operations", "o", "schemas", "typename", "shapeListSurfaces", "pluginId", "shapeListCapabilities", "shapeListOperations", "shapeListSchemas", "shapeListIdioms", "idiom", "slug", "applies", "insteadOf", "uses", "related", "host", "file", "line", "symbol", "pickListOptions", "args", "limit", "compact", "createToolDefinitions", "introspector", "log", "list_packages", "TOOL_METADATA", "handler", "result", "listPackages", "name", "pathPrefix", "privateOnly", "shaped", "shapeListPackages", "tool", "count", "length", "truncated", "get_package", "detail", "getPackage", "found", "data", "note", "shapeGetPackage", "list_symbols", "matches", "listSymbols", "package", "kind", "shapeFindSymbol", "find_symbol", "findSymbol", "query", "get_symbol", "getSymbol", "ref", "include", "shapeGetSymbol", "list_plugins", "listPlugins", "id", "undefined", "shapeListPlugins", "list_surfaces", "listSurfaces", "shapeListSurfaces", "list_capabilities", "listCapabilities", "shapeListCapabilities", "list_operations", "listOperations", "shapeListOperations", "list_schemas", "listSchemas", "shapeListSchemas", "list_idioms", "listIdioms", "slug", "hostKind", "shapeListIdioms", "appendFile", "mkdir", "dirname", "noopLogger", "registerLogger", "inner", "entry", "fileLogger", "path", "ensured", "line", "JSON", "stringify", "ts", "Date", "toISOString", "recursive", "catch", "undefined"]
7
+ }
@@ -4,7 +4,7 @@ import {
4
4
  fileLogger,
5
5
  noopLogger,
6
6
  registerLogger
7
- } from "./chunk-63HTIHM3.mjs";
7
+ } from "./chunk-RWYFJ2XT.mjs";
8
8
 
9
9
  // src/server/server.ts
10
10
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/server/server.ts", "../../../src/server/main.ts"],
4
- "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport type { Introspector } from '@dxos/introspect';\nimport { inputSchemaToZod } from '@dxos/introspect-tools';\n\nimport { createToolDefinitions, registerLogger, type ToolLogger, type ToolResult } from '../tools';\n\nexport type ServerOptions = {\n introspector: Introspector;\n /** Server name advertised over MCP. */\n name?: string;\n /** Server version advertised over MCP. */\n version?: string;\n /** Optional logger; defaults to a no-op. */\n logger?: ToolLogger;\n};\n\ntype McpToolResult = { content: Array<{ type: 'text'; text: string }> };\n\nexport const createServer = (options: ServerOptions): McpServer => {\n const { introspector } = options;\n const log = registerLogger(options.logger);\n\n const server = new McpServer({\n name: options.name ?? '@dxos/introspect-mcp',\n version: options.version ?? '0.0.0',\n });\n\n // Every tool handler is wrapped with `withReady` so it blocks on indexing\n // before running — but ONLY when the handler runs. `initialize` and\n // `tools/list` are answered by the SDK from the static tool registry below,\n // so MCP clients (Inspector, Claude Code, Composer) connect immediately\n // even on a cold cache. Cold-start cost is paid once, on the first\n // `tools/call`. Centralizing this in a wrapper means a future tool can't\n // accidentally skip the readiness gate by forgetting the await.\n const withReady =\n <TArgs>(handler: (args: TArgs) => ToolResult | Promise<ToolResult>) =>\n async (args: TArgs): Promise<McpToolResult> => {\n await introspector.ready;\n const shaped = await handler(args);\n return toToolResult(shaped);\n };\n\n // Tool metadata + handlers live in `tools.ts`. This server is just the\n // wiring: register each tool from the map, converting its Effect Schema\n // input to zod (the MCP SDK's required form), gating handlers behind\n // `withReady`, and wrapping their `ToolResult` in the MCP content envelope.\n const definitions = createToolDefinitions(introspector, log);\n for (const [name, def] of Object.entries(definitions)) {\n server.registerTool(\n name,\n {\n title: def.title,\n description: def.description,\n inputSchema: inputSchemaToZod(def.inputSchema),\n },\n withReady(def.handler),\n );\n }\n\n return server;\n};\n\nconst toToolResult = (shaped: ToolResult): McpToolResult => {\n const payload: Record<string, unknown> = { data: shaped.data };\n if (shaped.note) {\n payload.note = shaped.note;\n }\n if (shaped.truncated) {\n payload.truncated = shaped.truncated;\n }\n return {\n content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],\n };\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// Entry point for the dx-introspect-mcp CLI. Boots an introspector against the\n// monorepo root inferred from cwd (or --root) and exposes it over either\n// stdio (default) or HTTP (when --http <port> is passed).\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { randomUUID } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { createServer as createHttpServer, type IncomingMessage, type ServerResponse } from 'node:http';\nimport { dirname, isAbsolute, resolve } from 'node:path';\n\nimport { createIntrospector } from '@dxos/introspect';\n\nimport { fileLogger } from '../tools';\nimport { createServer } from './server';\n\ntype Args = {\n root: string;\n logPath?: string;\n /** If set, run as an HTTP server on this port instead of stdio. */\n httpPort?: number;\n /** Bind address for HTTP mode. Defaults to localhost. */\n host: string;\n /** Optional bearer token; when set, requests must send `Authorization: Bearer <token>`. */\n apiKey?: string;\n};\n\nconst parseArgs = (argv: string[]): Args => {\n let root: string | undefined;\n let logPath: string | undefined;\n let httpPort: number | undefined;\n let host = 'localhost';\n let apiKey: string | undefined;\n const valueArgs = new Set(['--root', '--log-path', '--http', '--host', '--api-key']);\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (valueArgs.has(arg)) {\n const value = argv[i + 1];\n if (value === undefined || value.startsWith('-')) {\n console.error(`Error: ${arg} requires a value.`);\n printUsage();\n process.exit(1);\n }\n i++;\n switch (arg) {\n case '--root':\n root = value;\n break;\n case '--log-path':\n logPath = value;\n break;\n case '--http':\n httpPort = Number.parseInt(value, 10);\n if (!Number.isFinite(httpPort) || httpPort <= 0) {\n console.error(`Error: --http expects a port number, got \"${value}\".`);\n process.exit(1);\n }\n break;\n case '--host':\n host = value;\n break;\n case '--api-key':\n apiKey = value;\n break;\n }\n } else if (arg === '--help' || arg === '-h') {\n printUsage();\n process.exit(0);\n } else {\n console.error(`Unknown argument: ${arg}`);\n printUsage();\n process.exit(1);\n }\n }\n const resolvedRoot = root ? resolveRoot(root) : findrootPath(process.cwd());\n if (!resolvedRoot) {\n console.error('Could not find monorepo root (looking for pnpm-workspace.yaml). Pass --root explicitly.');\n process.exit(1);\n }\n return { root: resolvedRoot, logPath, httpPort, host, apiKey };\n};\n\nconst resolveRoot = (root: string): string => (isAbsolute(root) ? root : resolve(process.cwd(), root));\n\nconst findrootPath = (start: string): string | null => {\n let cursor = start;\n while (true) {\n if (existsSync(`${cursor}/pnpm-workspace.yaml`)) {\n return cursor;\n }\n const parent = dirname(cursor);\n if (parent === cursor) {\n return null;\n }\n cursor = parent;\n }\n};\n\nconst printUsage = (): void => {\n console.error(\n [\n 'Usage: dx-introspect-mcp [options]',\n '',\n 'Options:',\n ' --root <path> Monorepo root (default: discovered from cwd via pnpm-workspace.yaml)',\n ' --log-path <path> Append-only JSONL log of tool calls (default: stderr-silent)',\n ' --http <port> Run as HTTP server on the given port (default: stdio)',\n ' --host <addr> HTTP bind address (default: localhost)',\n ' --api-key <token> Require `Authorization: Bearer <token>` on HTTP requests',\n ' -h, --help Show this help',\n ].join('\\n'),\n );\n};\n\nexport const main = async (argv: string[] = process.argv.slice(2)): Promise<void> => {\n const args = parseArgs(argv);\n\n // Kick off indexing in the background. We deliberately DON'T await\n // `introspector.ready` here — on a cold cache that's ~80s of ts-morph\n // parsing, longer than most MCP clients (Inspector, Claude Code, Composer)\n // will wait for `initialize` / `tools/list`. Each tool handler awaits\n // `introspector.ready` itself before doing work, so:\n //\n // - `initialize` responds instantly (MCP handshake — no introspector calls)\n // - `tools/list` responds instantly (registered statically in createServer)\n // - `tools/call` waits for indexing, then runs\n //\n // Result: clients connect immediately and the first real query pays the\n // one-time cold-start cost. Subsequent calls hit the cache and are fast.\n const introspector = createIntrospector({ rootPath: args.root });\n // Surface fatal indexing errors to stderr and exit. A live but\n // permanently-unusable process is worse than a clean failure: every tool\n // call would block forever on `await introspector.ready` once the rejected\n // promise is awaited, leaving the MCP client hung with no signal.\n introspector.ready.catch((err) => {\n console.error('[introspect-mcp] indexer failed:', err);\n process.exit(1);\n });\n\n const server = createServer({\n introspector,\n name: '@dxos/introspect-mcp',\n version: '0.0.1',\n logger: args.logPath ? fileLogger(args.logPath) : undefined,\n });\n\n if (args.httpPort !== undefined) {\n // HTTP mode needs a fresh McpServer per session (the SDK rejects multiple\n // transports on the same Server). Pass a factory so runHttp can build one\n // per connection while sharing the introspector.\n await runHttp(\n () =>\n createServer({\n introspector,\n name: '@dxos/introspect-mcp',\n version: '0.0.1',\n logger: args.logPath ? fileLogger(args.logPath) : undefined,\n }),\n args,\n );\n } else {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n // Stay alive until stdin closes — the SDK handles that signal internally.\n }\n};\n\nconst runHttp = async (serverFactory: () => Awaited<ReturnType<typeof createServer>>, args: Args): Promise<void> => {\n // Stateful mode — we keep one transport per client session. The session ID\n // is returned in the initialize response and the client echoes it on every\n // subsequent request. Required because the MCP client expects to send\n // `notifications/initialized` (and later requests) under the same session.\n const transports = new Map<string, StreamableHTTPServerTransport>();\n\n const httpServer = createHttpServer((req: IncomingMessage, res: ServerResponse) => {\n // CORS — Composer (and any other browser-based MCP client) sends a\n // cross-origin preflight before the POST. Without these headers, the\n // browser blocks the request and the underlying client surfaces a generic\n // \"UnknownException\" from Effect.tryPromise. We allow any origin because\n // this server is for local dev only; it should bind to localhost.\n res.setHeader('Access-Control-Allow-Origin', req.headers.origin ?? '*');\n res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');\n res.setHeader(\n 'Access-Control-Allow-Headers',\n 'Content-Type, Authorization, Mcp-Session-Id, Last-Event-ID, MCP-Protocol-Version',\n );\n res.setHeader('Access-Control-Expose-Headers', 'Mcp-Session-Id');\n res.setHeader('Access-Control-Max-Age', '86400');\n res.setHeader('Vary', 'Origin');\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n\n // Apply optional bearer-token auth before delegating to the transport.\n if (args.apiKey) {\n const header = req.headers.authorization ?? '';\n const expected = `Bearer ${args.apiKey}`;\n if (header !== expected) {\n res.statusCode = 401;\n res.setHeader('WWW-Authenticate', 'Bearer');\n res.end('Unauthorized');\n return;\n }\n }\n if (req.url === '/health') {\n res.statusCode = 200;\n res.setHeader('content-type', 'text/plain');\n res.end('ok\\n');\n return;\n }\n if (req.url !== '/mcp' && req.url !== '/mcp/') {\n res.statusCode = 404;\n res.end('Not found');\n return;\n }\n\n void (async () => {\n const sessionId = req.headers['mcp-session-id'];\n let transport: StreamableHTTPServerTransport | undefined;\n if (typeof sessionId === 'string' && transports.has(sessionId)) {\n transport = transports.get(sessionId)!;\n } else {\n // No session yet — must be an `initialize` request. Spin up a new\n // McpServer + transport pair (the SDK requires a 1:1 binding) and\n // remember it under the session id Composer/Inspector echoes back.\n const sessionServer = serverFactory();\n transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n onsessioninitialized: (id) => {\n transports.set(id, transport!);\n },\n });\n transport.onclose = () => {\n if (transport!.sessionId) {\n transports.delete(transport!.sessionId);\n }\n // Best-effort cleanup of the per-session server.\n sessionServer.close().catch(() => undefined);\n };\n await sessionServer.connect(transport);\n }\n try {\n await transport.handleRequest(req, res);\n } catch (err) {\n console.error('[introspect-mcp] HTTP transport error:', err);\n if (!res.writableEnded) {\n res.statusCode = 500;\n res.end('Internal Server Error');\n }\n }\n })();\n });\n\n await new Promise<void>((resolveListen, rejectListen) => {\n httpServer.once('error', rejectListen);\n httpServer.listen(args.httpPort, args.host, () => {\n console.error(`[introspect-mcp] HTTP server listening on http://${args.host}:${args.httpPort}/mcp`);\n if (args.apiKey) {\n console.error('[introspect-mcp] auth: Authorization: Bearer <token> required');\n } else {\n console.error('[introspect-mcp] auth: none — bind to localhost only');\n }\n resolveListen();\n });\n });\n\n // Stay alive until SIGINT/SIGTERM.\n await new Promise<void>(() => {});\n};\n"],
5
- "mappings": ";;;;;;;;;AAIA,SAASA,iBAAiB;AAG1B,SAASC,wBAAwB;AAgB1B,IAAMC,eAAe,CAACC,YAAAA;AAC3B,QAAM,EAAEC,aAAY,IAAKD;AACzB,QAAME,MAAMC,eAAeH,QAAQI,MAAM;AAEzC,QAAMC,SAAS,IAAIC,UAAU;IAC3BC,MAAMP,QAAQO,QAAQ;IACtBC,SAASR,QAAQQ,WAAW;EAC9B,CAAA;AASA,QAAMC,YACJ,CAAQC,YACR,OAAOC,SAAAA;AACL,UAAMV,aAAaW;AACnB,UAAMC,SAAS,MAAMH,QAAQC,IAAAA;AAC7B,WAAOG,aAAaD,MAAAA;EACtB;AAMF,QAAME,cAAcC,sBAAsBf,cAAcC,GAAAA;AACxD,aAAW,CAACK,MAAMU,GAAAA,KAAQC,OAAOC,QAAQJ,WAAAA,GAAc;AACrDV,WAAOe,aACLb,MACA;MACEc,OAAOJ,IAAII;MACXC,aAAaL,IAAIK;MACjBC,aAAaC,iBAAiBP,IAAIM,WAAW;IAC/C,GACAd,UAAUQ,IAAIP,OAAO,CAAA;EAEzB;AAEA,SAAOL;AACT;AAEA,IAAMS,eAAe,CAACD,WAAAA;AACpB,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AsE,oBAAAA;IACF,CAAA;EACF,CAAA;AAGA,QAAM,IAAID,QAAc,MAAA;EAAO,CAAA;AACjC;",
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport type { Introspector } from '@dxos/introspect';\nimport { inputSchemaToZod } from '@dxos/introspect-tools';\n\nimport { createToolDefinitions, registerLogger, type ToolLogger, type ToolResult } from '../tools';\n\nexport type ServerOptions = {\n introspector: Introspector;\n /** Server name advertised over MCP. */\n name?: string;\n /** Server version advertised over MCP. */\n version?: string;\n /** Optional logger; defaults to a no-op. */\n logger?: ToolLogger;\n};\n\ntype McpToolResult = { content: Array<{ type: 'text'; text: string }> };\n\nexport const createServer = (options: ServerOptions): McpServer => {\n const { introspector } = options;\n const log = registerLogger(options.logger);\n\n const server = new McpServer({\n name: options.name ?? '@dxos/introspect-mcp',\n version: options.version ?? '0.0.0',\n });\n\n // Every tool handler is wrapped with `withReady` so it blocks on indexing\n // before running — but ONLY when the handler runs. `initialize` and\n // `tools/list` are answered by the SDK from the static tool registry below,\n // so MCP clients (Inspector, Claude Code, Composer) connect immediately\n // even on a cold cache. Cold-start cost is paid once, on the first\n // `tools/call`. Centralizing this in a wrapper means a future tool can't\n // accidentally skip the readiness gate by forgetting the await.\n const withReady =\n <TArgs>(handler: (args: TArgs) => ToolResult | Promise<ToolResult>) =>\n async (args: TArgs): Promise<McpToolResult> => {\n await introspector.ready;\n const shaped = await handler(args);\n return toToolResult(shaped);\n };\n\n // Tool metadata + handlers live in `tools.ts`. This server is just the\n // wiring: register each tool from the map, converting its Effect Schema\n // input to zod (the MCP SDK's required form), gating handlers behind\n // `withReady`, and wrapping their `ToolResult` in the MCP content envelope.\n const definitions = createToolDefinitions(introspector, log);\n for (const [name, def] of Object.entries(definitions)) {\n server.registerTool(\n name,\n {\n title: def.title,\n description: def.description,\n inputSchema: inputSchemaToZod(def.inputSchema),\n },\n withReady(def.handler),\n );\n }\n\n return server;\n};\n\nconst toToolResult = (shaped: ToolResult): McpToolResult => {\n const payload: Record<string, unknown> = { data: shaped.data };\n if (shaped.note) {\n payload.note = shaped.note;\n }\n if (shaped.truncated) {\n payload.truncated = shaped.truncated;\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(payload, null, 2),\n },\n ],\n };\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// Entry point for the dx-introspect-mcp CLI. Boots an introspector against the\n// monorepo root inferred from cwd (or --root) and exposes it over either\n// stdio (default) or HTTP (when --http <port> is passed).\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { randomUUID } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { createServer as createHttpServer, type IncomingMessage, type ServerResponse } from 'node:http';\nimport { dirname, isAbsolute, resolve } from 'node:path';\n\nimport { createIntrospector } from '@dxos/introspect';\n\nimport { fileLogger } from '../tools';\nimport { createServer } from './server';\n\ntype Args = {\n root: string;\n logPath?: string;\n /** If set, run as an HTTP server on this port instead of stdio. */\n httpPort?: number;\n /** Bind address for HTTP mode. Defaults to localhost. */\n host: string;\n /** Optional bearer token; when set, requests must send `Authorization: Bearer <token>`. */\n apiKey?: string;\n};\n\nconst parseArgs = (argv: string[]): Args => {\n let root: string | undefined;\n let logPath: string | undefined;\n let httpPort: number | undefined;\n let host = 'localhost';\n let apiKey: string | undefined;\n const valueArgs = new Set(['--root', '--log-path', '--http', '--host', '--api-key']);\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (valueArgs.has(arg)) {\n const value = argv[i + 1];\n if (value === undefined || value.startsWith('-')) {\n console.error(`Error: ${arg} requires a value.`);\n printUsage();\n process.exit(1);\n }\n i++;\n switch (arg) {\n case '--root':\n root = value;\n break;\n case '--log-path':\n logPath = value;\n break;\n case '--http':\n httpPort = Number.parseInt(value, 10);\n if (!Number.isFinite(httpPort) || httpPort <= 0) {\n console.error(`Error: --http expects a port number, got \"${value}\".`);\n process.exit(1);\n }\n break;\n case '--host':\n host = value;\n break;\n case '--api-key':\n apiKey = value;\n break;\n }\n } else if (arg === '--help' || arg === '-h') {\n printUsage();\n process.exit(0);\n } else {\n console.error(`Unknown argument: ${arg}`);\n printUsage();\n process.exit(1);\n }\n }\n const resolvedRoot = root ? resolveRoot(root) : findrootPath(process.cwd());\n if (!resolvedRoot) {\n console.error('Could not find monorepo root (looking for pnpm-workspace.yaml). Pass --root explicitly.');\n process.exit(1);\n }\n return { root: resolvedRoot, logPath, httpPort, host, apiKey };\n};\n\nconst resolveRoot = (root: string): string => (isAbsolute(root) ? root : resolve(process.cwd(), root));\n\nconst findrootPath = (start: string): string | null => {\n let cursor = start;\n while (true) {\n if (existsSync(`${cursor}/pnpm-workspace.yaml`)) {\n return cursor;\n }\n const parent = dirname(cursor);\n if (parent === cursor) {\n return null;\n }\n cursor = parent;\n }\n};\n\nconst printUsage = (): void => {\n console.error(\n [\n 'Usage: dx-introspect-mcp [options]',\n '',\n 'Options:',\n ' --root <path> Monorepo root (default: discovered from cwd via pnpm-workspace.yaml)',\n ' --log-path <path> Append-only JSONL log of tool calls (default: stderr-silent)',\n ' --http <port> Run as HTTP server on the given port (default: stdio)',\n ' --host <addr> HTTP bind address (default: localhost)',\n ' --api-key <token> Require `Authorization: Bearer <token>` on HTTP requests',\n ' -h, --help Show this help',\n ].join('\\n'),\n );\n};\n\nexport const main = async (argv: string[] = process.argv.slice(2)): Promise<void> => {\n const args = parseArgs(argv);\n\n // Kick off indexing in the background. We deliberately DON'T await\n // `introspector.ready` here — on a cold cache that's ~80s of ts-morph\n // parsing, longer than most MCP clients (Inspector, Claude Code, Composer)\n // will wait for `initialize` / `tools/list`. Each tool handler awaits\n // `introspector.ready` itself before doing work, so:\n //\n // - `initialize` responds instantly (MCP handshake — no introspector calls)\n // - `tools/list` responds instantly (registered statically in createServer)\n // - `tools/call` waits for indexing, then runs\n //\n // Result: clients connect immediately and the first real query pays the\n // one-time cold-start cost. Subsequent calls hit the cache and are fast.\n const introspector = createIntrospector({ rootPath: args.root });\n // Surface fatal indexing errors to stderr and exit. A live but\n // permanently-unusable process is worse than a clean failure: every tool\n // call would block forever on `await introspector.ready` once the rejected\n // promise is awaited, leaving the MCP client hung with no signal.\n introspector.ready.catch((err) => {\n console.error('[introspect-mcp] indexer failed:', err);\n process.exit(1);\n });\n\n const server = createServer({\n introspector,\n name: '@dxos/introspect-mcp',\n version: '0.0.1',\n logger: args.logPath ? fileLogger(args.logPath) : undefined,\n });\n\n if (args.httpPort !== undefined) {\n // HTTP mode needs a fresh McpServer per session (the SDK rejects multiple\n // transports on the same Server). Pass a factory so runHttp can build one\n // per connection while sharing the introspector.\n await runHttp(\n () =>\n createServer({\n introspector,\n name: '@dxos/introspect-mcp',\n version: '0.0.1',\n logger: args.logPath ? fileLogger(args.logPath) : undefined,\n }),\n args,\n );\n } else {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n // Stay alive until stdin closes — the SDK handles that signal internally.\n }\n};\n\nconst runHttp = async (serverFactory: () => Awaited<ReturnType<typeof createServer>>, args: Args): Promise<void> => {\n // Stateful mode — we keep one transport per client session. The session ID\n // is returned in the initialize response and the client echoes it on every\n // subsequent request. Required because the MCP client expects to send\n // `notifications/initialized` (and later requests) under the same session.\n const transports = new Map<string, StreamableHTTPServerTransport>();\n\n const httpServer = createHttpServer((req: IncomingMessage, res: ServerResponse) => {\n // CORS — Composer (and any other browser-based MCP client) sends a\n // cross-origin preflight before the POST. Without these headers, the\n // browser blocks the request and the underlying client surfaces a generic\n // \"UnknownException\" from Effect.tryPromise. We allow any origin because\n // this server is for local dev only; it should bind to localhost.\n res.setHeader('Access-Control-Allow-Origin', req.headers.origin ?? '*');\n res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');\n res.setHeader(\n 'Access-Control-Allow-Headers',\n 'Content-Type, Authorization, Mcp-Session-Id, Last-Event-ID, MCP-Protocol-Version',\n );\n res.setHeader('Access-Control-Expose-Headers', 'Mcp-Session-Id');\n res.setHeader('Access-Control-Max-Age', '86400');\n res.setHeader('Vary', 'Origin');\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n\n // Apply optional bearer-token auth before delegating to the transport.\n if (args.apiKey) {\n const header = req.headers.authorization ?? '';\n const expected = `Bearer ${args.apiKey}`;\n if (header !== expected) {\n res.statusCode = 401;\n res.setHeader('WWW-Authenticate', 'Bearer');\n res.end('Unauthorized');\n return;\n }\n }\n if (req.url === '/health') {\n res.statusCode = 200;\n res.setHeader('content-type', 'text/plain');\n res.end('ok\\n');\n return;\n }\n if (req.url !== '/mcp' && req.url !== '/mcp/') {\n res.statusCode = 404;\n res.end('Not found');\n return;\n }\n\n void (async () => {\n const sessionId = req.headers['mcp-session-id'];\n let transport: StreamableHTTPServerTransport | undefined;\n if (typeof sessionId === 'string' && transports.has(sessionId)) {\n transport = transports.get(sessionId)!;\n } else {\n // No session yet — must be an `initialize` request. Spin up a new\n // McpServer + transport pair (the SDK requires a 1:1 binding) and\n // remember it under the session id Composer/Inspector echoes back.\n const sessionServer = serverFactory();\n transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n onsessioninitialized: (id) => {\n transports.set(id, transport!);\n },\n });\n transport.onclose = () => {\n if (transport!.sessionId) {\n transports.delete(transport!.sessionId);\n }\n // Best-effort cleanup of the per-session server.\n sessionServer.close().catch(() => undefined);\n };\n await sessionServer.connect(transport);\n }\n try {\n await transport.handleRequest(req, res);\n } catch (err) {\n console.error('[introspect-mcp] HTTP transport error:', err);\n if (!res.writableEnded) {\n res.statusCode = 500;\n res.end('Internal Server Error');\n }\n }\n })();\n });\n\n await new Promise<void>((resolveListen, rejectListen) => {\n httpServer.once('error', rejectListen);\n httpServer.listen(args.httpPort, args.host, () => {\n console.error(`[introspect-mcp] HTTP server listening on http://${args.host}:${args.httpPort}/mcp`);\n if (args.apiKey) {\n console.error('[introspect-mcp] auth: Authorization: Bearer <token> required');\n } else {\n console.error('[introspect-mcp] auth: none — bind to localhost only');\n }\n resolveListen();\n });\n });\n\n // Stay alive until SIGINT/SIGTERM.\n await new Promise<void>(() => {});\n};\n"],
5
+ "mappings": ";;;;;;;;;AAIA,SAASA,iBAAiB;AAG1B,SAASC,wBAAwB;AAgB1B,IAAMC,eAAe,CAACC,YAAAA;AAC3B,QAAM,EAAEC,aAAY,IAAKD;AACzB,QAAME,MAAMC,eAAeH,QAAQI,MAAM;AAEzC,QAAMC,SAAS,IAAIC,UAAU;IAC3BC,MAAMP,QAAQO,QAAQ;IACtBC,SAASR,QAAQQ,WAAW;EAC9B,CAAA;AASA,QAAMC,YACJ,CAAQC,YACR,OAAOC,SAAAA;AACL,UAAMV,aAAaW;AACnB,UAAMC,SAAS,MAAMH,QAAQC,IAAAA;AAC7B,WAAOG,aAAaD,MAAAA;EACtB;AAMF,QAAME,cAAcC,sBAAsBf,cAAcC,GAAAA;AACxD,aAAW,CAACK,MAAMU,GAAAA,KAAQC,OAAOC,QAAQJ,WAAAA,GAAc;AACrDV,WAAOe,aACLb,MACA;MACEc,OAAOJ,IAAII;MACXC,aAAaL,IAAIK;MACjBC,aAAaC,iBAAiBP,IAAIM,WAAW;IAC/C,GACAd,UAAUQ,IAAIP,OAAO,CAAA;EAEzB;AAEA,SAAOL;AACT;AAEA,IAAMS,eAAe,CAACD,WAAAA;AACpB,QAAMY,UAAmC;IAAEC,MAAMb,OAAOa;EAAK;AAC7D,MAAIb,OAAOc,MAAM;AACfF,YAAQE,OAAOd,OAAOc;EACxB;AACA,MAAId,OAAOe,WAAW;AACpBH,YAAQG,YAAYf,OAAOe;EAC7B;AAEA,SAAO;IACLC,SAAS;MACP;QACEC,MAAM;QACNC,MAAMC,KAAKC,UAAUR,SAAS,MAAM,CAAA;MACtC;;EAEJ;AACF;;;AC5EA,SAASS,4BAA4B;AACrC,SAASC,qCAAqC;AAC9C,SAASC,kBAAkB;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AAIuB,8BAA8B;UAC5CC,oBAAoB,MAAMC,WAAAA;UAC1BC,sBAAsB,CAACC,OAAAA;AACrBvB,uBAAWwB,IAAID,IAAI3B,SAAAA;UACrB;QACF,CAAA;AACAA,kBAAU6B,UAAU,MAAA;AAClB,cAAI7B,UAAWoB,WAAW;AACxBhB,uBAAW0B,OAAO9B,UAAWoB,SAAS;UACxC;AAEAE,wBAAcS,MAAK,EAAGxC,MAAM,MAAM7B,MAAAA;QACpC;AACA,cAAM4D,cAAcpB,QAAQF,SAAAA;MAC9B;AACA,UAAI;AACF,cAAMA,UAAUgC,cAAcxB,KAAKC,GAAAA;MACrC,SAASjB,KAAK;AACZ5B,gBAAQC,MAAM,0CAA0C2B,GAAAA;AACxD,YAAI,CAACiB,IAAIwB,eAAe;AACtBxB,cAAIK,aAAa;AACjBL,cAAIM,IAAI,uBAAA;QACV;MACF;IACF,GAAA;EACF,CAAA;AAEA,QAAM,IAAImB,QAAc,CAACC,eAAeC,iBAAAA;AACtC9B,eAAW+B,KAAK,SAASD,YAAAA;AACzB9B,eAAWgC,OAAOpD,KAAKlC,UAAUkC,KAAKjC,MAAM,MAAA;AAC1CW,cAAQC,MAAM,oDAAoDqB,KAAKjC,IAAI,IAAIiC,KAAKlC,QAAQ,MAAM;AAClG,UAAIkC,KAAKhC,QAAQ;AACfU,gBAAQC,MAAM,+DAAA;MAChB,OAAO;AACLD,gBAAQC,MAAM,2DAAA;MAChB;AACAsE,oBAAAA;IACF,CAAA;EACF,CAAA;AAGA,QAAM,IAAID,QAAc,MAAA;EAAO,CAAA;AACjC;",
6
6
  "names": ["McpServer", "inputSchemaToZod", "createServer", "options", "introspector", "log", "registerLogger", "logger", "server", "McpServer", "name", "version", "withReady", "handler", "args", "ready", "shaped", "toToolResult", "definitions", "createToolDefinitions", "def", "Object", "entries", "registerTool", "title", "description", "inputSchema", "inputSchemaToZod", "payload", "data", "note", "truncated", "content", "type", "text", "JSON", "stringify", "StdioServerTransport", "StreamableHTTPServerTransport", "randomUUID", "existsSync", "createServer", "createHttpServer", "dirname", "isAbsolute", "resolve", "createIntrospector", "parseArgs", "argv", "root", "logPath", "httpPort", "host", "apiKey", "valueArgs", "Set", "i", "length", "arg", "has", "value", "undefined", "startsWith", "console", "error", "printUsage", "process", "exit", "Number", "parseInt", "isFinite", "resolvedRoot", "resolveRoot", "findrootPath", "cwd", "isAbsolute", "resolve", "start", "cursor", "existsSync", "parent", "dirname", "join", "main", "slice", "args", "introspector", "createIntrospector", "rootPath", "ready", "catch", "err", "server", "createServer", "name", "version", "logger", "fileLogger", "runHttp", "transport", "StdioServerTransport", "connect", "serverFactory", "transports", "Map", "httpServer", "createHttpServer", "req", "res", "setHeader", "headers", "origin", "method", "statusCode", "end", "header", "authorization", "expected", "url", "sessionId", "get", "sessionServer", "StreamableHTTPServerTransport", "sessionIdGenerator", "randomUUID", "onsessioninitialized", "id", "set", "onclose", "delete", "close", "handleRequest", "writableEnded", "Promise", "resolveListen", "rejectListen", "once", "listen"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/tools/shaping.ts":{"bytes":23487,"imports":[{"path":"@dxos/introspect-tools","kind":"import-statement","external":true}],"format":"esm"},"src/tools/tools.ts":{"bytes":24366,"imports":[{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"src/tools/shaping.ts","kind":"import-statement","original":"./shaping"}],"format":"esm"},"src/tools/logger.ts":{"bytes":5297,"imports":[{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/tools/index.ts":{"bytes":3017,"imports":[{"path":"src/tools/tools.ts","kind":"import-statement","original":"./tools"},{"path":"src/tools/shaping.ts","kind":"import-statement","original":"./shaping"},{"path":"src/tools/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"},"src/server/server.ts":{"bytes":8199,"imports":[{"path":"@modelcontextprotocol/sdk/server/mcp.js","kind":"import-statement","external":true},{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"src/tools/index.ts","kind":"import-statement","original":"../tools"}],"format":"esm"},"src/server/main.ts":{"bytes":32633,"imports":[{"path":"@modelcontextprotocol/sdk/server/stdio.js","kind":"import-statement","external":true},{"path":"@modelcontextprotocol/sdk/server/streamableHttp.js","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/introspect","kind":"import-statement","external":true},{"path":"src/tools/index.ts","kind":"import-statement","original":"../tools"},{"path":"src/server/server.ts","kind":"import-statement","original":"./server"}],"format":"esm"},"src/server/index.ts":{"bytes":1169,"imports":[{"path":"src/server/server.ts","kind":"import-statement","original":"./server"},{"path":"src/server/main.ts","kind":"import-statement","original":"./main"}],"format":"esm"},"src/index.ts":{"bytes":1334,"imports":[{"path":"src/server/index.ts","kind":"import-statement","original":"./server"},{"path":"src/tools/index.ts","kind":"import-statement","original":"./tools"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":20184},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-63HTIHM3.mjs","kind":"import-statement"},{"path":"@modelcontextprotocol/sdk/server/mcp.js","kind":"import-statement","external":true},{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"@modelcontextprotocol/sdk/server/stdio.js","kind":"import-statement","external":true},{"path":"@modelcontextprotocol/sdk/server/streamableHttp.js","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/introspect","kind":"import-statement","external":true}],"exports":["createServer","fileLogger","main","noopLogger"],"entryPoint":"src/index.ts","inputs":{"src/server/server.ts":{"bytesInOutput":1190},"src/server/index.ts":{"bytesInOutput":0},"src/server/main.ts":{"bytesInOutput":6736},"src/index.ts":{"bytesInOutput":0}},"bytes":8274},"dist/lib/node-esm/tools/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/tools/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-63HTIHM3.mjs","kind":"import-statement"}],"exports":["createToolDefinitions","fileLogger","noopLogger","registerLogger","shapeFindSymbol","shapeGetPackage","shapeGetSymbol","shapeListCapabilities","shapeListOperations","shapeListPackages","shapeListPlugins","shapeListSchemas","shapeListSurfaces","shapePluginDetail"],"entryPoint":"src/tools/index.ts","inputs":{},"bytes":734},"dist/lib/node-esm/chunk-63HTIHM3.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26030},"dist/lib/node-esm/chunk-63HTIHM3.mjs":{"imports":[{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["createToolDefinitions","fileLogger","noopLogger","registerLogger","shapeFindSymbol","shapeGetPackage","shapeGetSymbol","shapeListCapabilities","shapeListOperations","shapeListPackages","shapeListPlugins","shapeListSchemas","shapeListSurfaces","shapePluginDetail"],"inputs":{"src/tools/tools.ts":{"bytesInOutput":4194},"src/tools/shaping.ts":{"bytesInOutput":4647},"src/tools/index.ts":{"bytesInOutput":0},"src/tools/logger.ts":{"bytesInOutput":702}},"bytes":10064}}}
1
+ {"inputs":{"src/tools/shaping.ts":{"bytes":26891,"imports":[{"path":"@dxos/introspect-tools","kind":"import-statement","external":true}],"format":"esm"},"src/tools/tools.ts":{"bytes":26103,"imports":[{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"src/tools/shaping.ts","kind":"import-statement","original":"./shaping"}],"format":"esm"},"src/tools/logger.ts":{"bytes":5297,"imports":[{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/tools/index.ts":{"bytes":3017,"imports":[{"path":"src/tools/tools.ts","kind":"import-statement","original":"./tools"},{"path":"src/tools/shaping.ts","kind":"import-statement","original":"./shaping"},{"path":"src/tools/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"},"src/server/server.ts":{"bytes":8259,"imports":[{"path":"@modelcontextprotocol/sdk/server/mcp.js","kind":"import-statement","external":true},{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"src/tools/index.ts","kind":"import-statement","original":"../tools"}],"format":"esm"},"src/server/main.ts":{"bytes":32633,"imports":[{"path":"@modelcontextprotocol/sdk/server/stdio.js","kind":"import-statement","external":true},{"path":"@modelcontextprotocol/sdk/server/streamableHttp.js","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/introspect","kind":"import-statement","external":true},{"path":"src/tools/index.ts","kind":"import-statement","original":"../tools"},{"path":"src/server/server.ts","kind":"import-statement","original":"./server"}],"format":"esm"},"src/server/index.ts":{"bytes":1169,"imports":[{"path":"src/server/server.ts","kind":"import-statement","original":"./server"},{"path":"src/server/main.ts","kind":"import-statement","original":"./main"}],"format":"esm"},"src/index.ts":{"bytes":1334,"imports":[{"path":"src/server/index.ts","kind":"import-statement","original":"./server"},{"path":"src/tools/index.ts","kind":"import-statement","original":"./tools"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":20227},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-RWYFJ2XT.mjs","kind":"import-statement"},{"path":"@modelcontextprotocol/sdk/server/mcp.js","kind":"import-statement","external":true},{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"@modelcontextprotocol/sdk/server/stdio.js","kind":"import-statement","external":true},{"path":"@modelcontextprotocol/sdk/server/streamableHttp.js","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:http","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"@dxos/introspect","kind":"import-statement","external":true}],"exports":["createServer","fileLogger","main","noopLogger"],"entryPoint":"src/index.ts","inputs":{"src/server/server.ts":{"bytesInOutput":1190},"src/server/index.ts":{"bytesInOutput":0},"src/server/main.ts":{"bytesInOutput":6736},"src/index.ts":{"bytesInOutput":0}},"bytes":8274},"dist/lib/node-esm/tools/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/tools/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-RWYFJ2XT.mjs","kind":"import-statement"}],"exports":["createToolDefinitions","fileLogger","noopLogger","registerLogger","shapeFindSymbol","shapeGetPackage","shapeGetSymbol","shapeListCapabilities","shapeListOperations","shapeListPackages","shapeListPlugins","shapeListSchemas","shapeListSurfaces","shapePluginDetail"],"entryPoint":"src/tools/index.ts","inputs":{},"bytes":734},"dist/lib/node-esm/chunk-RWYFJ2XT.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":28449},"dist/lib/node-esm/chunk-RWYFJ2XT.mjs":{"imports":[{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"@dxos/introspect-tools","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"exports":["createToolDefinitions","fileLogger","noopLogger","registerLogger","shapeFindSymbol","shapeGetPackage","shapeGetSymbol","shapeListCapabilities","shapeListOperations","shapeListPackages","shapeListPlugins","shapeListSchemas","shapeListSurfaces","shapePluginDetail"],"inputs":{"src/tools/tools.ts":{"bytesInOutput":4616},"src/tools/shaping.ts":{"bytesInOutput":5370},"src/tools/index.ts":{"bytesInOutput":0},"src/tools/logger.ts":{"bytesInOutput":702}},"bytes":11209}}}
@@ -14,7 +14,7 @@ import {
14
14
  shapeListSchemas,
15
15
  shapeListSurfaces,
16
16
  shapePluginDetail
17
- } from "../chunk-63HTIHM3.mjs";
17
+ } from "../chunk-RWYFJ2XT.mjs";
18
18
  export {
19
19
  createToolDefinitions,
20
20
  fileLogger,
@@ -1,4 +1,4 @@
1
- import type { Capability, Operation, Package, PackageDetail, Plugin, PluginDetail, Schema, Surface, SymbolDetail, SymbolMatch } from '@dxos/introspect';
1
+ import type { Capability, Idiom, Operation, Package, PackageDetail, Plugin, PluginDetail, Schema, Surface, SymbolDetail, SymbolMatch } from '@dxos/introspect';
2
2
  import { type ListOptions } from '@dxos/introspect-tools';
3
3
  export type ToolResult = {
4
4
  data: unknown;
@@ -21,4 +21,5 @@ export declare const shapeListSurfaces: (all: Surface[], opts?: ListOptions) =>
21
21
  export declare const shapeListCapabilities: (all: Capability[], opts?: ListOptions) => ToolResult;
22
22
  export declare const shapeListOperations: (all: Operation[], opts?: ListOptions) => ToolResult;
23
23
  export declare const shapeListSchemas: (all: Schema[], opts?: ListOptions) => ToolResult;
24
+ export declare const shapeListIdioms: (all: Idiom[], opts?: ListOptions) => ToolResult;
24
25
  //# sourceMappingURL=shaping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shaping.d.ts","sourceRoot":"","sources":["../../../../src/tools/shaping.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,MAAM,EACN,YAAY,EACZ,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAsC,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK9F,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA6BF,eAAO,MAAM,iBAAiB,QAAS,OAAO,EAAE,SAAQ,WAAW,KAAQ,UAWvE,CAAC;A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