@gtkx/mcp 2.0.0-beta.6 → 2.0.0-beta.8

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/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  <h1 align="center">GTKX</h1>
6
6
 
7
7
  <p align="center">
8
- The React framework for Linux, built on GTK.<br />
9
- Write native GTK4 desktop applications with React and TypeScript.
10
- Real GTK widgets, the GNOME stack, and standard web tooling.
8
+ The React framework for Linux.<br />
9
+ Write native GNOME applications with React and TypeScript.
10
+ Real Adwaita and GTK4 widgets with standard web tooling.
11
11
  </p>
12
12
 
13
13
  <p align="center">
@@ -38,11 +38,12 @@
38
38
 
39
39
  ## Demo
40
40
 
41
- The intrinsic elements in this snippet render GTK4 widgets, and ordinary React hooks and events drive them:
41
+ This app starts with an Adwaita application shell, renders native GTK4 widgets inside it, and uses ordinary React hooks and events:
42
42
 
43
43
  ```tsx
44
44
  import * as Gtk from "@gtkx/gi/gtk";
45
- import { GtkApplication, GtkApplicationWindow, GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
45
+ import { AdwApplication, AdwApplicationWindow, AdwHeaderBar, AdwToolbarView } from "@gtkx/jsx/adw";
46
+ import { GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
46
47
  import { createRoot, quit } from "@gtkx/react";
47
48
  import { useState } from "react";
48
49
 
@@ -50,38 +51,40 @@ const Counter = () => {
50
51
  const [count, setCount] = useState(0);
51
52
 
52
53
  return (
53
- <GtkApplicationWindow
54
+ <AdwApplicationWindow
54
55
  title="Hello GTKX"
55
56
  defaultWidth={400}
56
57
  defaultHeight={300}
57
58
  onCloseRequest={quit}
58
59
  >
59
- <GtkBox
60
- orientation={Gtk.Orientation.VERTICAL}
61
- spacing={20}
62
- marginTop={40}
63
- marginBottom={40}
64
- marginStart={40}
65
- marginEnd={40}
66
- valign={Gtk.Align.CENTER}
67
- halign={Gtk.Align.CENTER}
68
- >
69
- <GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
70
- <GtkLabel cssClasses={["title-2"]}>{`Count: ${count}`}</GtkLabel>
71
- <GtkButton
72
- label="Increment"
73
- onClicked={() => setCount((c) => c + 1)}
74
- cssClasses={["suggested-action", "pill"]}
75
- />
76
- </GtkBox>
77
- </GtkApplicationWindow>
60
+ <AdwToolbarView topBar={<AdwHeaderBar />}>
61
+ <GtkBox
62
+ orientation={Gtk.Orientation.VERTICAL}
63
+ spacing={20}
64
+ marginTop={40}
65
+ marginBottom={40}
66
+ marginStart={40}
67
+ marginEnd={40}
68
+ valign={Gtk.Align.CENTER}
69
+ halign={Gtk.Align.CENTER}
70
+ >
71
+ <GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
72
+ <GtkLabel cssClasses={["title-2"]}>{`Count: ${String(count)}`}</GtkLabel>
73
+ <GtkButton
74
+ label="Increment"
75
+ onClicked={() => setCount((c) => c + 1)}
76
+ cssClasses={["suggested-action", "pill"]}
77
+ />
78
+ </GtkBox>
79
+ </AdwToolbarView>
80
+ </AdwApplicationWindow>
78
81
  );
79
82
  };
80
83
 
81
84
  const App = () => (
82
- <GtkApplication>
85
+ <AdwApplication>
83
86
  <Counter />
84
- </GtkApplication>
87
+ </AdwApplication>
85
88
  );
86
89
 
87
90
  createRoot().render(<App />);
@@ -91,9 +94,9 @@ This is the [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/
91
94
 
92
95
  ## Why GTKX
93
96
 
94
- ### A declarative layer for the GNOME stack
97
+ ### Adwaita-first application development
95
98
 
96
- GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing re-renders that interface when your application state changes, and nothing hot-reloads it as you work. GTKX adds that missing layer, and the tooling around it, on top of the stack you already know:
99
+ GTKX uses Adwaita as the foundation for applications, windows, navigation, dialogs, and adaptive layouts, with the complete GTK4 toolkit underneath. It adds a declarative React layer and an integrated TypeScript toolchain to the GNOME platform:
97
100
 
98
101
  - a React reconciler that exposes every GObject as a JSX element,
99
102
  - a CLI for scaffolding, development, and production builds,
@@ -102,17 +105,17 @@ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing r
102
105
  - a Testing Library-style API for querying and driving your widgets in tests,
103
106
  - and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
104
107
 
105
- ### The full GNOME API surface
108
+ ### Native GNOME widgets, without a compatibility layer
106
109
 
107
- React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX exposes it: GTK4, Adwaita, and any other GObject-Introspection library on your system. Linux-only by design.
110
+ React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX renders real Adwaita and GTK4 widgets and exposes any other GObject-Introspection library on your system. It is GNOME-native and Linux-only by design.
108
111
 
109
112
  ### Why Node.js, and why generated bindings
110
113
 
111
114
  GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers what running on Node.js means day to day.
112
115
 
113
- GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
116
+ GTKX generates the TypeScript types and native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. `Adw-1` is the sole default GIR root; its GIR include pulls in `Gtk-4.0`, so codegen covers both complete API surfaces. Neither belongs in a GTKX 2 `libraries` list.
114
117
 
115
- At runtime, the native Rust core calls straight into the system GTK4, Adwaita, and GLib libraries through libffi, without loading libgirepository at all.
118
+ At runtime, the native Rust core calls straight into the system Adwaita, GTK4, and GLib libraries through libffi, without loading libgirepository at all.
116
119
 
117
120
  ## Quick start
118
121
 
@@ -121,10 +124,10 @@ GTKX is Linux-only and needs Node.js 26.7 or later. See [Requirements](#requirem
121
124
  Scaffold a new app with the `create-gtkx` initializer:
122
125
 
123
126
  ```sh
124
- npm create gtkx
127
+ npm create gtkx@beta
125
128
  ```
126
129
 
127
- The same command works with other package managers: `pnpm create gtkx` or `yarn create gtkx`.
130
+ The same command works with other package managers: `pnpm create gtkx@beta` or `yarn create gtkx@beta`.
128
131
 
129
132
  Then run your new app:
130
133
 
@@ -145,7 +148,7 @@ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tu
145
148
 
146
149
  GTKX is Linux-only. You need:
147
150
 
148
- - Linux with the GTK4 (4.20 or later), Adwaita (1.8 or later), and GLib development libraries
151
+ - Linux with the Adwaita (1.8 or later), GTK4 (4.20 or later), and GLib development libraries
149
152
  - Node.js 26.7 or later
150
153
 
151
154
  The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
@@ -154,10 +157,10 @@ The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other tar
154
157
 
155
158
  Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
156
159
 
157
- - [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
158
- - [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
159
- - [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
160
- - [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): a tour of `@gtkx/animated`, React Spring animations driven by the GTK frame clock.
160
+ - [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the Adwaita counter above.
161
+ - [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): the official GTK4 widget showcase in an Adwaita application shell, covering lists, dialogs, gestures, CSS, and OpenGL.
162
+ - [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): an Adwaita browser built around `WebKitWebView`.
163
+ - [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): an Adwaita showcase for `@gtkx/animated`, with React Spring animations driven by the GTK frame clock.
161
164
  - [`navigation`](https://github.com/gtkx-org/gtkx/tree/main/examples/navigation): a tour of `@gtkx/navigation`, React Navigation's stack, tab, and drawer navigators rendered with libadwaita.
162
165
  - [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
163
166
 
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAsE,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAK3F,OAAO,EAAsC,KAAK,IAAI,EAAiB,MAAM,WAAW,CAAC;AAEzF,KAAK,YAAY,GAAG,IAAI,CACpB,YAAY,EACZ,QAAQ,GAAG,mBAAmB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CACxF,CAAC;AAEF,KAAK,aAAa,GAAG,UAAU,GAAG,kBAAkB,GAAG,KAAK,CAAC;AAE7D,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,KAAK,eAAe,GAAG,eAAe,GAAG;IACrC,SAAS,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC5B,UAAU,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACrC,mBAAmB,CAAC,EAAE,MAAM,MAAM,CAAC;CACtC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACrB,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,CAAC,WAAW,CAAC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,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;CAClD,CAAC;AAsBF,KAAK,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAkM1D,QAAA,MAAM,uBAAuB,GAAI,SAAS,wBAAwB,KAAG,iBAgBpE,CAAC;AA2HF,QAAA,MAAM,mBAAmB,GAAI,UAAU,iBAAiB,KAAG,IAAI,EAI9D,CAAC;AAmJF,QAAA,MAAM,0BAA0B,GAAI,QAAQ,cAAc,EAAE,UAAU,iBAAiB,KAAG,IAIzF,CAAC;AAEF,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,iBAAiB,GACzB,CAAC"}
package/dist/reference.js CHANGED
@@ -25,8 +25,8 @@ const SYMBOL_KIND = z.enum([
25
25
  "function",
26
26
  "constant",
27
27
  ]);
28
- const SYMBOL_DESCRIPTION = "Qualified symbol name (`Gtk.Button`, `Gtk.Orientation`, `GLib.idleAdd`), JSX element name (`GtkButton`), " +
29
- "or bare symbol name when unambiguous (`Button`).";
28
+ const SYMBOL_DESCRIPTION = "Qualified symbol name (`Adw.Toast`, `Gtk.Orientation`, `GLib.idleAdd`), JSX element name (`AdwToast`), " +
29
+ "or bare symbol name when unambiguous (`Toast`).";
30
30
  const PROJECT_ROOT_DESCRIPTION = "Directory of the GTKX project whose bindings to document, absolute or relative to the working directory. " +
31
31
  "Any directory inside the project works; its `gtkx.config.ts` decides the documented libraries. Omit to use " +
32
32
  "the project containing the working directory, falling back to a connected app's project.";
@@ -38,12 +38,12 @@ const listApiShape = {
38
38
  namespace: z
39
39
  .string()
40
40
  .optional()
41
- .describe("Namespace to list (e.g. `Gtk`, `Adw`, `Gio`). Omit for an overview of all namespaces."),
41
+ .describe("Namespace to list (e.g. `Adw`, `Gtk`, `Gio`). Omit for an overview of all namespaces."),
42
42
  };
43
43
  const searchApiShape = {
44
44
  ...projectRootShape,
45
45
  query: z.string().describe("Case-insensitive substring of a symbol name, e.g. `headerbar` or `orientation`."),
46
- namespace: z.string().optional().describe("Restrict matches to one namespace (e.g. `Gtk`)."),
46
+ namespace: z.string().optional().describe("Restrict matches to one namespace (e.g. `Adw`)."),
47
47
  kind: SYMBOL_KIND.optional().describe("Restrict matches to one symbol kind."),
48
48
  limit: z.number().int().min(1).optional().describe("Maximum number of results (default: 20)."),
49
49
  };
@@ -211,8 +211,9 @@ const listApiTool = (provider) => defineTool({
211
211
  name: "gtkx_list_api",
212
212
  title: "List API reference",
213
213
  kind: "readOnly",
214
- description: "List the project's generated GTK4 bindings API (`@gtkx/gi` and `@gtkx/jsx`). Without a namespace, " +
215
- "returns every namespace with symbol counts; with a namespace, lists all of its symbols grouped by kind.",
214
+ description: "List the project's generated bindings API (`@gtkx/gi` and `@gtkx/jsx`), including Adwaita, " +
215
+ "GTK4, and its declared GIR libraries. Without a namespace, returns every namespace with symbol counts; " +
216
+ "with a namespace, lists all of its symbols grouped by kind.",
216
217
  inputSchema: listApiShape,
217
218
  handler: ({ namespace, projectRoot }) => scopedResult(provider, projectRoot, (reference) => listApiResult(reference, namespace)),
218
219
  });
@@ -220,7 +221,7 @@ const searchApiTool = (provider) => defineTool({
220
221
  name: "gtkx_search_api",
221
222
  title: "Search API reference",
222
223
  kind: "readOnly",
223
- description: "Search the project's generated GTK4 bindings API by symbol name. Returns matching symbols with " +
224
+ description: "Search the project's generated bindings API by symbol name. Returns matching symbols with " +
224
225
  "their namespace, kind, and a one-line summary; fetch full pages with `gtkx_get_api_docs`.",
225
226
  inputSchema: searchApiShape,
226
227
  handler: (args) => scopedResult(provider, args.projectRoot, (reference) => searchApiResult(reference, args)),
@@ -229,7 +230,7 @@ const getApiDocsTool = (provider) => defineTool({
229
230
  name: "gtkx_get_api_docs",
230
231
  title: "Get API docs",
231
232
  kind: "readOnly",
232
- description: "Get the full reference page for one symbol of the project's generated GTK4 bindings: JSX elements " +
233
+ description: "Get the full reference page for one symbol of the project's generated bindings: JSX elements " +
233
234
  "(props, signals, methods) or `@gtkx/gi` classes, interfaces, records, enums, callbacks, aliases, " +
234
235
  "functions, and constants.",
235
236
  inputSchema: apiDocsShape,
@@ -278,7 +279,7 @@ const symbolPage = async (uri, provider, namespace, symbol) => {
278
279
  const registerIndexResource = (server, provider) => {
279
280
  server.registerResource("gtkx-api-reference", "gtkx://reference/index", {
280
281
  title: "GTKX API reference index",
281
- description: "Namespaces of the project's generated GTK4 bindings, with symbol and JSX element counts.",
282
+ description: "Namespaces of the project's generated bindings, with symbol and JSX element counts.",
282
283
  mimeType: "text/markdown",
283
284
  }, async (uri) => {
284
285
  const { reference } = await provider.get();
@@ -302,7 +303,7 @@ const registerNamespaceResource = (server, provider) => {
302
303
  },
303
304
  }), {
304
305
  title: "GTKX namespace reference",
305
- description: "All symbols of one namespace of the project's generated GTK4 bindings, grouped by kind.",
306
+ description: "All symbols of one namespace of the project's generated bindings, grouped by kind.",
306
307
  mimeType: "text/markdown",
307
308
  }, async (uri, variables) => {
308
309
  const namespace = variableValue(variables.namespace);
@@ -323,7 +324,7 @@ const registerSymbolResource = (server, provider) => {
323
324
  },
324
325
  }), {
325
326
  title: "GTKX symbol reference",
326
- description: "Reference page for one symbol of the project's generated GTK4 bindings: a JSX element or a " +
327
+ description: "Reference page for one symbol of the project's generated bindings: a JSX element or a " +
327
328
  "class, interface, record, enum, callback, alias, function, or constant.",
328
329
  mimeType: "text/markdown",
329
330
  }, (uri, variables) => symbolPage(uri, provider, variableValue(variables.namespace), variableValue(variables.symbol)));
@@ -1 +1 @@
1
- {"version":3,"file":"reference.js","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO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CAAC;AAEF,OAAO,EACH,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,GAE7B,CAAC","sourcesContent":["import { type ApiReference, type ApiSymbol, loadApiReference, resolveGirPath, resolveLibraries } from \"@gtkx/codegen\";\nimport { loadConfig } from \"@gtkx/config\";\nimport { type McpServer, ResourceTemplate } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { type CallToolResult, ErrorCode, McpError, type ReadResourceResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport { defineTool, textContent, textError, type Tool, type ToolArgs } from \"./tool.js\";\n\ntype ReferenceApi = Pick<\n ApiReference,\n \"lookup\" | \"namespaceOverview\" | \"namespaces\" | \"overview\" | \"search\" | \"symbolNames\"\n>;\n\ntype ProjectSource = \"argument\" | \"workingDirectory\" | \"app\";\n\ntype ResolvedProject = {\n root: string;\n source: ProjectSource;\n};\n\ntype ScopedReference = ResolvedProject & {\n reference: ReferenceApi;\n};\n\ntype ReferenceProviderOptions = {\n getAppRoot: () => string | undefined;\n getWorkingDirectory?: () => string;\n};\n\ntype ReferenceProvider = {\n get(projectRoot?: string): Promise<ScopedReference>;\n load(project: ResolvedProject): Promise<ScopedReference>;\n resolve(projectRoot?: string): ResolvedProject;\n};\n\ntype WatchedFile = {\n path: string;\n mtimeMs: number;\n size: number;\n};\n\ntype LoadedReference = {\n reference: ApiReference;\n root: string;\n watched: WatchedFile[];\n};\n\ntype CacheEntry = {\n pending: Promise<LoadedReference>;\n verifiedAt: number;\n failedAt: number | undefined;\n};\n\ntype ReferenceCache = Map<string, CacheEntry>;\ntype SearchOptions = Parameters<ReferenceApi[\"search\"]>[0];\ntype ResourceServer = Pick<McpServer, \"registerResource\">;\n\nconst FRESHNESS_INTERVAL_MS = 2000;\nconst FAILURE_RETRY_MS = 5000;\nconst CONFIG_EXTENSIONS = [\"ts\", \"mts\", \"js\", \"mjs\", \"json\"];\n\nconst PROJECT_SOURCE_LABELS: Record<ProjectSource, string> = {\n argument: \"requested with `projectRoot`\",\n workingDirectory: \"found from the working directory\",\n app: \"taken from a connected app; pass `projectRoot` to document another project\",\n};\n\nconst SYMBOL_KIND = z.enum([\n \"element\",\n \"class\",\n \"interface\",\n \"record\",\n \"enum\",\n \"callback\",\n \"alias\",\n \"function\",\n \"constant\",\n]);\n\nconst SYMBOL_DESCRIPTION =\n \"Qualified symbol name (`Gtk.Button`, `Gtk.Orientation`, `GLib.idleAdd`), JSX element name (`GtkButton`), \" +\n \"or bare symbol name when unambiguous (`Button`).\";\n\nconst PROJECT_ROOT_DESCRIPTION =\n \"Directory of the GTKX project whose bindings to document, absolute or relative to the working directory. \" +\n \"Any directory inside the project works; its `gtkx.config.ts` decides the documented libraries. Omit to use \" +\n \"the project containing the working directory, falling back to a connected app's project.\";\n\nconst projectRootShape = {\n projectRoot: z.string().optional().describe(PROJECT_ROOT_DESCRIPTION),\n};\n\nconst listApiShape = {\n ...projectRootShape,\n namespace: z\n .string()\n .optional()\n .describe(\"Namespace to list (e.g. `Gtk`, `Adw`, `Gio`). Omit for an overview of all namespaces.\"),\n};\n\nconst searchApiShape = {\n ...projectRootShape,\n query: z.string().describe(\"Case-insensitive substring of a symbol name, e.g. `headerbar` or `orientation`.\"),\n namespace: z.string().optional().describe(\"Restrict matches to one namespace (e.g. `Gtk`).\"),\n kind: SYMBOL_KIND.optional().describe(\"Restrict matches to one symbol kind.\"),\n limit: z.number().int().min(1).optional().describe(\"Maximum number of results (default: 20).\"),\n};\n\nconst apiDocsShape = {\n ...projectRootShape,\n symbol: z.string().describe(SYMBOL_DESCRIPTION),\n kind: SYMBOL_KIND.optional().describe(\"Disambiguate when several kinds share the symbol name.\"),\n};\n\nconst watchFile = (path: string): WatchedFile => {\n try {\n const stats = statSync(path);\n\n return { path, mtimeMs: stats.mtimeMs, size: stats.size };\n } catch {\n return { path, mtimeMs: -1, size: -1 };\n }\n};\n\nconst isFresh = (loaded: LoadedReference): boolean =>\n loaded.watched.every((file) => {\n const current = watchFile(file.path);\n\n return current.mtimeMs === file.mtimeMs && current.size === file.size;\n });\n\nconst hasConfigFile = (directory: string): boolean =>\n CONFIG_EXTENSIONS.some((extension) => existsSync(join(directory, `gtkx.config.${extension}`)));\n\nconst findProjectRoot = (start: string): string | undefined => {\n const current = resolve(start);\n const parent = dirname(current);\n\n if (hasConfigFile(current)) {\n return current;\n }\n\n return parent === current ? undefined : findProjectRoot(parent);\n};\n\nconst projectAt = (candidate: string, source: ProjectSource): ResolvedProject => ({\n root: findProjectRoot(candidate) ?? resolve(candidate),\n source,\n});\n\nconst resolveProject = (\n workingDirectory: string,\n getAppRoot: () => string | undefined,\n projectRoot: string | undefined,\n): ResolvedProject => {\n if (projectRoot !== undefined) {\n return projectAt(projectRoot, \"argument\");\n }\n\n const discovered = findProjectRoot(workingDirectory);\n\n if (discovered !== undefined) {\n return { root: discovered, source: \"workingDirectory\" };\n }\n\n const appRoot = getAppRoot();\n\n return appRoot === undefined\n ? { root: resolve(workingDirectory), source: \"workingDirectory\" }\n : projectAt(appRoot, \"app\");\n};\n\nconst loadReference = async (requestedRoot: string): Promise<LoadedReference> => {\n const { config, configFile, root } = await loadConfig(requestedRoot);\n\n if (config.codegen === false) {\n throw new Error(\n `codegen is disabled for the project at ${root}, so there are no generated bindings to document. ` +\n \"Remove `codegen: false` from gtkx.config.ts to use the API reference, or point the `projectRoot` \" +\n \"argument at another project.\",\n );\n }\n\n const girPath = resolveGirPath(config.girPath);\n\n if (girPath.length === 0) {\n throw new Error(\n \"No GIR search paths available. Install gobject-introspection \" +\n \"(Linux: `sudo dnf install gobject-introspection-devel` or `sudo apt install libgirepository1.0-dev`), \" +\n \"or set `girPath` in gtkx.config.ts.\",\n );\n }\n\n const libraries = resolveLibraries(config.libraries);\n\n const reference = loadApiReference({\n libraries,\n girPath,\n });\n\n const watched = [watchFile(resolve(root, configFile)), ...reference.girFiles.map((file) => watchFile(file))];\n\n return { reference, root, watched };\n};\n\nconst startLoad = (cache: ReferenceCache, root: string): CacheEntry => {\n const entry: CacheEntry = { pending: loadReference(root), verifiedAt: Date.now(), failedAt: undefined };\n\n void entry.pending.catch(() => {\n entry.failedAt = Date.now();\n });\n\n cache.set(root, entry);\n\n return entry;\n};\n\nconst isRetryDue = (entry: CacheEntry): boolean =>\n entry.failedAt !== undefined && Date.now() - entry.failedAt >= FAILURE_RETRY_MS;\n\nconst resolveEntry = (cache: ReferenceCache, root: string): CacheEntry => {\n const entry = cache.get(root) ?? startLoad(cache, root);\n\n return isRetryDue(entry) ? startLoad(cache, root) : entry;\n};\n\nconst revalidate = (cache: ReferenceCache, root: string, entry: CacheEntry): CacheEntry => {\n const current = cache.get(root);\n\n return current === undefined || current === entry ? startLoad(cache, root) : current;\n};\n\nconst currentReference = async (cache: ReferenceCache, root: string): Promise<LoadedReference> => {\n const entry = resolveEntry(cache, root);\n const loaded = await entry.pending;\n\n if (Date.now() - entry.verifiedAt < FRESHNESS_INTERVAL_MS) {\n return loaded;\n }\n\n if (isFresh(loaded)) {\n entry.verifiedAt = Date.now();\n\n return loaded;\n }\n\n return revalidate(cache, root, entry).pending;\n};\n\nconst createReferenceProvider = (options: ReferenceProviderOptions): ReferenceProvider => {\n const cache: ReferenceCache = new Map();\n const getWorkingDirectory = options.getWorkingDirectory ?? (() => process.cwd());\n\n const resolve = (projectRoot?: string): ResolvedProject =>\n resolveProject(getWorkingDirectory(), options.getAppRoot, projectRoot);\n\n const load = async (project: ResolvedProject): Promise<ScopedReference> => {\n const loaded = await currentReference(cache, project.root);\n\n return { reference: loaded.reference, root: loaded.root, source: project.source };\n };\n\n const get = (projectRoot?: string): Promise<ScopedReference> => load(resolve(projectRoot));\n\n return { get, load, resolve };\n};\n\nconst projectNote = (project: ResolvedProject): string =>\n `Project: ${project.root} (${PROJECT_SOURCE_LABELS[project.source]})`;\n\nconst withProjectNote = (result: CallToolResult, note: string): CallToolResult => ({\n ...result,\n content: [...result.content, { type: \"text\", text: note }],\n});\n\nconst scopedResult = async (\n provider: ReferenceProvider,\n projectRoot: string | undefined,\n render: (reference: ReferenceApi) => CallToolResult,\n): Promise<CallToolResult> => {\n const resolved = provider.resolve(projectRoot);\n\n try {\n const scoped = await provider.load(resolved);\n\n return withProjectNote(render(scoped.reference), projectNote(scoped));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n return withProjectNote(textError(message), projectNote(resolved));\n }\n};\n\nconst formatCandidates = (candidates: ApiSymbol[]): string =>\n candidates.map((candidate) => `- ${candidate.namespace}.${candidate.name} (${candidate.kind})`).join(\"\\n\");\n\nconst buildSearchOptions = (args: ToolArgs<typeof searchApiShape>): SearchOptions => ({\n query: args.query,\n ...(args.namespace !== undefined && { namespace: args.namespace }),\n ...(args.kind !== undefined && { kinds: [args.kind] }),\n ...(args.limit !== undefined && { limit: args.limit }),\n});\n\nconst listApiResult = (reference: ReferenceApi, namespace: string | undefined): CallToolResult => {\n if (namespace === undefined) {\n return textContent(reference.overview());\n }\n\n const overview = reference.namespaceOverview(namespace);\n\n if (overview === undefined) {\n const names = reference\n .namespaces()\n .map((summary) => summary.name)\n .join(\", \");\n\n return textError(`Unknown namespace \"${namespace}\". Available namespaces: ${names}`);\n }\n\n return textContent(overview);\n};\n\nconst searchApiResult = (reference: ReferenceApi, args: ToolArgs<typeof searchApiShape>): CallToolResult => {\n const results = reference.search(buildSearchOptions(args));\n\n if (results.length === 0) {\n return textContent(`No symbols matched \"${args.query}\". Try a shorter substring or \\`gtkx_list_api\\`.`);\n }\n\n return textContent(JSON.stringify(results, null, 2));\n};\n\nconst apiDocsResult = (reference: ReferenceApi, args: ToolArgs<typeof apiDocsShape>): CallToolResult => {\n const result = reference.lookup(args.symbol, args.kind);\n\n if (result.outcome === \"notFound\") {\n return textError(`No symbol named \"${args.symbol}\". Use \\`gtkx_search_api\\` to find the right name.`);\n }\n\n if (result.outcome === \"ambiguous\") {\n return textError(\n `\"${args.symbol}\" matches several symbols. Pass a qualified name or a kind:\\n` +\n formatCandidates(result.candidates),\n );\n }\n\n return textContent(result.markdown);\n};\n\nconst listApiTool = (provider: ReferenceProvider): Tool =>\n defineTool({\n name: \"gtkx_list_api\",\n title: \"List API reference\",\n kind: \"readOnly\",\n description:\n \"List the project's generated GTK4 bindings API (`@gtkx/gi` and `@gtkx/jsx`). Without a namespace, \" +\n \"returns every namespace with symbol counts; with a namespace, lists all of its symbols grouped by kind.\",\n inputSchema: listApiShape,\n handler: ({ namespace, projectRoot }) =>\n scopedResult(provider, projectRoot, (reference) => listApiResult(reference, namespace)),\n });\n\nconst searchApiTool = (provider: ReferenceProvider): Tool =>\n defineTool({\n name: \"gtkx_search_api\",\n title: \"Search API reference\",\n kind: \"readOnly\",\n description:\n \"Search the project's generated GTK4 bindings API by symbol name. Returns matching symbols with \" +\n \"their namespace, kind, and a one-line summary; fetch full pages with `gtkx_get_api_docs`.\",\n inputSchema: searchApiShape,\n handler: (args) => scopedResult(provider, args.projectRoot, (reference) => searchApiResult(reference, args)),\n });\n\nconst getApiDocsTool = (provider: ReferenceProvider): Tool =>\n defineTool({\n name: \"gtkx_get_api_docs\",\n title: \"Get API docs\",\n kind: \"readOnly\",\n description:\n \"Get the full reference page for one symbol of the project's generated GTK4 bindings: JSX elements \" +\n \"(props, signals, methods) or `@gtkx/gi` classes, interfaces, records, enums, callbacks, aliases, \" +\n \"functions, and constants.\",\n inputSchema: apiDocsShape,\n handler: (args) => scopedResult(provider, args.projectRoot, (reference) => apiDocsResult(reference, args)),\n });\n\nconst buildReferenceTools = (provider: ReferenceProvider): Tool[] => [\n listApiTool(provider),\n searchApiTool(provider),\n getApiDocsTool(provider),\n];\n\nconst markdownResource = (uri: URL, text: string): ReadResourceResult => ({\n contents: [{ uri: uri.href, mimeType: \"text/markdown\", text }],\n});\n\nconst variableValue = (value: string | string[] | undefined): string =>\n Array.isArray(value) ? (value[0] ?? \"\") : (value ?? \"\");\n\nconst withLoadFallback = async <T>(load: () => Promise<T>, fallback: T): Promise<T> => {\n try {\n return await load();\n } catch {\n return fallback;\n }\n};\n\nconst completeNames = (\n provider: ReferenceProvider,\n value: string,\n collect: (reference: ReferenceApi) => string[],\n): Promise<string[]> =>\n withLoadFallback(async () => {\n const { reference } = await provider.get();\n\n return collect(reference).filter((name) => name.toLowerCase().startsWith(value.toLowerCase()));\n }, []);\n\nconst namespaceCompleter =\n (provider: ReferenceProvider) =>\n (value: string): Promise<string[]> =>\n completeNames(provider, value, (reference) => reference.namespaces().map((summary) => summary.name));\n\nconst completeSymbol = (provider: ReferenceProvider, namespace: string, value: string): Promise<string[]> => {\n if (namespace.length === 0) {\n return Promise.resolve([]);\n }\n\n return completeNames(provider, value, (reference) => reference.symbolNames(namespace));\n};\n\nconst resourceNotFound = (message: string): McpError => new McpError(ErrorCode.InvalidParams, message);\n\nconst symbolPage = async (\n uri: URL,\n provider: ReferenceProvider,\n namespace: string,\n symbol: string,\n): Promise<ReadResourceResult> => {\n const { reference } = await provider.get();\n const result = reference.lookup(`${namespace}.${symbol}`);\n\n if (result.outcome === \"page\") {\n return markdownResource(uri, result.markdown);\n }\n\n if (result.outcome === \"ambiguous\") {\n throw resourceNotFound(\n `\"${namespace}.${symbol}\" matches several symbols:\\n${formatCandidates(result.candidates)}`,\n );\n }\n\n throw resourceNotFound(`No symbol named \"${namespace}.${symbol}\"`);\n};\n\nconst registerIndexResource = (server: ResourceServer, provider: ReferenceProvider): void => {\n server.registerResource(\n \"gtkx-api-reference\",\n \"gtkx://reference/index\",\n {\n title: \"GTKX API reference index\",\n description: \"Namespaces of the project's generated GTK4 bindings, with symbol and JSX element counts.\",\n mimeType: \"text/markdown\",\n },\n async (uri) => {\n const { reference } = await provider.get();\n\n return markdownResource(uri, reference.overview());\n },\n );\n};\n\nconst registerNamespaceResource = (server: ResourceServer, provider: ReferenceProvider): void => {\n server.registerResource(\n \"gtkx-api-namespace\",\n new ResourceTemplate(\"gtkx://reference/{namespace}\", {\n list: () =>\n withLoadFallback(\n async () => {\n const { reference } = await provider.get();\n\n return {\n resources: reference.namespaces().map((summary) => ({\n uri: `gtkx://reference/${summary.name}`,\n name: `${summary.name} namespace reference`,\n mimeType: \"text/markdown\",\n })),\n };\n },\n { resources: [] },\n ),\n complete: {\n namespace: namespaceCompleter(provider),\n },\n }),\n {\n title: \"GTKX namespace reference\",\n description: \"All symbols of one namespace of the project's generated GTK4 bindings, grouped by kind.\",\n mimeType: \"text/markdown\",\n },\n async (uri, variables) => {\n const namespace = variableValue(variables.namespace);\n const { reference } = await provider.get();\n const overview = reference.namespaceOverview(namespace);\n\n if (overview === undefined) {\n throw resourceNotFound(`Unknown namespace \"${namespace}\"`);\n }\n\n return markdownResource(uri, overview);\n },\n );\n};\n\nconst registerSymbolResource = (server: ResourceServer, provider: ReferenceProvider): void => {\n server.registerResource(\n \"gtkx-api-symbol\",\n new ResourceTemplate(\"gtkx://reference/{namespace}/{symbol}\", {\n list: undefined,\n complete: {\n namespace: namespaceCompleter(provider),\n symbol: (value, context) =>\n completeSymbol(provider, variableValue(context?.arguments?.namespace), value),\n },\n }),\n {\n title: \"GTKX symbol reference\",\n description:\n \"Reference page for one symbol of the project's generated GTK4 bindings: a JSX element or a \" +\n \"class, interface, record, enum, callback, alias, function, or constant.\",\n mimeType: \"text/markdown\",\n },\n (uri, variables) =>\n symbolPage(uri, provider, variableValue(variables.namespace), variableValue(variables.symbol)),\n );\n};\n\nconst registerReferenceResources = (server: ResourceServer, provider: ReferenceProvider): void => {\n registerIndexResource(server, provider);\n registerNamespaceResource(server, provider);\n registerSymbolResource(server, provider);\n};\n\nexport {\n createReferenceProvider,\n buildReferenceTools,\n registerReferenceResources,\n type ReferenceProvider,\n};\n"]}
1
+ {"version":3,"file":"reference.js","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA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AAuB,EACvB,mBAAmB,EACnB,0BAA0B,GAE7B,CAAC","sourcesContent":["import { type ApiReference, type ApiSymbol, loadApiReference, resolveGirPath, resolveLibraries } from \"@gtkx/codegen\";\nimport { loadConfig } from \"@gtkx/config\";\nimport { type McpServer, ResourceTemplate } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { type CallToolResult, ErrorCode, McpError, type ReadResourceResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport { defineTool, textContent, textError, type Tool, type ToolArgs } from \"./tool.js\";\n\ntype ReferenceApi = Pick<\n ApiReference,\n \"lookup\" | \"namespaceOverview\" | \"namespaces\" | \"overview\" | \"search\" | \"symbolNames\"\n>;\n\ntype ProjectSource = \"argument\" | \"workingDirectory\" | \"app\";\n\ntype ResolvedProject = {\n root: string;\n source: ProjectSource;\n};\n\ntype ScopedReference = ResolvedProject & {\n reference: ReferenceApi;\n};\n\ntype ReferenceProviderOptions = {\n getAppRoot: () => string | undefined;\n getWorkingDirectory?: () => string;\n};\n\ntype ReferenceProvider = {\n get(projectRoot?: string): Promise<ScopedReference>;\n load(project: ResolvedProject): Promise<ScopedReference>;\n resolve(projectRoot?: string): ResolvedProject;\n};\n\ntype WatchedFile = {\n path: string;\n mtimeMs: number;\n size: number;\n};\n\ntype LoadedReference = {\n reference: ApiReference;\n root: string;\n watched: WatchedFile[];\n};\n\ntype CacheEntry = {\n pending: Promise<LoadedReference>;\n verifiedAt: number;\n failedAt: number | undefined;\n};\n\ntype ReferenceCache = Map<string, CacheEntry>;\ntype SearchOptions = Parameters<ReferenceApi[\"search\"]>[0];\ntype ResourceServer = Pick<McpServer, \"registerResource\">;\n\nconst FRESHNESS_INTERVAL_MS = 2000;\nconst FAILURE_RETRY_MS = 5000;\nconst CONFIG_EXTENSIONS = [\"ts\", \"mts\", \"js\", \"mjs\", \"json\"];\n\nconst PROJECT_SOURCE_LABELS: Record<ProjectSource, string> = {\n argument: \"requested with `projectRoot`\",\n workingDirectory: \"found from the working directory\",\n app: \"taken from a connected app; pass `projectRoot` to document another project\",\n};\n\nconst SYMBOL_KIND = z.enum([\n \"element\",\n \"class\",\n \"interface\",\n \"record\",\n \"enum\",\n \"callback\",\n \"alias\",\n \"function\",\n \"constant\",\n]);\n\nconst SYMBOL_DESCRIPTION =\n \"Qualified symbol name (`Adw.Toast`, `Gtk.Orientation`, `GLib.idleAdd`), JSX element name (`AdwToast`), \" +\n \"or bare symbol name when unambiguous (`Toast`).\";\n\nconst PROJECT_ROOT_DESCRIPTION =\n \"Directory of the GTKX project whose bindings to document, absolute or relative to the working directory. \" +\n \"Any directory inside the project works; its `gtkx.config.ts` decides the documented libraries. Omit to use \" +\n \"the project containing the working directory, falling back to a connected app's project.\";\n\nconst projectRootShape = {\n projectRoot: z.string().optional().describe(PROJECT_ROOT_DESCRIPTION),\n};\n\nconst listApiShape = {\n ...projectRootShape,\n namespace: z\n .string()\n .optional()\n .describe(\"Namespace to list (e.g. `Adw`, `Gtk`, `Gio`). Omit for an overview of all namespaces.\"),\n};\n\nconst searchApiShape = {\n ...projectRootShape,\n query: z.string().describe(\"Case-insensitive substring of a symbol name, e.g. `headerbar` or `orientation`.\"),\n namespace: z.string().optional().describe(\"Restrict matches to one namespace (e.g. `Adw`).\"),\n kind: SYMBOL_KIND.optional().describe(\"Restrict matches to one symbol kind.\"),\n limit: z.number().int().min(1).optional().describe(\"Maximum number of results (default: 20).\"),\n};\n\nconst apiDocsShape = {\n ...projectRootShape,\n symbol: z.string().describe(SYMBOL_DESCRIPTION),\n kind: SYMBOL_KIND.optional().describe(\"Disambiguate when several kinds share the symbol name.\"),\n};\n\nconst watchFile = (path: string): WatchedFile => {\n try {\n const stats = statSync(path);\n\n return { path, mtimeMs: stats.mtimeMs, size: stats.size };\n } catch {\n return { path, mtimeMs: -1, size: -1 };\n }\n};\n\nconst isFresh = (loaded: LoadedReference): boolean =>\n loaded.watched.every((file) => {\n const current = watchFile(file.path);\n\n return current.mtimeMs === file.mtimeMs && current.size === file.size;\n });\n\nconst hasConfigFile = (directory: string): boolean =>\n CONFIG_EXTENSIONS.some((extension) => existsSync(join(directory, `gtkx.config.${extension}`)));\n\nconst findProjectRoot = (start: string): string | undefined => {\n const current = resolve(start);\n const parent = dirname(current);\n\n if (hasConfigFile(current)) {\n return current;\n }\n\n return parent === current ? undefined : findProjectRoot(parent);\n};\n\nconst projectAt = (candidate: string, source: ProjectSource): ResolvedProject => ({\n root: findProjectRoot(candidate) ?? resolve(candidate),\n source,\n});\n\nconst resolveProject = (\n workingDirectory: string,\n getAppRoot: () => string | undefined,\n projectRoot: string | undefined,\n): ResolvedProject => {\n if (projectRoot !== undefined) {\n return projectAt(projectRoot, \"argument\");\n }\n\n const discovered = findProjectRoot(workingDirectory);\n\n if (discovered !== undefined) {\n return { root: discovered, source: \"workingDirectory\" };\n }\n\n const appRoot = getAppRoot();\n\n return appRoot === undefined\n ? { root: resolve(workingDirectory), source: \"workingDirectory\" }\n : projectAt(appRoot, \"app\");\n};\n\nconst loadReference = async (requestedRoot: string): Promise<LoadedReference> => {\n const { config, configFile, root } = await loadConfig(requestedRoot);\n\n if (config.codegen === false) {\n throw new Error(\n `codegen is disabled for the project at ${root}, so there are no generated bindings to document. ` +\n \"Remove `codegen: false` from gtkx.config.ts to use the API reference, or point the `projectRoot` \" +\n \"argument at another project.\",\n );\n }\n\n const girPath = resolveGirPath(config.girPath);\n\n if (girPath.length === 0) {\n throw new Error(\n \"No GIR search paths available. Install gobject-introspection \" +\n \"(Linux: `sudo dnf install gobject-introspection-devel` or `sudo apt install libgirepository1.0-dev`), \" +\n \"or set `girPath` in gtkx.config.ts.\",\n );\n }\n\n const libraries = resolveLibraries(config.libraries);\n\n const reference = loadApiReference({\n libraries,\n girPath,\n });\n\n const watched = [watchFile(resolve(root, configFile)), ...reference.girFiles.map((file) => watchFile(file))];\n\n return { reference, root, watched };\n};\n\nconst startLoad = (cache: ReferenceCache, root: string): CacheEntry => {\n const entry: CacheEntry = { pending: loadReference(root), verifiedAt: Date.now(), failedAt: undefined };\n\n void entry.pending.catch(() => {\n entry.failedAt = Date.now();\n });\n\n cache.set(root, entry);\n\n return entry;\n};\n\nconst isRetryDue = (entry: CacheEntry): boolean =>\n entry.failedAt !== undefined && Date.now() - entry.failedAt >= FAILURE_RETRY_MS;\n\nconst resolveEntry = (cache: ReferenceCache, root: string): CacheEntry => {\n const entry = cache.get(root) ?? startLoad(cache, root);\n\n return isRetryDue(entry) ? startLoad(cache, root) : entry;\n};\n\nconst revalidate = (cache: ReferenceCache, root: string, entry: CacheEntry): CacheEntry => {\n const current = cache.get(root);\n\n return current === undefined || current === entry ? startLoad(cache, root) : current;\n};\n\nconst currentReference = async (cache: ReferenceCache, root: string): Promise<LoadedReference> => {\n const entry = resolveEntry(cache, root);\n const loaded = await entry.pending;\n\n if (Date.now() - entry.verifiedAt < FRESHNESS_INTERVAL_MS) {\n return loaded;\n }\n\n if (isFresh(loaded)) {\n entry.verifiedAt = Date.now();\n\n return loaded;\n }\n\n return revalidate(cache, root, entry).pending;\n};\n\nconst createReferenceProvider = (options: ReferenceProviderOptions): ReferenceProvider => {\n const cache: ReferenceCache = new Map();\n const getWorkingDirectory = options.getWorkingDirectory ?? (() => process.cwd());\n\n const resolve = (projectRoot?: string): ResolvedProject =>\n resolveProject(getWorkingDirectory(), options.getAppRoot, projectRoot);\n\n const load = async (project: ResolvedProject): Promise<ScopedReference> => {\n const loaded = await currentReference(cache, project.root);\n\n return { reference: loaded.reference, root: loaded.root, source: project.source };\n };\n\n const get = (projectRoot?: string): Promise<ScopedReference> => load(resolve(projectRoot));\n\n return { get, load, resolve };\n};\n\nconst projectNote = (project: ResolvedProject): string =>\n `Project: ${project.root} (${PROJECT_SOURCE_LABELS[project.source]})`;\n\nconst withProjectNote = (result: CallToolResult, note: string): CallToolResult => ({\n ...result,\n content: [...result.content, { type: \"text\", text: note }],\n});\n\nconst scopedResult = async (\n provider: ReferenceProvider,\n projectRoot: string | undefined,\n render: (reference: ReferenceApi) => CallToolResult,\n): Promise<CallToolResult> => {\n const resolved = provider.resolve(projectRoot);\n\n try {\n const scoped = await provider.load(resolved);\n\n return withProjectNote(render(scoped.reference), projectNote(scoped));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n return withProjectNote(textError(message), projectNote(resolved));\n }\n};\n\nconst formatCandidates = (candidates: ApiSymbol[]): string =>\n candidates.map((candidate) => `- ${candidate.namespace}.${candidate.name} (${candidate.kind})`).join(\"\\n\");\n\nconst buildSearchOptions = (args: ToolArgs<typeof searchApiShape>): SearchOptions => ({\n query: args.query,\n ...(args.namespace !== undefined && { namespace: args.namespace }),\n ...(args.kind !== undefined && { kinds: [args.kind] }),\n ...(args.limit !== undefined && { limit: args.limit }),\n});\n\nconst listApiResult = (reference: ReferenceApi, namespace: string | undefined): CallToolResult => {\n if (namespace === undefined) {\n return textContent(reference.overview());\n }\n\n const overview = reference.namespaceOverview(namespace);\n\n if (overview === undefined) {\n const names = reference\n .namespaces()\n .map((summary) => summary.name)\n .join(\", \");\n\n return textError(`Unknown namespace \"${namespace}\". Available namespaces: ${names}`);\n }\n\n return textContent(overview);\n};\n\nconst searchApiResult = (reference: ReferenceApi, args: ToolArgs<typeof searchApiShape>): CallToolResult => {\n const results = reference.search(buildSearchOptions(args));\n\n if (results.length === 0) {\n return textContent(`No symbols matched \"${args.query}\". Try a shorter substring or \\`gtkx_list_api\\`.`);\n }\n\n return textContent(JSON.stringify(results, null, 2));\n};\n\nconst apiDocsResult = (reference: ReferenceApi, args: ToolArgs<typeof apiDocsShape>): CallToolResult => {\n const result = reference.lookup(args.symbol, args.kind);\n\n if (result.outcome === \"notFound\") {\n return textError(`No symbol named \"${args.symbol}\". Use \\`gtkx_search_api\\` to find the right name.`);\n }\n\n if (result.outcome === \"ambiguous\") {\n return textError(\n `\"${args.symbol}\" matches several symbols. Pass a qualified name or a kind:\\n` +\n formatCandidates(result.candidates),\n );\n }\n\n return textContent(result.markdown);\n};\n\nconst listApiTool = (provider: ReferenceProvider): Tool =>\n defineTool({\n name: \"gtkx_list_api\",\n title: \"List API reference\",\n kind: \"readOnly\",\n description:\n \"List the project's generated bindings API (`@gtkx/gi` and `@gtkx/jsx`), including Adwaita, \" +\n \"GTK4, and its declared GIR libraries. Without a namespace, returns every namespace with symbol counts; \" +\n \"with a namespace, lists all of its symbols grouped by kind.\",\n inputSchema: listApiShape,\n handler: ({ namespace, projectRoot }) =>\n scopedResult(provider, projectRoot, (reference) => listApiResult(reference, namespace)),\n });\n\nconst searchApiTool = (provider: ReferenceProvider): Tool =>\n defineTool({\n name: \"gtkx_search_api\",\n title: \"Search API reference\",\n kind: \"readOnly\",\n description:\n \"Search the project's generated bindings API by symbol name. Returns matching symbols with \" +\n \"their namespace, kind, and a one-line summary; fetch full pages with `gtkx_get_api_docs`.\",\n inputSchema: searchApiShape,\n handler: (args) => scopedResult(provider, args.projectRoot, (reference) => searchApiResult(reference, args)),\n });\n\nconst getApiDocsTool = (provider: ReferenceProvider): Tool =>\n defineTool({\n name: \"gtkx_get_api_docs\",\n title: \"Get API docs\",\n kind: \"readOnly\",\n description:\n \"Get the full reference page for one symbol of the project's generated bindings: JSX elements \" +\n \"(props, signals, methods) or `@gtkx/gi` classes, interfaces, records, enums, callbacks, aliases, \" +\n \"functions, and constants.\",\n inputSchema: apiDocsShape,\n handler: (args) => scopedResult(provider, args.projectRoot, (reference) => apiDocsResult(reference, args)),\n });\n\nconst buildReferenceTools = (provider: ReferenceProvider): Tool[] => [\n listApiTool(provider),\n searchApiTool(provider),\n getApiDocsTool(provider),\n];\n\nconst markdownResource = (uri: URL, text: string): ReadResourceResult => ({\n contents: [{ uri: uri.href, mimeType: \"text/markdown\", text }],\n});\n\nconst variableValue = (value: string | string[] | undefined): string =>\n Array.isArray(value) ? (value[0] ?? \"\") : (value ?? \"\");\n\nconst withLoadFallback = async <T>(load: () => Promise<T>, fallback: T): Promise<T> => {\n try {\n return await load();\n } catch {\n return fallback;\n }\n};\n\nconst completeNames = (\n provider: ReferenceProvider,\n value: string,\n collect: (reference: ReferenceApi) => string[],\n): Promise<string[]> =>\n withLoadFallback(async () => {\n const { reference } = await provider.get();\n\n return collect(reference).filter((name) => name.toLowerCase().startsWith(value.toLowerCase()));\n }, []);\n\nconst namespaceCompleter =\n (provider: ReferenceProvider) =>\n (value: string): Promise<string[]> =>\n completeNames(provider, value, (reference) => reference.namespaces().map((summary) => summary.name));\n\nconst completeSymbol = (provider: ReferenceProvider, namespace: string, value: string): Promise<string[]> => {\n if (namespace.length === 0) {\n return Promise.resolve([]);\n }\n\n return completeNames(provider, value, (reference) => reference.symbolNames(namespace));\n};\n\nconst resourceNotFound = (message: string): McpError => new McpError(ErrorCode.InvalidParams, message);\n\nconst symbolPage = async (\n uri: URL,\n provider: ReferenceProvider,\n namespace: string,\n symbol: string,\n): Promise<ReadResourceResult> => {\n const { reference } = await provider.get();\n const result = reference.lookup(`${namespace}.${symbol}`);\n\n if (result.outcome === \"page\") {\n return markdownResource(uri, result.markdown);\n }\n\n if (result.outcome === \"ambiguous\") {\n throw resourceNotFound(\n `\"${namespace}.${symbol}\" matches several symbols:\\n${formatCandidates(result.candidates)}`,\n );\n }\n\n throw resourceNotFound(`No symbol named \"${namespace}.${symbol}\"`);\n};\n\nconst registerIndexResource = (server: ResourceServer, provider: ReferenceProvider): void => {\n server.registerResource(\n \"gtkx-api-reference\",\n \"gtkx://reference/index\",\n {\n title: \"GTKX API reference index\",\n description: \"Namespaces of the project's generated bindings, with symbol and JSX element counts.\",\n mimeType: \"text/markdown\",\n },\n async (uri) => {\n const { reference } = await provider.get();\n\n return markdownResource(uri, reference.overview());\n },\n );\n};\n\nconst registerNamespaceResource = (server: ResourceServer, provider: ReferenceProvider): void => {\n server.registerResource(\n \"gtkx-api-namespace\",\n new ResourceTemplate(\"gtkx://reference/{namespace}\", {\n list: () =>\n withLoadFallback(\n async () => {\n const { reference } = await provider.get();\n\n return {\n resources: reference.namespaces().map((summary) => ({\n uri: `gtkx://reference/${summary.name}`,\n name: `${summary.name} namespace reference`,\n mimeType: \"text/markdown\",\n })),\n };\n },\n { resources: [] },\n ),\n complete: {\n namespace: namespaceCompleter(provider),\n },\n }),\n {\n title: \"GTKX namespace reference\",\n description: \"All symbols of one namespace of the project's generated bindings, grouped by kind.\",\n mimeType: \"text/markdown\",\n },\n async (uri, variables) => {\n const namespace = variableValue(variables.namespace);\n const { reference } = await provider.get();\n const overview = reference.namespaceOverview(namespace);\n\n if (overview === undefined) {\n throw resourceNotFound(`Unknown namespace \"${namespace}\"`);\n }\n\n return markdownResource(uri, overview);\n },\n );\n};\n\nconst registerSymbolResource = (server: ResourceServer, provider: ReferenceProvider): void => {\n server.registerResource(\n \"gtkx-api-symbol\",\n new ResourceTemplate(\"gtkx://reference/{namespace}/{symbol}\", {\n list: undefined,\n complete: {\n namespace: namespaceCompleter(provider),\n symbol: (value, context) =>\n completeSymbol(provider, variableValue(context?.arguments?.namespace), value),\n },\n }),\n {\n title: \"GTKX symbol reference\",\n description:\n \"Reference page for one symbol of the project's generated bindings: a JSX element or a \" +\n \"class, interface, record, enum, callback, alias, function, or constant.\",\n mimeType: \"text/markdown\",\n },\n (uri, variables) =>\n symbolPage(uri, provider, variableValue(variables.namespace), variableValue(variables.symbol)),\n );\n};\n\nconst registerReferenceResources = (server: ResourceServer, provider: ReferenceProvider): void => {\n registerIndexResource(server, provider);\n registerNamespaceResource(server, provider);\n registerSymbolResource(server, provider);\n};\n\nexport {\n createReferenceProvider,\n buildReferenceTools,\n registerReferenceResources,\n type ReferenceProvider,\n};\n"]}
package/dist/server.js CHANGED
@@ -22,8 +22,8 @@ const INSTRUCTIONS = "The widget tools drive a GTKX app running under `gtkx dev`
22
22
  "They wait briefly for a starting app, so start `gtkx dev` before or alongside a widget request. " +
23
23
  "The reference tools answer from the " +
24
24
  "bindings generated for a specific project, so they describe that project's GIR libraries rather than " +
25
- "GTK in general; prefer them over recalled GTK knowledge, which is usually C, PyGObject or GJS and " +
26
- "does not apply here.\n\n" +
25
+ "the GNOME platform in general; prefer them over recalled Adwaita or GTK knowledge, which is usually C, " +
26
+ "PyGObject or GJS and does not apply here.\n\n" +
27
27
  "Widget IDs are valid only while the widget is mounted. After a dialog closes, a list re-renders, or " +
28
28
  "fast refresh patches a component, re-read the tree or re-run the query instead of reusing an ID.";
29
29
  const APPLICATION_ID_DESCRIPTION = "Application ID to query. If not specified, uses the first connected app. The tool waits briefly for the " +
@@ -88,7 +88,7 @@ const fireEventShape = {
88
88
  ...applicationIdShape,
89
89
  ...describeParams(fireEventParams.shape, {
90
90
  widgetId: WIDGET_ID_DESCRIPTION,
91
- signal: "GTK4 signal name to emit",
91
+ signal: "GObject signal name to emit",
92
92
  args: "Arguments to pass to the signal",
93
93
  }),
94
94
  };
@@ -267,7 +267,7 @@ function buildInteractionTools(appRouter) {
267
267
  name: "gtkx_fire_event",
268
268
  title: "Fire event",
269
269
  kind: "action",
270
- description: "Emit a GTK4 signal on a widget. Use this for custom interactions.",
270
+ description: "Emit a GObject signal on a widget. Use this for custom interactions.",
271
271
  inputSchema: fireEventShape,
272
272
  handler: async ({ applicationId, appTimeout, ...params }) => {
273
273
  const result = await appRouter.sendToApp(applicationId, "widget.fireEvent", params, appTimeout);
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAoB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAe,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM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C;AACN,CAAC,CAAC;AAEF,KAAK,UAAU,IAAI,CAAC,UAAyB,EAAE;IAC3C,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEtD,uBAAuB,CAAC;QACpB,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;KAChC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,YAAY,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { loadConfig } from \"@gtkx/config\";\nimport { type McpSettings, resolveMcpSettings } from \"@gtkx/config/internal\";\nimport { createLogger, installGracefulShutdown, type Logger } from \"@gtkx/utils\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { parseArgs } from \"node:util\";\nimport { z } from \"zod\";\nimport type { ConnectionErrorEvent } from \"./transport.js\";\nimport packageManifest from \"../package.json\" with { type: \"json\" };\nimport { type AppRegisteredEvent, AppRouter, type AppUnregisteredEvent } from \"./app-router.js\";\nimport { ConnectionRegistry } from \"./connection-registry.js\";\nimport {\n type AppInfo,\n DEFAULT_SUBTREE_DEPTH,\n fireEventParams,\n MAX_SUBTREE_WIDGETS,\n queryParams,\n screenshotParams,\n treeParams,\n typeParams,\n widgetIdParams,\n widgetPropsParams,\n} from \"./protocol/schemas.js\";\nimport {\n buildReferenceTools,\n createReferenceProvider,\n type ReferenceProvider,\n registerReferenceResources,\n} from \"./reference.js\";\nimport { resolveMcpSocketAddress } from \"./socket-path.js\";\nimport { SocketServer } from \"./socket-server.js\";\nimport { selectTools } from \"./tool-filter.js\";\nimport { defineTool, imageContent, registerTool, textContent, textError, type Tool } from \"./tool.js\";\n\ntype CreateMcpServerOptions = {\n socketPath?: string;\n version: string;\n settings?: McpSettings;\n};\n\ntype ServerOptions = {\n cwd?: string;\n tools?: string[];\n isReadOnly?: boolean;\n};\n\ntype McpServerHandle = {\n start(): Promise<void>;\n stop(): Promise<void>;\n};\n\ntype ServerLifecycle = {\n socketServer: SocketServer;\n mcpServer: McpServer;\n appRouter: AppRouter;\n socketPath: string;\n isStopRequested: boolean;\n startup: Promise<void> | null;\n shutdown: Promise<void> | null;\n};\n\ntype AppWindow = { id: string; title: string | null };\ntype AppWithWindows = AppInfo & { windows?: AppWindow[] };\n\nconst { version } = packageManifest;\nconst log: Logger = createLogger(\"mcp\");\nconst DEFAULT_SETTINGS: McpSettings = { tools: [], isReadOnly: false };\n\nconst INSTRUCTIONS =\n \"The widget tools drive a GTKX app running under `gtkx dev`: they read \" +\n \"its live widget tree, query it by accessible role and name, click and type, and capture screenshots. \" +\n \"They wait briefly for a starting app, so start `gtkx dev` before or alongside a widget request. \" +\n \"The reference tools answer from the \" +\n \"bindings generated for a specific project, so they describe that project's GIR libraries rather than \" +\n \"GTK in general; prefer them over recalled GTK knowledge, which is usually C, PyGObject or GJS and \" +\n \"does not apply here.\\n\\n\" +\n \"Widget IDs are valid only while the widget is mounted. After a dialog closes, a list re-renders, or \" +\n \"fast refresh patches a component, re-read the tree or re-run the query instead of reusing an ID.\";\n\nconst APPLICATION_ID_DESCRIPTION =\n \"Application ID to query. If not specified, uses the first connected app. The tool waits briefly for the \" +\n \"requested app to register.\";\n\nconst APP_TIMEOUT_DESCRIPTION = \"Milliseconds to wait for the requested app to register (default: 10000).\";\n\nconst WIDGET_ID_DESCRIPTION =\n \"Widget ID obtained from `gtkx_get_widget_tree`, `gtkx_query_widgets`, or `gtkx_get_widget_props`. \" +\n \"IDs are scoped to a single app. An ID stays valid for as long as its widget is mounted and stops \" +\n \"resolving once the widget is unmounted.\";\n\nconst applicationIdShape = {\n applicationId: z.string().optional().describe(APPLICATION_ID_DESCRIPTION),\n appTimeout: z.number().int().nonnegative().optional().describe(APP_TIMEOUT_DESCRIPTION),\n};\n\nconst widgetIdShape = {\n ...applicationIdShape,\n ...describeParams(widgetIdParams.shape, { widgetId: WIDGET_ID_DESCRIPTION }),\n};\n\nconst widgetPropsShape = {\n ...applicationIdShape,\n ...describeParams(widgetPropsParams.shape, {\n widgetId: WIDGET_ID_DESCRIPTION,\n properties:\n \"GObject property names to read as well, in kebab-case or camelCase (\\\"current-breakpoint\\\" or \" +\n \"\\\"currentBreakpoint\\\"). Omit for the summary alone.\",\n maxDepth:\n `How many levels of descendants to include: ${String(DEFAULT_SUBTREE_DEPTH)} by default, and 0 ` +\n `for the widget on its own. At most ${String(MAX_SUBTREE_WIDGETS)} widgets come back whatever ` +\n \"the depth, and any widget whose own direct children were left out carries a `hiddenChildren` count.\",\n }),\n};\n\nconst treeShape = {\n ...applicationIdShape,\n ...describeParams(treeParams.shape, {\n rootId:\n \"Render only the subtree rooted at this widget ID (from a prior tree or query). Omit for the \" +\n \"whole app.\",\n maxDepth:\n \"Limit how many levels deep to render, and 0 for the root widget on its own; deeper \" +\n \"descendants are summarized with a count. Combine with rootId to drill in without dumping \" +\n \"the whole tree.\",\n }),\n};\n\nconst listAppsShape = {\n waitForApps: z\n .boolean()\n .optional()\n .describe(\n \"If true, wait for at least one app to register before returning. Useful when app is still starting.\",\n ),\n timeout: z.number().optional().describe(\"Timeout in milliseconds when waitForApps is true (default: 10000)\"),\n};\n\nconst queryWidgetsShape = {\n ...applicationIdShape,\n ...describeParams(queryParams.shape, {\n by: \"Query type\",\n value: \"Value to search for\",\n options: \"Additional query options\",\n }),\n};\n\nconst typeShape = {\n ...applicationIdShape,\n ...describeParams(typeParams.shape, {\n widgetId: WIDGET_ID_DESCRIPTION,\n text: \"Text to type\",\n clear: \"Clear existing text before typing\",\n }),\n};\n\nconst fireEventShape = {\n ...applicationIdShape,\n ...describeParams(fireEventParams.shape, {\n widgetId: WIDGET_ID_DESCRIPTION,\n signal: \"GTK4 signal name to emit\",\n args: \"Arguments to pass to the signal\",\n }),\n};\n\nconst screenshotShape = {\n ...applicationIdShape,\n ...describeParams(screenshotParams.shape, {\n windowId: \"Window ID to capture. If not specified, captures the first window.\",\n path:\n \"Absolute path to write the PNG to on the app's machine. If set, the screenshot is saved there \" +\n \"in addition to being returned.\",\n }),\n returnImage: z\n .boolean()\n .optional()\n .describe(\n \"Whether to return the PNG as image content, true by default. Pass false together with `path` \" +\n \"to save the screenshot and get back only where it landed, which keeps the image out of the \" +\n \"conversation until something actually needs to look at it.\",\n ),\n};\n\nfunction describeParams<Shape extends Record<string, z.ZodType>>(\n shape: Shape,\n descriptions: { [Key in keyof Shape]: string },\n): Shape {\n const described: [string, z.ZodType][] = Object.entries(shape).map(([key, schema]) => [\n key,\n schema.describe(descriptions[key as keyof Shape]),\n ]);\n\n return Object.fromEntries(described) as Shape;\n}\n\nconst connectStdio = async (mcpServer: McpServer, stop: () => Promise<void>): Promise<void> => {\n const transport = new StdioServerTransport();\n process.stdin.on(\"end\", () => void stop());\n process.stdin.on(\"close\", () => void stop());\n await mcpServer.connect(transport);\n};\n\nconst logSocketError = (event: Event): void => {\n const error = (event as ConnectionErrorEvent).detail;\n const code = (error as NodeJS.ErrnoException).code;\n\n if (code === \"EPIPE\" || code === \"ECONNRESET\") {\n return;\n }\n\n log.error(`socket error: ${error.message}`);\n};\n\nconst appWithWindows = async (appRouter: AppRouter, app: AppInfo): Promise<AppWithWindows> => {\n try {\n const result = await appRouter.sendToApp<{ windows: AppWindow[] }>(\n app.applicationId,\n \"app.getWindows\",\n {},\n );\n\n return { ...app, windows: result.windows };\n } catch {\n return app;\n }\n};\n\nconst listAppsTool = (appRouter: AppRouter): Tool =>\n defineTool({\n name: \"gtkx_list_apps\",\n title: \"List apps\",\n kind: \"readOnly\",\n description:\n \"List connected GTKX applications and their open windows. \" +\n \"Returns the current snapshot immediately unless waitForApps is true.\",\n inputSchema: listAppsShape,\n handler: async ({ waitForApps, timeout }) => {\n if (waitForApps && !appRouter.hasConnectedApps()) {\n await appRouter.waitForApp(undefined, timeout);\n }\n\n const apps = appRouter.getApps();\n const appsWithWindows = await Promise.all(apps.map((app) => appWithWindows(appRouter, app)));\n\n return textContent(JSON.stringify(appsWithWindows, null, 2));\n },\n });\n\nconst screenshotResult = (\n result: { data: string; mimeType: string; savedPath?: string },\n shouldReturnImage: boolean,\n): CallToolResult => {\n if (result.savedPath === undefined) {\n return shouldReturnImage\n ? imageContent(result.data, result.mimeType)\n : textError(\n \"Nothing to return: `returnImage` was false and no `path` was given, so the screenshot was \" +\n \"neither saved nor returned. Pass `path` to save it, or leave `returnImage` unset.\",\n );\n }\n\n const saved = { type: \"text\", text: `Screenshot saved to ${result.savedPath}` } as const;\n\n if (!shouldReturnImage) {\n return { content: [saved] };\n }\n\n return { content: [saved, { type: \"image\", data: result.data, mimeType: result.mimeType }] };\n};\n\nconst screenshotTool = (appRouter: AppRouter): Tool =>\n defineTool({\n name: \"gtkx_take_screenshot\",\n title: \"Take screenshot\",\n kind: \"readOnly\",\n description:\n \"Capture a screenshot of a window. Returns base64-encoded PNG image data, and optionally writes \" +\n \"the PNG to `path` on the app's machine. You can't target widgets from a screenshot; use \" +\n \"`gtkx_get_widget_tree` to find widget IDs for interaction.\",\n inputSchema: screenshotShape,\n handler: async ({ applicationId, appTimeout, returnImage, ...params }) => {\n const result = await appRouter.sendToApp<{ data: string; mimeType: string; savedPath?: string }>(\n applicationId,\n \"widget.screenshot\",\n params,\n appTimeout,\n );\n\n return screenshotResult(result, returnImage !== false);\n },\n });\n\nconst widgetPropsTool = (appRouter: AppRouter): Tool =>\n defineTool({\n name: \"gtkx_get_widget_props\",\n title: \"Get widget properties\",\n kind: \"readOnly\",\n description:\n \"Get a fixed summary of one widget by ID: type, accessible role, name, text, sensitivity, \" +\n \"visibility, CSS classes, and the same summary for its descendants. The subtree is bounded \" +\n `twice: ${String(DEFAULT_SUBTREE_DEPTH)} levels deep unless \\`maxDepth\\` says otherwise, and ` +\n `${String(MAX_SUBTREE_WIDGETS)} widgets in all, filled breadth first. Wherever either bound ` +\n \"cut a branch, that widget carries `hiddenChildren`, the count of its own direct children left \" +\n \"out rather than of everything below them; call again with that widget's ID to drill in, or \" +\n \"use `gtkx_get_widget_tree` for a wider map. Pass `properties` to read GObject properties too; \" +\n \"they come back first in the payload, each under its canonical kebab-case name as \" +\n \"`{type, value}`, where an enum or flags value is its GType value name, a 64-bit integer a \" +\n \"decimal string, and an object its GType name plus `widgetId` when it is a widget. Asking for \" +\n \"a property the widget does not have fails; a value that cannot be marshalled carries a `note` \" +\n \"instead.\",\n inputSchema: widgetPropsShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n const result = await appRouter.sendToApp(applicationId, \"widget.getProps\", params, appTimeout);\n\n return textContent(JSON.stringify(result, null, 2));\n },\n });\n\nfunction buildInspectionTools(appRouter: AppRouter): Tool[] {\n return [\n listAppsTool(appRouter),\n defineTool({\n name: \"gtkx_get_widget_tree\",\n title: \"Widget tree\",\n kind: \"readOnly\",\n description:\n \"Get the widget hierarchy for a connected GTKX app. Returns a tree of widgets with their IDs, \" +\n \"types, roles, and properties. For large apps, pass `maxDepth` for a shallow overview and/or \" +\n \"`rootId` to render just one subtree instead of the whole (possibly truncated) tree.\",\n inputSchema: treeShape,\n handler: async ({ applicationId, appTimeout, rootId, maxDepth }) => {\n const result = await appRouter.sendToApp<{ tree: string }>(applicationId, \"widget.getTree\", {\n rootId,\n maxDepth,\n }, appTimeout);\n\n return textContent(result.tree);\n },\n }),\n defineTool({\n name: \"gtkx_query_widgets\",\n title: \"Query widgets\",\n kind: \"readOnly\",\n description:\n \"Find widgets by role, text, name, or label. Returns each match with its ID and the same \" +\n \"fixed summary `gtkx_get_widget_props` returns, with no descendants: a match that has \" +\n \"children carries `hiddenChildren`, the count of its direct children left out. Read a \" +\n \"match's subtree with `gtkx_get_widget_props` or `gtkx_get_widget_tree`.\",\n inputSchema: queryWidgetsShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n const result = await appRouter.sendToApp(applicationId, \"widget.query\", params, appTimeout);\n\n return textContent(JSON.stringify(result, null, 2));\n },\n }),\n widgetPropsTool(appRouter),\n screenshotTool(appRouter),\n ];\n}\n\nfunction buildInteractionTools(appRouter: AppRouter): Tool[] {\n return [\n defineTool({\n name: \"gtkx_click\",\n title: \"Click widget\",\n kind: \"action\",\n description:\n \"Click a widget through userEvent.click, with no special case per widget. Works with \" +\n \"buttons, checkboxes, switches, list and grid rows, tree expanders, and column headers: a \" +\n \"row is selected, an expander toggles its row's expansion, and a header sorts its column.\",\n inputSchema: widgetIdShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n await appRouter.sendToApp(applicationId, \"widget.click\", params, appTimeout);\n\n return textContent(\"Clicked\");\n },\n }),\n defineTool({\n name: \"gtkx_type\",\n title: \"Type text\",\n kind: \"action\",\n description: \"Type text into an editable widget like Entry or TextView\",\n inputSchema: typeShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n await appRouter.sendToApp(applicationId, \"widget.type\", params, appTimeout);\n\n return textContent(\"Typed text\");\n },\n }),\n defineTool({\n name: \"gtkx_fire_event\",\n title: \"Fire event\",\n kind: \"action\",\n description: \"Emit a GTK4 signal on a widget. Use this for custom interactions.\",\n inputSchema: fireEventShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n const result = await appRouter.sendToApp(applicationId, \"widget.fireEvent\", params, appTimeout);\n\n return textContent(JSON.stringify(result, null, 2));\n },\n }),\n ];\n}\n\nfunction buildTools(appRouter: AppRouter): Tool[] {\n return [...buildInspectionTools(appRouter), ...buildInteractionTools(appRouter)];\n}\n\nconst registerTools = (\n mcpServer: McpServer,\n appRouter: AppRouter,\n provider: ReferenceProvider,\n settings: McpSettings,\n): void => {\n const tools = selectTools([...buildTools(appRouter), ...buildReferenceTools(provider)], settings);\n\n if (tools.length === 0) {\n log.warn(\"no tools matched the configured filter; the server is registering none\");\n }\n\n for (const tool of tools) {\n registerTool(mcpServer, tool);\n }\n};\n\nconst stoppedServerError = (): Error => new Error(\"createMcpServer: a stopped server cannot be started again\");\n\nconst wasStopRequested = (state: ServerLifecycle): boolean => state.isStopRequested;\n\nfunction stopServer(state: ServerLifecycle): Promise<void> {\n if (state.shutdown !== null) {\n return state.shutdown;\n }\n\n state.isStopRequested = true;\n state.appRouter.dispose();\n const startup = state.startup;\n const shutdown = (async (): Promise<void> => {\n if (startup !== null) {\n await Promise.allSettled([startup]);\n }\n\n await state.socketServer.stop();\n await state.mcpServer.close();\n })();\n\n state.shutdown = shutdown;\n\n return shutdown;\n}\n\nfunction startServer(state: ServerLifecycle): Promise<void> {\n if (wasStopRequested(state)) {\n return Promise.reject(stoppedServerError());\n }\n\n if (state.startup !== null) {\n return state.startup;\n }\n\n const startup = (async (): Promise<void> => {\n try {\n await state.socketServer.start();\n\n if (wasStopRequested(state)) {\n return;\n }\n\n log.info(`socket server listening on ${state.socketPath}`);\n await connectStdio(state.mcpServer, () => stopServer(state));\n } catch (error) {\n if (!wasStopRequested(state)) {\n state.isStopRequested = true;\n state.appRouter.dispose();\n await state.socketServer.stop();\n await state.mcpServer.close();\n }\n\n throw error;\n }\n })();\n\n state.startup = startup;\n\n return startup;\n}\n\nconst createServerHandle = (\n socketServer: SocketServer,\n mcpServer: McpServer,\n appRouter: AppRouter,\n socketPath: string,\n): McpServerHandle => {\n const state: ServerLifecycle = {\n socketServer,\n mcpServer,\n appRouter,\n socketPath,\n isStopRequested: false,\n startup: null,\n shutdown: null,\n };\n\n return { start: () => startServer(state), stop: () => stopServer(state) };\n};\n\nconst createMcpServer = (options: CreateMcpServerOptions): McpServerHandle => {\n const socketAddress = resolveMcpSocketAddress(options.socketPath);\n const socketPath = socketAddress.path;\n\n if (socketAddress.fallbackDirectory !== null) {\n log.warn(`MCP socket path exceeds the safe Unix byte budget; using private fallback ${socketPath}`);\n }\n\n const registry = new ConnectionRegistry();\n const socketServer = new SocketServer(registry, socketAddress);\n const appRouter = new AppRouter(registry);\n registry.addEventListener(\"error\", logSocketError);\n\n appRouter.addEventListener(\"appRegistered\", (event) => {\n const appInfo = (event as AppRegisteredEvent).detail;\n log.info(`app registered: ${appInfo.applicationId} (PID: ${String(appInfo.pid)})`);\n });\n\n appRouter.addEventListener(\"appUnregistered\", (event) => {\n log.info(`app unregistered: ${(event as AppUnregisteredEvent).detail}`);\n });\n\n const mcpServer = new McpServer({ name: \"gtkx-mcp\", version: options.version }, { instructions: INSTRUCTIONS });\n const referenceProvider = createReferenceProvider({ getAppRoot: () => appRouter.getProjectRoot() });\n registerTools(mcpServer, appRouter, referenceProvider, options.settings ?? DEFAULT_SETTINGS);\n registerReferenceResources(mcpServer, referenceProvider);\n\n return createServerHandle(socketServer, mcpServer, appRouter, socketPath);\n};\n\nconst configuredSettings = async (cwd: string): Promise<McpSettings> => {\n try {\n const { config } = await loadConfig(cwd);\n\n return resolveMcpSettings(config);\n } catch {\n return DEFAULT_SETTINGS;\n }\n};\n\nconst resolveSettings = async (options: ServerOptions): Promise<McpSettings> => {\n const configured = await configuredSettings(options.cwd ?? process.cwd());\n\n return {\n tools: options.tools ?? configured.tools,\n isReadOnly: options.isReadOnly ?? configured.isReadOnly,\n };\n};\n\nconst splitPatterns = (values: string[]): string[] =>\n values.flatMap((value) => value.split(\",\")).map((value) => value.trim()).filter((value) => value.length > 0);\n\nconst parseServerArgs = (argv: string[]): ServerOptions => {\n const { values } = parseArgs({\n args: argv,\n options: {\n tools: { type: \"string\", multiple: true },\n \"read-only\": { type: \"boolean\" },\n },\n allowPositionals: false,\n });\n\n const tools = values.tools === undefined ? undefined : splitPatterns(values.tools);\n\n return {\n ...(tools !== undefined && { tools }),\n ...(values[\"read-only\"] !== undefined && { isReadOnly: values[\"read-only\"] }),\n };\n};\n\nasync function main(options: ServerOptions = {}): Promise<void> {\n const settings = await resolveSettings(options);\n const server = createMcpServer({ version, settings });\n\n installGracefulShutdown({\n onSignal: () => server.stop(),\n });\n\n await server.start();\n}\n\nexport { log, main, main as runMcpServer, parseServerArgs };\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAoB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAe,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,EAA2B,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAEH,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,cAAc,EACd,iBAAiB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,mBAAmB,EACnB,uBAAuB,EAEvB,0BAA0B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AAgCtG,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;AACpC,MAAM,GAAG,GAAW,YAAY,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AAE,QAAQ,EAAE,IAAI,EAAE;YACzC,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SACnC;QACD,gBAAgB,EAAE,KAAK;KAC1B,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEnF,OAAO;QACH,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC;QACrC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;KAChF,CAAC;AACN,CAAC,CAAC;AAEF,KAAK,UAAU,IAAI,CAAC,UAAyB,EAAE;IAC3C,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEtD,uBAAuB,CAAC;QACpB,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE;KAChC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,IAAI,YAAY,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { loadConfig } from \"@gtkx/config\";\nimport { type McpSettings, resolveMcpSettings } from \"@gtkx/config/internal\";\nimport { createLogger, installGracefulShutdown, type Logger } from \"@gtkx/utils\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { parseArgs } from \"node:util\";\nimport { z } from \"zod\";\nimport type { ConnectionErrorEvent } from \"./transport.js\";\nimport packageManifest from \"../package.json\" with { type: \"json\" };\nimport { type AppRegisteredEvent, AppRouter, type AppUnregisteredEvent } from \"./app-router.js\";\nimport { ConnectionRegistry } from \"./connection-registry.js\";\nimport {\n type AppInfo,\n DEFAULT_SUBTREE_DEPTH,\n fireEventParams,\n MAX_SUBTREE_WIDGETS,\n queryParams,\n screenshotParams,\n treeParams,\n typeParams,\n widgetIdParams,\n widgetPropsParams,\n} from \"./protocol/schemas.js\";\nimport {\n buildReferenceTools,\n createReferenceProvider,\n type ReferenceProvider,\n registerReferenceResources,\n} from \"./reference.js\";\nimport { resolveMcpSocketAddress } from \"./socket-path.js\";\nimport { SocketServer } from \"./socket-server.js\";\nimport { selectTools } from \"./tool-filter.js\";\nimport { defineTool, imageContent, registerTool, textContent, textError, type Tool } from \"./tool.js\";\n\ntype CreateMcpServerOptions = {\n socketPath?: string;\n version: string;\n settings?: McpSettings;\n};\n\ntype ServerOptions = {\n cwd?: string;\n tools?: string[];\n isReadOnly?: boolean;\n};\n\ntype McpServerHandle = {\n start(): Promise<void>;\n stop(): Promise<void>;\n};\n\ntype ServerLifecycle = {\n socketServer: SocketServer;\n mcpServer: McpServer;\n appRouter: AppRouter;\n socketPath: string;\n isStopRequested: boolean;\n startup: Promise<void> | null;\n shutdown: Promise<void> | null;\n};\n\ntype AppWindow = { id: string; title: string | null };\ntype AppWithWindows = AppInfo & { windows?: AppWindow[] };\n\nconst { version } = packageManifest;\nconst log: Logger = createLogger(\"mcp\");\nconst DEFAULT_SETTINGS: McpSettings = { tools: [], isReadOnly: false };\n\nconst INSTRUCTIONS =\n \"The widget tools drive a GTKX app running under `gtkx dev`: they read \" +\n \"its live widget tree, query it by accessible role and name, click and type, and capture screenshots. \" +\n \"They wait briefly for a starting app, so start `gtkx dev` before or alongside a widget request. \" +\n \"The reference tools answer from the \" +\n \"bindings generated for a specific project, so they describe that project's GIR libraries rather than \" +\n \"the GNOME platform in general; prefer them over recalled Adwaita or GTK knowledge, which is usually C, \" +\n \"PyGObject or GJS and does not apply here.\\n\\n\" +\n \"Widget IDs are valid only while the widget is mounted. After a dialog closes, a list re-renders, or \" +\n \"fast refresh patches a component, re-read the tree or re-run the query instead of reusing an ID.\";\n\nconst APPLICATION_ID_DESCRIPTION =\n \"Application ID to query. If not specified, uses the first connected app. The tool waits briefly for the \" +\n \"requested app to register.\";\n\nconst APP_TIMEOUT_DESCRIPTION = \"Milliseconds to wait for the requested app to register (default: 10000).\";\n\nconst WIDGET_ID_DESCRIPTION =\n \"Widget ID obtained from `gtkx_get_widget_tree`, `gtkx_query_widgets`, or `gtkx_get_widget_props`. \" +\n \"IDs are scoped to a single app. An ID stays valid for as long as its widget is mounted and stops \" +\n \"resolving once the widget is unmounted.\";\n\nconst applicationIdShape = {\n applicationId: z.string().optional().describe(APPLICATION_ID_DESCRIPTION),\n appTimeout: z.number().int().nonnegative().optional().describe(APP_TIMEOUT_DESCRIPTION),\n};\n\nconst widgetIdShape = {\n ...applicationIdShape,\n ...describeParams(widgetIdParams.shape, { widgetId: WIDGET_ID_DESCRIPTION }),\n};\n\nconst widgetPropsShape = {\n ...applicationIdShape,\n ...describeParams(widgetPropsParams.shape, {\n widgetId: WIDGET_ID_DESCRIPTION,\n properties:\n \"GObject property names to read as well, in kebab-case or camelCase (\\\"current-breakpoint\\\" or \" +\n \"\\\"currentBreakpoint\\\"). Omit for the summary alone.\",\n maxDepth:\n `How many levels of descendants to include: ${String(DEFAULT_SUBTREE_DEPTH)} by default, and 0 ` +\n `for the widget on its own. At most ${String(MAX_SUBTREE_WIDGETS)} widgets come back whatever ` +\n \"the depth, and any widget whose own direct children were left out carries a `hiddenChildren` count.\",\n }),\n};\n\nconst treeShape = {\n ...applicationIdShape,\n ...describeParams(treeParams.shape, {\n rootId:\n \"Render only the subtree rooted at this widget ID (from a prior tree or query). Omit for the \" +\n \"whole app.\",\n maxDepth:\n \"Limit how many levels deep to render, and 0 for the root widget on its own; deeper \" +\n \"descendants are summarized with a count. Combine with rootId to drill in without dumping \" +\n \"the whole tree.\",\n }),\n};\n\nconst listAppsShape = {\n waitForApps: z\n .boolean()\n .optional()\n .describe(\n \"If true, wait for at least one app to register before returning. Useful when app is still starting.\",\n ),\n timeout: z.number().optional().describe(\"Timeout in milliseconds when waitForApps is true (default: 10000)\"),\n};\n\nconst queryWidgetsShape = {\n ...applicationIdShape,\n ...describeParams(queryParams.shape, {\n by: \"Query type\",\n value: \"Value to search for\",\n options: \"Additional query options\",\n }),\n};\n\nconst typeShape = {\n ...applicationIdShape,\n ...describeParams(typeParams.shape, {\n widgetId: WIDGET_ID_DESCRIPTION,\n text: \"Text to type\",\n clear: \"Clear existing text before typing\",\n }),\n};\n\nconst fireEventShape = {\n ...applicationIdShape,\n ...describeParams(fireEventParams.shape, {\n widgetId: WIDGET_ID_DESCRIPTION,\n signal: \"GObject signal name to emit\",\n args: \"Arguments to pass to the signal\",\n }),\n};\n\nconst screenshotShape = {\n ...applicationIdShape,\n ...describeParams(screenshotParams.shape, {\n windowId: \"Window ID to capture. If not specified, captures the first window.\",\n path:\n \"Absolute path to write the PNG to on the app's machine. If set, the screenshot is saved there \" +\n \"in addition to being returned.\",\n }),\n returnImage: z\n .boolean()\n .optional()\n .describe(\n \"Whether to return the PNG as image content, true by default. Pass false together with `path` \" +\n \"to save the screenshot and get back only where it landed, which keeps the image out of the \" +\n \"conversation until something actually needs to look at it.\",\n ),\n};\n\nfunction describeParams<Shape extends Record<string, z.ZodType>>(\n shape: Shape,\n descriptions: { [Key in keyof Shape]: string },\n): Shape {\n const described: [string, z.ZodType][] = Object.entries(shape).map(([key, schema]) => [\n key,\n schema.describe(descriptions[key as keyof Shape]),\n ]);\n\n return Object.fromEntries(described) as Shape;\n}\n\nconst connectStdio = async (mcpServer: McpServer, stop: () => Promise<void>): Promise<void> => {\n const transport = new StdioServerTransport();\n process.stdin.on(\"end\", () => void stop());\n process.stdin.on(\"close\", () => void stop());\n await mcpServer.connect(transport);\n};\n\nconst logSocketError = (event: Event): void => {\n const error = (event as ConnectionErrorEvent).detail;\n const code = (error as NodeJS.ErrnoException).code;\n\n if (code === \"EPIPE\" || code === \"ECONNRESET\") {\n return;\n }\n\n log.error(`socket error: ${error.message}`);\n};\n\nconst appWithWindows = async (appRouter: AppRouter, app: AppInfo): Promise<AppWithWindows> => {\n try {\n const result = await appRouter.sendToApp<{ windows: AppWindow[] }>(\n app.applicationId,\n \"app.getWindows\",\n {},\n );\n\n return { ...app, windows: result.windows };\n } catch {\n return app;\n }\n};\n\nconst listAppsTool = (appRouter: AppRouter): Tool =>\n defineTool({\n name: \"gtkx_list_apps\",\n title: \"List apps\",\n kind: \"readOnly\",\n description:\n \"List connected GTKX applications and their open windows. \" +\n \"Returns the current snapshot immediately unless waitForApps is true.\",\n inputSchema: listAppsShape,\n handler: async ({ waitForApps, timeout }) => {\n if (waitForApps && !appRouter.hasConnectedApps()) {\n await appRouter.waitForApp(undefined, timeout);\n }\n\n const apps = appRouter.getApps();\n const appsWithWindows = await Promise.all(apps.map((app) => appWithWindows(appRouter, app)));\n\n return textContent(JSON.stringify(appsWithWindows, null, 2));\n },\n });\n\nconst screenshotResult = (\n result: { data: string; mimeType: string; savedPath?: string },\n shouldReturnImage: boolean,\n): CallToolResult => {\n if (result.savedPath === undefined) {\n return shouldReturnImage\n ? imageContent(result.data, result.mimeType)\n : textError(\n \"Nothing to return: `returnImage` was false and no `path` was given, so the screenshot was \" +\n \"neither saved nor returned. Pass `path` to save it, or leave `returnImage` unset.\",\n );\n }\n\n const saved = { type: \"text\", text: `Screenshot saved to ${result.savedPath}` } as const;\n\n if (!shouldReturnImage) {\n return { content: [saved] };\n }\n\n return { content: [saved, { type: \"image\", data: result.data, mimeType: result.mimeType }] };\n};\n\nconst screenshotTool = (appRouter: AppRouter): Tool =>\n defineTool({\n name: \"gtkx_take_screenshot\",\n title: \"Take screenshot\",\n kind: \"readOnly\",\n description:\n \"Capture a screenshot of a window. Returns base64-encoded PNG image data, and optionally writes \" +\n \"the PNG to `path` on the app's machine. You can't target widgets from a screenshot; use \" +\n \"`gtkx_get_widget_tree` to find widget IDs for interaction.\",\n inputSchema: screenshotShape,\n handler: async ({ applicationId, appTimeout, returnImage, ...params }) => {\n const result = await appRouter.sendToApp<{ data: string; mimeType: string; savedPath?: string }>(\n applicationId,\n \"widget.screenshot\",\n params,\n appTimeout,\n );\n\n return screenshotResult(result, returnImage !== false);\n },\n });\n\nconst widgetPropsTool = (appRouter: AppRouter): Tool =>\n defineTool({\n name: \"gtkx_get_widget_props\",\n title: \"Get widget properties\",\n kind: \"readOnly\",\n description:\n \"Get a fixed summary of one widget by ID: type, accessible role, name, text, sensitivity, \" +\n \"visibility, CSS classes, and the same summary for its descendants. The subtree is bounded \" +\n `twice: ${String(DEFAULT_SUBTREE_DEPTH)} levels deep unless \\`maxDepth\\` says otherwise, and ` +\n `${String(MAX_SUBTREE_WIDGETS)} widgets in all, filled breadth first. Wherever either bound ` +\n \"cut a branch, that widget carries `hiddenChildren`, the count of its own direct children left \" +\n \"out rather than of everything below them; call again with that widget's ID to drill in, or \" +\n \"use `gtkx_get_widget_tree` for a wider map. Pass `properties` to read GObject properties too; \" +\n \"they come back first in the payload, each under its canonical kebab-case name as \" +\n \"`{type, value}`, where an enum or flags value is its GType value name, a 64-bit integer a \" +\n \"decimal string, and an object its GType name plus `widgetId` when it is a widget. Asking for \" +\n \"a property the widget does not have fails; a value that cannot be marshalled carries a `note` \" +\n \"instead.\",\n inputSchema: widgetPropsShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n const result = await appRouter.sendToApp(applicationId, \"widget.getProps\", params, appTimeout);\n\n return textContent(JSON.stringify(result, null, 2));\n },\n });\n\nfunction buildInspectionTools(appRouter: AppRouter): Tool[] {\n return [\n listAppsTool(appRouter),\n defineTool({\n name: \"gtkx_get_widget_tree\",\n title: \"Widget tree\",\n kind: \"readOnly\",\n description:\n \"Get the widget hierarchy for a connected GTKX app. Returns a tree of widgets with their IDs, \" +\n \"types, roles, and properties. For large apps, pass `maxDepth` for a shallow overview and/or \" +\n \"`rootId` to render just one subtree instead of the whole (possibly truncated) tree.\",\n inputSchema: treeShape,\n handler: async ({ applicationId, appTimeout, rootId, maxDepth }) => {\n const result = await appRouter.sendToApp<{ tree: string }>(applicationId, \"widget.getTree\", {\n rootId,\n maxDepth,\n }, appTimeout);\n\n return textContent(result.tree);\n },\n }),\n defineTool({\n name: \"gtkx_query_widgets\",\n title: \"Query widgets\",\n kind: \"readOnly\",\n description:\n \"Find widgets by role, text, name, or label. Returns each match with its ID and the same \" +\n \"fixed summary `gtkx_get_widget_props` returns, with no descendants: a match that has \" +\n \"children carries `hiddenChildren`, the count of its direct children left out. Read a \" +\n \"match's subtree with `gtkx_get_widget_props` or `gtkx_get_widget_tree`.\",\n inputSchema: queryWidgetsShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n const result = await appRouter.sendToApp(applicationId, \"widget.query\", params, appTimeout);\n\n return textContent(JSON.stringify(result, null, 2));\n },\n }),\n widgetPropsTool(appRouter),\n screenshotTool(appRouter),\n ];\n}\n\nfunction buildInteractionTools(appRouter: AppRouter): Tool[] {\n return [\n defineTool({\n name: \"gtkx_click\",\n title: \"Click widget\",\n kind: \"action\",\n description:\n \"Click a widget through userEvent.click, with no special case per widget. Works with \" +\n \"buttons, checkboxes, switches, list and grid rows, tree expanders, and column headers: a \" +\n \"row is selected, an expander toggles its row's expansion, and a header sorts its column.\",\n inputSchema: widgetIdShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n await appRouter.sendToApp(applicationId, \"widget.click\", params, appTimeout);\n\n return textContent(\"Clicked\");\n },\n }),\n defineTool({\n name: \"gtkx_type\",\n title: \"Type text\",\n kind: \"action\",\n description: \"Type text into an editable widget like Entry or TextView\",\n inputSchema: typeShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n await appRouter.sendToApp(applicationId, \"widget.type\", params, appTimeout);\n\n return textContent(\"Typed text\");\n },\n }),\n defineTool({\n name: \"gtkx_fire_event\",\n title: \"Fire event\",\n kind: \"action\",\n description: \"Emit a GObject signal on a widget. Use this for custom interactions.\",\n inputSchema: fireEventShape,\n handler: async ({ applicationId, appTimeout, ...params }) => {\n const result = await appRouter.sendToApp(applicationId, \"widget.fireEvent\", params, appTimeout);\n\n return textContent(JSON.stringify(result, null, 2));\n },\n }),\n ];\n}\n\nfunction buildTools(appRouter: AppRouter): Tool[] {\n return [...buildInspectionTools(appRouter), ...buildInteractionTools(appRouter)];\n}\n\nconst registerTools = (\n mcpServer: McpServer,\n appRouter: AppRouter,\n provider: ReferenceProvider,\n settings: McpSettings,\n): void => {\n const tools = selectTools([...buildTools(appRouter), ...buildReferenceTools(provider)], settings);\n\n if (tools.length === 0) {\n log.warn(\"no tools matched the configured filter; the server is registering none\");\n }\n\n for (const tool of tools) {\n registerTool(mcpServer, tool);\n }\n};\n\nconst stoppedServerError = (): Error => new Error(\"createMcpServer: a stopped server cannot be started again\");\n\nconst wasStopRequested = (state: ServerLifecycle): boolean => state.isStopRequested;\n\nfunction stopServer(state: ServerLifecycle): Promise<void> {\n if (state.shutdown !== null) {\n return state.shutdown;\n }\n\n state.isStopRequested = true;\n state.appRouter.dispose();\n const startup = state.startup;\n const shutdown = (async (): Promise<void> => {\n if (startup !== null) {\n await Promise.allSettled([startup]);\n }\n\n await state.socketServer.stop();\n await state.mcpServer.close();\n })();\n\n state.shutdown = shutdown;\n\n return shutdown;\n}\n\nfunction startServer(state: ServerLifecycle): Promise<void> {\n if (wasStopRequested(state)) {\n return Promise.reject(stoppedServerError());\n }\n\n if (state.startup !== null) {\n return state.startup;\n }\n\n const startup = (async (): Promise<void> => {\n try {\n await state.socketServer.start();\n\n if (wasStopRequested(state)) {\n return;\n }\n\n log.info(`socket server listening on ${state.socketPath}`);\n await connectStdio(state.mcpServer, () => stopServer(state));\n } catch (error) {\n if (!wasStopRequested(state)) {\n state.isStopRequested = true;\n state.appRouter.dispose();\n await state.socketServer.stop();\n await state.mcpServer.close();\n }\n\n throw error;\n }\n })();\n\n state.startup = startup;\n\n return startup;\n}\n\nconst createServerHandle = (\n socketServer: SocketServer,\n mcpServer: McpServer,\n appRouter: AppRouter,\n socketPath: string,\n): McpServerHandle => {\n const state: ServerLifecycle = {\n socketServer,\n mcpServer,\n appRouter,\n socketPath,\n isStopRequested: false,\n startup: null,\n shutdown: null,\n };\n\n return { start: () => startServer(state), stop: () => stopServer(state) };\n};\n\nconst createMcpServer = (options: CreateMcpServerOptions): McpServerHandle => {\n const socketAddress = resolveMcpSocketAddress(options.socketPath);\n const socketPath = socketAddress.path;\n\n if (socketAddress.fallbackDirectory !== null) {\n log.warn(`MCP socket path exceeds the safe Unix byte budget; using private fallback ${socketPath}`);\n }\n\n const registry = new ConnectionRegistry();\n const socketServer = new SocketServer(registry, socketAddress);\n const appRouter = new AppRouter(registry);\n registry.addEventListener(\"error\", logSocketError);\n\n appRouter.addEventListener(\"appRegistered\", (event) => {\n const appInfo = (event as AppRegisteredEvent).detail;\n log.info(`app registered: ${appInfo.applicationId} (PID: ${String(appInfo.pid)})`);\n });\n\n appRouter.addEventListener(\"appUnregistered\", (event) => {\n log.info(`app unregistered: ${(event as AppUnregisteredEvent).detail}`);\n });\n\n const mcpServer = new McpServer({ name: \"gtkx-mcp\", version: options.version }, { instructions: INSTRUCTIONS });\n const referenceProvider = createReferenceProvider({ getAppRoot: () => appRouter.getProjectRoot() });\n registerTools(mcpServer, appRouter, referenceProvider, options.settings ?? DEFAULT_SETTINGS);\n registerReferenceResources(mcpServer, referenceProvider);\n\n return createServerHandle(socketServer, mcpServer, appRouter, socketPath);\n};\n\nconst configuredSettings = async (cwd: string): Promise<McpSettings> => {\n try {\n const { config } = await loadConfig(cwd);\n\n return resolveMcpSettings(config);\n } catch {\n return DEFAULT_SETTINGS;\n }\n};\n\nconst resolveSettings = async (options: ServerOptions): Promise<McpSettings> => {\n const configured = await configuredSettings(options.cwd ?? process.cwd());\n\n return {\n tools: options.tools ?? configured.tools,\n isReadOnly: options.isReadOnly ?? configured.isReadOnly,\n };\n};\n\nconst splitPatterns = (values: string[]): string[] =>\n values.flatMap((value) => value.split(\",\")).map((value) => value.trim()).filter((value) => value.length > 0);\n\nconst parseServerArgs = (argv: string[]): ServerOptions => {\n const { values } = parseArgs({\n args: argv,\n options: {\n tools: { type: \"string\", multiple: true },\n \"read-only\": { type: \"boolean\" },\n },\n allowPositionals: false,\n });\n\n const tools = values.tools === undefined ? undefined : splitPatterns(values.tools);\n\n return {\n ...(tools !== undefined && { tools }),\n ...(values[\"read-only\"] !== undefined && { isReadOnly: values[\"read-only\"] }),\n };\n};\n\nasync function main(options: ServerOptions = {}): Promise<void> {\n const settings = await resolveSettings(options);\n const server = createMcpServer({ version, settings });\n\n installGracefulShutdown({\n onSignal: () => server.stop(),\n });\n\n await server.start();\n}\n\nexport { log, main, main as runMcpServer, parseServerArgs };\n"]}
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@gtkx/mcp",
3
- "version": "2.0.0-beta.6",
4
- "description": "MCP server exposing the GTK API reference and a running GTK4 app.",
3
+ "version": "2.0.0-beta.8",
4
+ "description": "MCP server for GTKX GNOME references and live Adwaita apps.",
5
5
  "keywords": [
6
6
  "gtkx",
7
7
  "gtk",
8
8
  "gtk4",
9
+ "adwaita",
10
+ "gnome",
9
11
  "mcp",
10
12
  "model-context-protocol",
11
13
  "ai",
@@ -63,15 +65,15 @@
63
65
  "node": ">=26.7.0"
64
66
  },
65
67
  "dependencies": {
66
- "@gtkx/codegen": "2.0.0-beta.6",
67
- "@gtkx/config": "2.0.0-beta.6",
68
- "@gtkx/utils": "2.0.0-beta.6",
68
+ "@gtkx/codegen": "2.0.0-beta.8",
69
+ "@gtkx/config": "2.0.0-beta.8",
70
+ "@gtkx/utils": "2.0.0-beta.8",
69
71
  "@modelcontextprotocol/sdk": "^1.30.0",
70
72
  "zod": "^4.5.4"
71
73
  },
72
74
  "devDependencies": {
73
- "@gtkx/vitest": "2.0.0-beta.6",
74
- "vitest": "^4.1.11"
75
+ "@gtkx/vitest": "2.0.0-beta.8",
76
+ "vitest": "^5.0.0"
75
77
  },
76
78
  "scripts": {
77
79
  "release": "tsx ../../scripts/release-package.ts"
package/src/reference.ts CHANGED
@@ -79,8 +79,8 @@ const SYMBOL_KIND = z.enum([
79
79
  ]);
80
80
 
81
81
  const SYMBOL_DESCRIPTION =
82
- "Qualified symbol name (`Gtk.Button`, `Gtk.Orientation`, `GLib.idleAdd`), JSX element name (`GtkButton`), " +
83
- "or bare symbol name when unambiguous (`Button`).";
82
+ "Qualified symbol name (`Adw.Toast`, `Gtk.Orientation`, `GLib.idleAdd`), JSX element name (`AdwToast`), " +
83
+ "or bare symbol name when unambiguous (`Toast`).";
84
84
 
85
85
  const PROJECT_ROOT_DESCRIPTION =
86
86
  "Directory of the GTKX project whose bindings to document, absolute or relative to the working directory. " +
@@ -96,13 +96,13 @@ const listApiShape = {
96
96
  namespace: z
97
97
  .string()
98
98
  .optional()
99
- .describe("Namespace to list (e.g. `Gtk`, `Adw`, `Gio`). Omit for an overview of all namespaces."),
99
+ .describe("Namespace to list (e.g. `Adw`, `Gtk`, `Gio`). Omit for an overview of all namespaces."),
100
100
  };
101
101
 
102
102
  const searchApiShape = {
103
103
  ...projectRootShape,
104
104
  query: z.string().describe("Case-insensitive substring of a symbol name, e.g. `headerbar` or `orientation`."),
105
- namespace: z.string().optional().describe("Restrict matches to one namespace (e.g. `Gtk`)."),
105
+ namespace: z.string().optional().describe("Restrict matches to one namespace (e.g. `Adw`)."),
106
106
  kind: SYMBOL_KIND.optional().describe("Restrict matches to one symbol kind."),
107
107
  limit: z.number().int().min(1).optional().describe("Maximum number of results (default: 20)."),
108
108
  };
@@ -354,8 +354,9 @@ const listApiTool = (provider: ReferenceProvider): Tool =>
354
354
  title: "List API reference",
355
355
  kind: "readOnly",
356
356
  description:
357
- "List the project's generated GTK4 bindings API (`@gtkx/gi` and `@gtkx/jsx`). Without a namespace, " +
358
- "returns every namespace with symbol counts; with a namespace, lists all of its symbols grouped by kind.",
357
+ "List the project's generated bindings API (`@gtkx/gi` and `@gtkx/jsx`), including Adwaita, " +
358
+ "GTK4, and its declared GIR libraries. Without a namespace, returns every namespace with symbol counts; " +
359
+ "with a namespace, lists all of its symbols grouped by kind.",
359
360
  inputSchema: listApiShape,
360
361
  handler: ({ namespace, projectRoot }) =>
361
362
  scopedResult(provider, projectRoot, (reference) => listApiResult(reference, namespace)),
@@ -367,7 +368,7 @@ const searchApiTool = (provider: ReferenceProvider): Tool =>
367
368
  title: "Search API reference",
368
369
  kind: "readOnly",
369
370
  description:
370
- "Search the project's generated GTK4 bindings API by symbol name. Returns matching symbols with " +
371
+ "Search the project's generated bindings API by symbol name. Returns matching symbols with " +
371
372
  "their namespace, kind, and a one-line summary; fetch full pages with `gtkx_get_api_docs`.",
372
373
  inputSchema: searchApiShape,
373
374
  handler: (args) => scopedResult(provider, args.projectRoot, (reference) => searchApiResult(reference, args)),
@@ -379,7 +380,7 @@ const getApiDocsTool = (provider: ReferenceProvider): Tool =>
379
380
  title: "Get API docs",
380
381
  kind: "readOnly",
381
382
  description:
382
- "Get the full reference page for one symbol of the project's generated GTK4 bindings: JSX elements " +
383
+ "Get the full reference page for one symbol of the project's generated bindings: JSX elements " +
383
384
  "(props, signals, methods) or `@gtkx/gi` classes, interfaces, records, enums, callbacks, aliases, " +
384
385
  "functions, and constants.",
385
386
  inputSchema: apiDocsShape,
@@ -461,7 +462,7 @@ const registerIndexResource = (server: ResourceServer, provider: ReferenceProvid
461
462
  "gtkx://reference/index",
462
463
  {
463
464
  title: "GTKX API reference index",
464
- description: "Namespaces of the project's generated GTK4 bindings, with symbol and JSX element counts.",
465
+ description: "Namespaces of the project's generated bindings, with symbol and JSX element counts.",
465
466
  mimeType: "text/markdown",
466
467
  },
467
468
  async (uri) => {
@@ -497,7 +498,7 @@ const registerNamespaceResource = (server: ResourceServer, provider: ReferencePr
497
498
  }),
498
499
  {
499
500
  title: "GTKX namespace reference",
500
- description: "All symbols of one namespace of the project's generated GTK4 bindings, grouped by kind.",
501
+ description: "All symbols of one namespace of the project's generated bindings, grouped by kind.",
501
502
  mimeType: "text/markdown",
502
503
  },
503
504
  async (uri, variables) => {
@@ -528,7 +529,7 @@ const registerSymbolResource = (server: ResourceServer, provider: ReferenceProvi
528
529
  {
529
530
  title: "GTKX symbol reference",
530
531
  description:
531
- "Reference page for one symbol of the project's generated GTK4 bindings: a JSX element or a " +
532
+ "Reference page for one symbol of the project's generated bindings: a JSX element or a " +
532
533
  "class, interface, record, enum, callback, alias, function, or constant.",
533
534
  mimeType: "text/markdown",
534
535
  },
package/src/server.ts CHANGED
@@ -73,8 +73,8 @@ const INSTRUCTIONS =
73
73
  "They wait briefly for a starting app, so start `gtkx dev` before or alongside a widget request. " +
74
74
  "The reference tools answer from the " +
75
75
  "bindings generated for a specific project, so they describe that project's GIR libraries rather than " +
76
- "GTK in general; prefer them over recalled GTK knowledge, which is usually C, PyGObject or GJS and " +
77
- "does not apply here.\n\n" +
76
+ "the GNOME platform in general; prefer them over recalled Adwaita or GTK knowledge, which is usually C, " +
77
+ "PyGObject or GJS and does not apply here.\n\n" +
78
78
  "Widget IDs are valid only while the widget is mounted. After a dialog closes, a list re-renders, or " +
79
79
  "fast refresh patches a component, re-read the tree or re-run the query instead of reusing an ID.";
80
80
 
@@ -158,7 +158,7 @@ const fireEventShape = {
158
158
  ...applicationIdShape,
159
159
  ...describeParams(fireEventParams.shape, {
160
160
  widgetId: WIDGET_ID_DESCRIPTION,
161
- signal: "GTK4 signal name to emit",
161
+ signal: "GObject signal name to emit",
162
162
  args: "Arguments to pass to the signal",
163
163
  }),
164
164
  };
@@ -391,7 +391,7 @@ function buildInteractionTools(appRouter: AppRouter): Tool[] {
391
391
  name: "gtkx_fire_event",
392
392
  title: "Fire event",
393
393
  kind: "action",
394
- description: "Emit a GTK4 signal on a widget. Use this for custom interactions.",
394
+ description: "Emit a GObject signal on a widget. Use this for custom interactions.",
395
395
  inputSchema: fireEventShape,
396
396
  handler: async ({ applicationId, appTimeout, ...params }) => {
397
397
  const result = await appRouter.sendToApp(applicationId, "widget.fireEvent", params, appTimeout);