@gtkx/mcp 0.20.0 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +122 -55
  2. package/bin/gtkx-mcp.js +8 -1
  3. package/dist/app-router.d.ts +35 -0
  4. package/dist/app-router.d.ts.map +1 -0
  5. package/dist/app-router.js +130 -0
  6. package/dist/app-router.js.map +1 -0
  7. package/dist/connection-registry.d.ts +12 -0
  8. package/dist/connection-registry.d.ts.map +1 -0
  9. package/dist/connection-registry.js +38 -0
  10. package/dist/connection-registry.js.map +1 -0
  11. package/dist/internal.d.ts +4 -0
  12. package/dist/internal.d.ts.map +1 -0
  13. package/dist/internal.js +4 -0
  14. package/dist/internal.js.map +1 -0
  15. package/dist/protocol/errors.d.ts +24 -87
  16. package/dist/protocol/errors.d.ts.map +1 -1
  17. package/dist/protocol/errors.js +27 -91
  18. package/dist/protocol/errors.js.map +1 -1
  19. package/dist/protocol/schemas.d.ts +89 -0
  20. package/dist/protocol/schemas.d.ts.map +1 -0
  21. package/dist/protocol/schemas.js +56 -0
  22. package/dist/protocol/schemas.js.map +1 -0
  23. package/dist/reference.d.ts +13 -0
  24. package/dist/reference.d.ts.map +1 -0
  25. package/dist/reference.js +250 -0
  26. package/dist/reference.js.map +1 -0
  27. package/dist/server.d.ts +14 -0
  28. package/dist/server.d.ts.map +1 -0
  29. package/dist/server.js +220 -0
  30. package/dist/server.js.map +1 -0
  31. package/dist/socket-server.d.ts +4 -38
  32. package/dist/socket-server.d.ts.map +1 -1
  33. package/dist/socket-server.js +26 -109
  34. package/dist/socket-server.js.map +1 -1
  35. package/dist/tool.d.ts +22 -0
  36. package/dist/tool.d.ts.map +1 -0
  37. package/dist/tool.js +36 -0
  38. package/dist/tool.js.map +1 -0
  39. package/dist/transport.d.ts +41 -0
  40. package/dist/transport.d.ts.map +1 -0
  41. package/dist/transport.js +121 -0
  42. package/dist/transport.js.map +1 -0
  43. package/package.json +17 -11
  44. package/src/app-router.ts +172 -0
  45. package/src/connection-registry.ts +42 -0
  46. package/src/internal.ts +17 -0
  47. package/src/protocol/errors.ts +44 -100
  48. package/src/protocol/schemas.ts +148 -0
  49. package/src/reference.ts +340 -0
  50. package/src/server.ts +281 -0
  51. package/src/socket-server.ts +30 -154
  52. package/src/tool.ts +66 -0
  53. package/src/transport.ts +165 -0
  54. package/dist/cli.d.ts +0 -3
  55. package/dist/cli.d.ts.map +0 -1
  56. package/dist/cli.js +0 -399
  57. package/dist/cli.js.map +0 -1
  58. package/dist/connection-manager.d.ts +0 -48
  59. package/dist/connection-manager.d.ts.map +0 -1
  60. package/dist/connection-manager.js +0 -185
  61. package/dist/connection-manager.js.map +0 -1
  62. package/dist/index.d.ts +0 -5
  63. package/dist/index.d.ts.map +0 -1
  64. package/dist/index.js +0 -5
  65. package/dist/index.js.map +0 -1
  66. package/dist/protocol/types.d.ts +0 -132
  67. package/dist/protocol/types.d.ts.map +0 -1
  68. package/dist/protocol/types.js +0 -46
  69. package/dist/protocol/types.js.map +0 -1
  70. package/src/cli.ts +0 -449
  71. package/src/connection-manager.ts +0 -247
  72. package/src/index.ts +0 -27
  73. package/src/protocol/types.ts +0 -153
@@ -1,93 +1,30 @@
1
- /**
2
- * Error codes for MCP protocol errors.
3
- */
4
- export declare enum McpErrorCode {
5
- /** Internal server error */
6
- INTERNAL_ERROR = 1000,
7
- /** No GTKX application is connected */
8
- NO_APP_CONNECTED = 1001,
9
- /** Requested application ID was not found */
10
- APP_NOT_FOUND = 1002,
11
- /** Widget with specified ID was not found */
12
- WIDGET_NOT_FOUND = 1003,
13
- /** Widget cannot be interacted with */
14
- WIDGET_NOT_INTERACTABLE = 1004,
15
- /** Query timed out waiting for widget */
16
- QUERY_TIMEOUT = 1005,
17
- /** Widget is not the expected type */
18
- INVALID_WIDGET_TYPE = 1006,
19
- /** Screenshot capture failed */
20
- SCREENSHOT_FAILED = 1007,
21
- /** IPC request timed out */
22
- IPC_TIMEOUT = 1008,
23
- /** Failed to serialize data */
24
- SERIALIZATION_ERROR = 1009,
25
- /** Request format is invalid */
26
- INVALID_REQUEST = 1010,
27
- /** Requested method does not exist */
28
- METHOD_NOT_FOUND = 1011
29
- }
30
- /**
31
- * Error class for MCP protocol errors.
32
- *
33
- * Contains an error code, message, and optional additional data.
34
- */
35
- export declare class McpError extends Error {
36
- /** The MCP error code */
37
- readonly code: McpErrorCode;
38
- /** Additional error context */
39
- readonly data?: unknown;
40
- constructor(code: McpErrorCode, message: string, data?: unknown);
41
- /**
42
- * Converts the error to an IPC-compatible format.
43
- *
44
- * @returns Object suitable for IPC response error field
45
- */
46
- toIpcError(): {
1
+ export declare const ErrorCode: {
2
+ readonly INTERNAL_ERROR: 1000;
3
+ readonly NO_APP_CONNECTED: 1001;
4
+ readonly APP_NOT_FOUND: 1002;
5
+ readonly WIDGET_NOT_FOUND: 1003;
6
+ readonly CONNECTION_WRITE_FAILED: 1004;
7
+ readonly REQUEST_TIMEOUT: 1005;
8
+ readonly INVALID_REQUEST: 1006;
9
+ readonly METHOD_NOT_FOUND: 1007;
10
+ };
11
+ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
12
+ export declare function isErrorCode(code: number): code is ErrorCode;
13
+ export declare class ProtocolError extends Error {
14
+ code: ErrorCode;
15
+ data?: unknown;
16
+ constructor(code: ErrorCode, message: string, data?: unknown);
17
+ toErrorObject(): {
47
18
  code: number;
48
19
  message: string;
49
20
  data?: unknown;
50
21
  };
51
22
  }
52
- /**
53
- * Creates an error for when no GTKX application is connected.
54
- *
55
- * @returns McpError with NO_APP_CONNECTED code
56
- */
57
- export declare function noAppConnectedError(): McpError;
58
- /**
59
- * Creates an error for when a requested app is not found.
60
- *
61
- * @param appId - The application ID that was not found
62
- * @returns McpError with APP_NOT_FOUND code
63
- */
64
- export declare function appNotFoundError(appId: string): McpError;
65
- /**
66
- * Creates an error for when a widget is not found.
67
- *
68
- * @param widgetId - The widget ID that was not found
69
- * @returns McpError with WIDGET_NOT_FOUND code
70
- */
71
- export declare function widgetNotFoundError(widgetId: string): McpError;
72
- /**
73
- * Creates an error for when an IPC request times out.
74
- *
75
- * @param timeout - The timeout duration in milliseconds
76
- * @returns McpError with IPC_TIMEOUT code
77
- */
78
- export declare function ipcTimeoutError(timeout: number): McpError;
79
- /**
80
- * Creates an error for invalid request format.
81
- *
82
- * @param reason - Description of why the request is invalid
83
- * @returns McpError with INVALID_REQUEST code
84
- */
85
- export declare function invalidRequestError(reason: string): McpError;
86
- /**
87
- * Creates an error for when a method is not found.
88
- *
89
- * @param method - The method name that was not found
90
- * @returns McpError with METHOD_NOT_FOUND code
91
- */
92
- export declare function methodNotFoundError(method: string): McpError;
23
+ export declare function noAppConnectedError(): ProtocolError;
24
+ export declare function appNotFoundError(applicationId: string): ProtocolError;
25
+ export declare function connectionWriteFailedError(applicationId: string): ProtocolError;
26
+ export declare function widgetNotFoundError(widgetId: string): ProtocolError;
27
+ export declare function requestTimeoutError(timeout: number): ProtocolError;
28
+ export declare function invalidRequestError(reason: string): ProtocolError;
29
+ export declare function methodNotFoundError(method: string): ProtocolError;
93
30
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,YAAY;IACpB,4BAA4B;IAC5B,cAAc,OAAO;IACrB,uCAAuC;IACvC,gBAAgB,OAAO;IACvB,6CAA6C;IAC7C,aAAa,OAAO;IACpB,6CAA6C;IAC7C,gBAAgB,OAAO;IACvB,uCAAuC;IACvC,uBAAuB,OAAO;IAC9B,yCAAyC;IACzC,aAAa,OAAO;IACpB,sCAAsC;IACtC,mBAAmB,OAAO;IAC1B,gCAAgC;IAChC,iBAAiB,OAAO;IACxB,4BAA4B;IAC5B,WAAW,OAAO;IAClB,+BAA+B;IAC/B,mBAAmB,OAAO;IAC1B,gCAAgC;IAChC,eAAe,OAAO;I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SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEnE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,SAAS,CAE3D;AAED,qBAAa,aAAc,SAAQ,KAAK;IACpC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,YAAY,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAK3D;IAED,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAMjE;CACJ;AAED,wBAAgB,mBAAmB,IAAI,aAAa,CAMnD;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAErE;AAED,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAM/E;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAEnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAElE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAEjE"}
@@ -1,58 +1,26 @@
1
- /**
2
- * Error codes for MCP protocol errors.
3
- */
4
- export var McpErrorCode;
5
- (function (McpErrorCode) {
6
- /** Internal server error */
7
- McpErrorCode[McpErrorCode["INTERNAL_ERROR"] = 1000] = "INTERNAL_ERROR";
8
- /** No GTKX application is connected */
9
- McpErrorCode[McpErrorCode["NO_APP_CONNECTED"] = 1001] = "NO_APP_CONNECTED";
10
- /** Requested application ID was not found */
11
- McpErrorCode[McpErrorCode["APP_NOT_FOUND"] = 1002] = "APP_NOT_FOUND";
12
- /** Widget with specified ID was not found */
13
- McpErrorCode[McpErrorCode["WIDGET_NOT_FOUND"] = 1003] = "WIDGET_NOT_FOUND";
14
- /** Widget cannot be interacted with */
15
- McpErrorCode[McpErrorCode["WIDGET_NOT_INTERACTABLE"] = 1004] = "WIDGET_NOT_INTERACTABLE";
16
- /** Query timed out waiting for widget */
17
- McpErrorCode[McpErrorCode["QUERY_TIMEOUT"] = 1005] = "QUERY_TIMEOUT";
18
- /** Widget is not the expected type */
19
- McpErrorCode[McpErrorCode["INVALID_WIDGET_TYPE"] = 1006] = "INVALID_WIDGET_TYPE";
20
- /** Screenshot capture failed */
21
- McpErrorCode[McpErrorCode["SCREENSHOT_FAILED"] = 1007] = "SCREENSHOT_FAILED";
22
- /** IPC request timed out */
23
- McpErrorCode[McpErrorCode["IPC_TIMEOUT"] = 1008] = "IPC_TIMEOUT";
24
- /** Failed to serialize data */
25
- McpErrorCode[McpErrorCode["SERIALIZATION_ERROR"] = 1009] = "SERIALIZATION_ERROR";
26
- /** Request format is invalid */
27
- McpErrorCode[McpErrorCode["INVALID_REQUEST"] = 1010] = "INVALID_REQUEST";
28
- /** Requested method does not exist */
29
- McpErrorCode[McpErrorCode["METHOD_NOT_FOUND"] = 1011] = "METHOD_NOT_FOUND";
30
- })(McpErrorCode || (McpErrorCode = {}));
31
- /**
32
- * Error class for MCP protocol errors.
33
- *
34
- * Contains an error code, message, and optional additional data.
35
- */
36
- export class McpError extends Error {
37
- /** The MCP error code */
1
+ export const ErrorCode = {
2
+ INTERNAL_ERROR: 1000,
3
+ NO_APP_CONNECTED: 1001,
4
+ APP_NOT_FOUND: 1002,
5
+ WIDGET_NOT_FOUND: 1003,
6
+ CONNECTION_WRITE_FAILED: 1004,
7
+ REQUEST_TIMEOUT: 1005,
8
+ INVALID_REQUEST: 1006,
9
+ METHOD_NOT_FOUND: 1007,
10
+ };
11
+ export function isErrorCode(code) {
12
+ return Object.values(ErrorCode).includes(code);
13
+ }
14
+ export class ProtocolError extends Error {
38
15
  code;
39
- /** Additional error context */
40
16
  data;
41
17
  constructor(code, message, data) {
42
18
  super(message);
43
19
  this.code = code;
44
20
  this.data = data;
45
- this.name = "McpError";
46
- if (Error.captureStackTrace) {
47
- Error.captureStackTrace(this, McpError);
48
- }
21
+ this.name = "ProtocolError";
49
22
  }
50
- /**
51
- * Converts the error to an IPC-compatible format.
52
- *
53
- * @returns Object suitable for IPC response error field
54
- */
55
- toIpcError() {
23
+ toErrorObject() {
56
24
  return {
57
25
  code: this.code,
58
26
  message: this.message,
@@ -60,57 +28,25 @@ export class McpError extends Error {
60
28
  };
61
29
  }
62
30
  }
63
- /**
64
- * Creates an error for when no GTKX application is connected.
65
- *
66
- * @returns McpError with NO_APP_CONNECTED code
67
- */
68
31
  export function noAppConnectedError() {
69
- return new McpError(McpErrorCode.NO_APP_CONNECTED, "No GTKX application connected. Start an app with 'gtkx dev' to connect.", { hint: "Run 'gtkx dev src/app.tsx' in your project directory" });
32
+ return new ProtocolError(ErrorCode.NO_APP_CONNECTED, "No GTKX application connected: start an app with 'gtkx dev' to connect", { hint: "Run 'gtkx dev' in your project directory" });
33
+ }
34
+ export function appNotFoundError(applicationId) {
35
+ return new ProtocolError(ErrorCode.APP_NOT_FOUND, `Application '${applicationId}' not found`, { applicationId });
70
36
  }
71
- /**
72
- * Creates an error for when a requested app is not found.
73
- *
74
- * @param appId - The application ID that was not found
75
- * @returns McpError with APP_NOT_FOUND code
76
- */
77
- export function appNotFoundError(appId) {
78
- return new McpError(McpErrorCode.APP_NOT_FOUND, `Application '${appId}' not found`, { appId });
37
+ export function connectionWriteFailedError(applicationId) {
38
+ return new ProtocolError(ErrorCode.CONNECTION_WRITE_FAILED, `Connection to application '${applicationId}' is no longer writable`, { applicationId });
79
39
  }
80
- /**
81
- * Creates an error for when a widget is not found.
82
- *
83
- * @param widgetId - The widget ID that was not found
84
- * @returns McpError with WIDGET_NOT_FOUND code
85
- */
86
40
  export function widgetNotFoundError(widgetId) {
87
- return new McpError(McpErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });
41
+ return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });
88
42
  }
89
- /**
90
- * Creates an error for when an IPC request times out.
91
- *
92
- * @param timeout - The timeout duration in milliseconds
93
- * @returns McpError with IPC_TIMEOUT code
94
- */
95
- export function ipcTimeoutError(timeout) {
96
- return new McpError(McpErrorCode.IPC_TIMEOUT, `IPC request timed out after ${timeout}ms`, { timeout });
43
+ export function requestTimeoutError(timeout) {
44
+ return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${timeout}ms`, { timeout });
97
45
  }
98
- /**
99
- * Creates an error for invalid request format.
100
- *
101
- * @param reason - Description of why the request is invalid
102
- * @returns McpError with INVALID_REQUEST code
103
- */
104
46
  export function invalidRequestError(reason) {
105
- return new McpError(McpErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });
47
+ return new ProtocolError(ErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });
106
48
  }
107
- /**
108
- * Creates an error for when a method is not found.
109
- *
110
- * @param method - The method name that was not found
111
- * @returns McpError with METHOD_NOT_FOUND code
112
- */
113
49
  export function methodNotFoundError(method) {
114
- return new McpError(McpErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });
50
+ return new ProtocolError(ErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });
115
51
  }
116
52
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/protocol/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,YAyBX;AAzBD,WAAY,YAAY;IACpB,4BAA4B;IAC5B,sEAAqB,CAAA;IACrB,uCAAuC;IACvC,0EAAuB,CAAA;IACvB,6CAA6C;IAC7C,oEAAoB,CAAA;IACpB,6CAA6C;IAC7C,0EAAuB,CAAA;IACvB,u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AED,MAAM,UAAU,mBAAmB,CAAC,OAAe;IAC/C,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,eAAe,EAAE,2BAA2B,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7G,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAC9C,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,eAAe,EAAE,oBAAoB,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAClG,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAC9C,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,gBAAgB,EAAE,WAAW,MAAM,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AACrG,CAAC","sourcesContent":["export const ErrorCode = {\n INTERNAL_ERROR: 1000,\n NO_APP_CONNECTED: 1001,\n APP_NOT_FOUND: 1002,\n WIDGET_NOT_FOUND: 1003,\n CONNECTION_WRITE_FAILED: 1004,\n REQUEST_TIMEOUT: 1005,\n INVALID_REQUEST: 1006,\n METHOD_NOT_FOUND: 1007,\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nexport function isErrorCode(code: number): code is ErrorCode {\n return (Object.values(ErrorCode) as number[]).includes(code);\n}\n\nexport class ProtocolError extends Error {\n code: ErrorCode;\n data?: unknown;\n\n constructor(code: ErrorCode, message: string, data?: unknown) {\n super(message);\n this.code = code;\n this.data = data;\n this.name = \"ProtocolError\";\n }\n\n toErrorObject(): { code: number; message: string; data?: unknown } {\n return {\n code: this.code,\n message: this.message,\n ...(this.data !== undefined && { data: this.data }),\n };\n }\n}\n\nexport function noAppConnectedError(): ProtocolError {\n return new ProtocolError(\n ErrorCode.NO_APP_CONNECTED,\n \"No GTKX application connected: start an app with 'gtkx dev' to connect\",\n { hint: \"Run 'gtkx dev' in your project directory\" },\n );\n}\n\nexport function appNotFoundError(applicationId: string): ProtocolError {\n return new ProtocolError(ErrorCode.APP_NOT_FOUND, `Application '${applicationId}' not found`, { applicationId });\n}\n\nexport function connectionWriteFailedError(applicationId: string): ProtocolError {\n return new ProtocolError(\n ErrorCode.CONNECTION_WRITE_FAILED,\n `Connection to application '${applicationId}' is no longer writable`,\n { applicationId },\n );\n}\n\nexport function widgetNotFoundError(widgetId: string): ProtocolError {\n return new ProtocolError(ErrorCode.WIDGET_NOT_FOUND, `Widget '${widgetId}' not found`, { widgetId });\n}\n\nexport function requestTimeoutError(timeout: number): ProtocolError {\n return new ProtocolError(ErrorCode.REQUEST_TIMEOUT, `Request timed out after ${timeout}ms`, { timeout });\n}\n\nexport function invalidRequestError(reason: string): ProtocolError {\n return new ProtocolError(ErrorCode.INVALID_REQUEST, `Invalid request: ${reason}`, { reason });\n}\n\nexport function methodNotFoundError(method: string): ProtocolError {\n return new ProtocolError(ErrorCode.METHOD_NOT_FOUND, `Method '${method}' not found`, { method });\n}\n"]}
@@ -0,0 +1,89 @@
1
+ import { z } from "zod";
2
+ export declare const RequestSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ method: z.ZodString;
5
+ params: z.ZodOptional<z.ZodUnknown>;
6
+ }, z.core.$strip>;
7
+ export type Request = z.infer<typeof RequestSchema>;
8
+ declare const ErrorSchema: z.ZodObject<{
9
+ code: z.ZodNumber;
10
+ message: z.ZodString;
11
+ data: z.ZodOptional<z.ZodUnknown>;
12
+ }, z.core.$strip>;
13
+ export declare const ResponseSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ result: z.ZodOptional<z.ZodUnknown>;
16
+ error: z.ZodOptional<typeof ErrorSchema>;
17
+ }, z.core.$strip>;
18
+ export type Response = z.infer<typeof ResponseSchema>;
19
+ export type SerializedWidget = {
20
+ id: string;
21
+ type: string;
22
+ role: string;
23
+ name: string | null;
24
+ text: string | null;
25
+ sensitive: boolean;
26
+ visible: boolean;
27
+ cssClasses: string[];
28
+ children: SerializedWidget[];
29
+ };
30
+ export type AppInfo = {
31
+ applicationId: string;
32
+ pid: number;
33
+ projectRoot?: string;
34
+ };
35
+ export declare const RegisterParamsSchema: z.ZodObject<{
36
+ applicationId: z.ZodString;
37
+ pid: z.ZodNumber;
38
+ projectRoot: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ declare const emptyParams: z.ZodObject<Record<string, never>, z.core.$strip>;
41
+ export declare const widgetIdParams: z.ZodObject<{
42
+ widgetId: z.ZodString;
43
+ }, z.core.$strip>;
44
+ export declare const queryOptionsSchema: z.ZodObject<{
45
+ name: z.ZodOptional<z.ZodString>;
46
+ exact: z.ZodOptional<z.ZodBoolean>;
47
+ timeout: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strip>;
49
+ export declare const queryParams: z.ZodObject<{
50
+ by: z.ZodEnum<{
51
+ role: "role";
52
+ text: "text";
53
+ name: "name";
54
+ labelText: "labelText";
55
+ }>;
56
+ value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
57
+ options: z.ZodOptional<typeof queryOptionsSchema>;
58
+ }, z.core.$strip>;
59
+ export declare const typeParams: z.ZodObject<{
60
+ widgetId: z.ZodString;
61
+ text: z.ZodString;
62
+ clear: z.ZodOptional<z.ZodBoolean>;
63
+ }, z.core.$strip>;
64
+ export declare const fireEventParams: z.ZodObject<{
65
+ widgetId: z.ZodString;
66
+ signal: z.ZodString;
67
+ args: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
68
+ }, z.core.$strip>;
69
+ export declare const screenshotParams: z.ZodObject<{
70
+ windowId: z.ZodOptional<z.ZodString>;
71
+ path: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strip>;
73
+ export declare const ServerRequestParamsSchemas: {
74
+ "app.getWindows": typeof emptyParams;
75
+ "widget.getTree": typeof emptyParams;
76
+ "widget.query": typeof queryParams;
77
+ "widget.getProps": typeof widgetIdParams;
78
+ "widget.click": typeof widgetIdParams;
79
+ "widget.type": typeof typeParams;
80
+ "widget.fireEvent": typeof fireEventParams;
81
+ "widget.screenshot": typeof screenshotParams;
82
+ };
83
+ export type ServerRequestParams<Method extends keyof typeof ServerRequestParamsSchemas> = z.infer<(typeof ServerRequestParamsSchemas)[Method]>;
84
+ export type ParamsSchema<Output> = z.ZodType<Output>;
85
+ export type ServerInitiatedMethod = keyof typeof ServerRequestParamsSchemas;
86
+ export type Message = Request | Response;
87
+ export declare const DEFAULT_SOCKET_PATH: string;
88
+ export {};
89
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,SAAS,CACnC;IACI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;CACvC,EACD,CAAC,CAAC,IAAI,CAAC,MAAM,CAKf,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,QAAA,MAAM,WAAW,EAAE,CAAC,CAAC,SAAS,CAC1B;IAAE,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC;IAAC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;CAAE,EAC9E,CAAC,CAAC,IAAI,CAAC,MAAM,CAKf,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,SAAS,CACpC;IACI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,WAA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),
6
+ method: z.string(),
7
+ params: z.unknown().optional(),
8
+ });
9
+ const ErrorSchema = z.object({
10
+ code: z.number(),
11
+ message: z.string(),
12
+ data: z.unknown().optional(),
13
+ });
14
+ export const ResponseSchema = z.object({
15
+ id: z.string(),
16
+ result: z.unknown().optional(),
17
+ error: ErrorSchema.optional(),
18
+ });
19
+ export const RegisterParamsSchema = z.object({
20
+ applicationId: z.string(),
21
+ pid: z.number(),
22
+ projectRoot: z.string().optional(),
23
+ });
24
+ const emptyParams = z.object({});
25
+ export const widgetIdParams = z.object({
26
+ widgetId: z.string(),
27
+ });
28
+ export const queryOptionsSchema = z.object({
29
+ name: z.string().optional(),
30
+ exact: z.boolean().optional(),
31
+ timeout: z.number().optional(),
32
+ });
33
+ export const queryParams = z.object({
34
+ by: z.enum(["role", "text", "name", "labelText"]),
35
+ value: z.union([z.string(), z.number()]),
36
+ options: queryOptionsSchema.optional(),
37
+ });
38
+ export const typeParams = z.object({ widgetId: z.string(), text: z.string(), clear: z.boolean().optional() });
39
+ export const fireEventParams = z.object({ widgetId: z.string(), signal: z.string(), args: z.array(z.unknown()).optional() });
40
+ export const screenshotParams = z.object({
41
+ windowId: z.string().optional(),
42
+ path: z.string().optional(),
43
+ });
44
+ export const ServerRequestParamsSchemas = {
45
+ "app.getWindows": emptyParams,
46
+ "widget.getTree": emptyParams,
47
+ "widget.query": queryParams,
48
+ "widget.getProps": widgetIdParams,
49
+ "widget.click": widgetIdParams,
50
+ "widget.type": typeParams,
51
+ "widget.fireEvent": fireEventParams,
52
+ "widget.screenshot": screenshotParams,
53
+ };
54
+ const getRuntimeDir = () => process.env.XDG_RUNTIME_DIR ?? tmpdir();
55
+ export const DEFAULT_SOCKET_PATH = join(getRuntimeDir(), "gtkx-mcp.sock");
56
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM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Q,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GASnC;IACA,gBAAgB,EAAE,WAAW;IAC7B,gBAAgB,EAAE,WAAW;IAC7B,cAAc,EAAE,WAAW;IAC3B,iBAAiB,EAAE,cAAc;IACjC,cAAc,EAAE,cAAc;IAC9B,aAAa,EAAE,UAAU;IACzB,kBAAkB,EAAE,eAAe;IACnC,mBAAmB,EAAE,gBAAgB;CACxC,CAAC;AAYF,MAAM,aAAa,GAAG,GAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,MAAM,EAAE,CAAC;AAE5E,MAAM,CAAC,MAAM,mBAAmB,GAAW,IAAI,CAAC,aAAa,EAAE,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\n\nexport const RequestSchema: z.ZodObject<\n {\n id: z.ZodString;\n method: z.ZodString;\n params: z.ZodOptional<z.ZodUnknown>;\n },\n z.core.$strip\n> = z.object({\n id: z.string(),\n method: z.string(),\n params: z.unknown().optional(),\n});\n\nexport type Request = z.infer<typeof RequestSchema>;\n\nconst ErrorSchema: z.ZodObject<\n { code: z.ZodNumber; message: z.ZodString; data: z.ZodOptional<z.ZodUnknown> },\n z.core.$strip\n> = z.object({\n code: z.number(),\n message: z.string(),\n data: z.unknown().optional(),\n});\n\nexport const ResponseSchema: z.ZodObject<\n {\n id: z.ZodString;\n result: z.ZodOptional<z.ZodUnknown>;\n error: z.ZodOptional<typeof ErrorSchema>;\n },\n z.core.$strip\n> = z.object({\n id: z.string(),\n result: z.unknown().optional(),\n error: ErrorSchema.optional(),\n});\n\nexport type Response = z.infer<typeof ResponseSchema>;\n\nexport type SerializedWidget = {\n id: string;\n type: string;\n role: string;\n name: string | null;\n text: string | null;\n sensitive: boolean;\n visible: boolean;\n cssClasses: string[];\n children: SerializedWidget[];\n};\n\nexport type AppInfo = {\n applicationId: string;\n pid: number;\n projectRoot?: string;\n};\n\nexport const RegisterParamsSchema: z.ZodObject<\n {\n applicationId: z.ZodString;\n pid: z.ZodNumber;\n projectRoot: z.ZodOptional<z.ZodString>;\n },\n z.core.$strip\n> = z.object({\n applicationId: z.string(),\n pid: z.number(),\n projectRoot: z.string().optional(),\n});\n\nconst emptyParams: z.ZodObject<Record<string, never>, z.core.$strip> = z.object({});\nexport const widgetIdParams: z.ZodObject<{ widgetId: z.ZodString }, z.core.$strip> = z.object({\n widgetId: z.string(),\n});\nexport const queryOptionsSchema: z.ZodObject<\n { name: z.ZodOptional<z.ZodString>; exact: z.ZodOptional<z.ZodBoolean>; timeout: z.ZodOptional<z.ZodNumber> },\n z.core.$strip\n> = z.object({\n name: z.string().optional(),\n exact: z.boolean().optional(),\n timeout: z.number().optional(),\n});\n\nexport const queryParams: z.ZodObject<\n {\n by: z.ZodEnum<{ role: \"role\"; text: \"text\"; name: \"name\"; labelText: \"labelText\" }>;\n value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;\n options: z.ZodOptional<typeof queryOptionsSchema>;\n },\n z.core.$strip\n> = z.object({\n by: z.enum([\"role\", \"text\", \"name\", \"labelText\"]),\n value: z.union([z.string(), z.number()]),\n options: queryOptionsSchema.optional(),\n});\nexport const typeParams: z.ZodObject<\n { widgetId: z.ZodString; text: z.ZodString; clear: z.ZodOptional<z.ZodBoolean> },\n z.core.$strip\n> = z.object({ widgetId: z.string(), text: z.string(), clear: z.boolean().optional() });\nexport const fireEventParams: z.ZodObject<\n { widgetId: z.ZodString; signal: z.ZodString; args: z.ZodOptional<z.ZodArray<z.ZodUnknown>> },\n z.core.$strip\n> = z.object({ widgetId: z.string(), signal: z.string(), args: z.array(z.unknown()).optional() });\nexport const screenshotParams: z.ZodObject<\n { windowId: z.ZodOptional<z.ZodString>; path: z.ZodOptional<z.ZodString> },\n z.core.$strip\n> = z.object({\n windowId: z.string().optional(),\n path: z.string().optional(),\n});\n\nexport const ServerRequestParamsSchemas: {\n \"app.getWindows\": typeof emptyParams;\n \"widget.getTree\": typeof emptyParams;\n \"widget.query\": typeof queryParams;\n \"widget.getProps\": typeof widgetIdParams;\n \"widget.click\": typeof widgetIdParams;\n \"widget.type\": typeof typeParams;\n \"widget.fireEvent\": typeof fireEventParams;\n \"widget.screenshot\": typeof screenshotParams;\n} = {\n \"app.getWindows\": emptyParams,\n \"widget.getTree\": emptyParams,\n \"widget.query\": queryParams,\n \"widget.getProps\": widgetIdParams,\n \"widget.click\": widgetIdParams,\n \"widget.type\": typeParams,\n \"widget.fireEvent\": fireEventParams,\n \"widget.screenshot\": screenshotParams,\n};\n\nexport type ServerRequestParams<Method extends keyof typeof ServerRequestParamsSchemas> = z.infer<\n (typeof ServerRequestParamsSchemas)[Method]\n>;\n\nexport type ParamsSchema<Output> = z.ZodType<Output>;\n\nexport type ServerInitiatedMethod = keyof typeof ServerRequestParamsSchemas;\n\nexport type Message = Request | Response;\n\nconst getRuntimeDir = (): string => process.env.XDG_RUNTIME_DIR ?? tmpdir();\n\nexport const DEFAULT_SOCKET_PATH: string = join(getRuntimeDir(), \"gtkx-mcp.sock\");\n"]}
@@ -0,0 +1,13 @@
1
+ import { type ApiReference } from "@gtkx/codegen";
2
+ import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { type Tool } from "./tool.js";
4
+ export type ReferenceApi = Pick<ApiReference, "lookup" | "namespaceOverview" | "namespaces" | "overview" | "search" | "symbolNames">;
5
+ export type ReferenceProvider = {
6
+ get(): Promise<ReferenceApi>;
7
+ };
8
+ export declare const createReferenceProvider: (resolveRoot: () => string) => ReferenceProvider;
9
+ export declare const buildReferenceTools: (provider: ReferenceProvider) => Tool[];
10
+ type ResourceServer = Pick<McpServer, "registerResource">;
11
+ export declare const registerReferenceResources: (server: ResourceServer, provider: ReferenceProvider) => void;
12
+ export {};
13
+ //# sourceMappingURL=reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAsE,MAAM,eAAe,CAAC;AAEtH,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAG3F,OAAO,EAAc,KAAK,IAAI,EAA0B,MAAM,WAAW,CAAC;AAE1E,MAAM,MAAM,YAAY,GAAG,IAAI,CAC3B,YAAY,EACZ,QAAQ,GAAG,mBAAmB,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,CACxF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC,CAAC;AA2DF,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,MAAM,KAAG,iBA4BnE,CAAC;AA4GF,eAAO,MAAM,mBAAmB,aAAc,iBAAiB,KAAG,IAAI,EAIrE,CAAC;AASF,KAAK,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AA+G1D,eAAO,MAAM,0BAA0B,WAAY,cAAc,YAAY,iBAAiB,KAAG,IAIhG,CAAC"}