@google/stitch-sdk 0.0.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 (86) hide show
  1. package/README.md +271 -0
  2. package/dist/generated/src/index.d.ts +13 -0
  3. package/dist/generated/src/index.d.ts.map +1 -0
  4. package/dist/generated/src/index.js +13 -0
  5. package/dist/generated/src/index.js.map +1 -0
  6. package/dist/generated/src/project.d.ts +35 -0
  7. package/dist/generated/src/project.d.ts.map +1 -0
  8. package/dist/generated/src/project.js +62 -0
  9. package/dist/generated/src/project.js.map +1 -0
  10. package/dist/generated/src/screen.d.ts +40 -0
  11. package/dist/generated/src/screen.d.ts.map +1 -0
  12. package/dist/generated/src/screen.js +82 -0
  13. package/dist/generated/src/screen.js.map +1 -0
  14. package/dist/generated/src/stitch.d.ts +23 -0
  15. package/dist/generated/src/stitch.d.ts.map +1 -0
  16. package/dist/generated/src/stitch.js +27 -0
  17. package/dist/generated/src/stitch.js.map +1 -0
  18. package/dist/generated/src/tool-definitions.d.ts +20 -0
  19. package/dist/generated/src/tool-definitions.d.ts.map +1 -0
  20. package/dist/generated/src/tool-definitions.js +333 -0
  21. package/dist/generated/src/tool-definitions.js.map +1 -0
  22. package/dist/src/ai.d.ts +17 -0
  23. package/dist/src/ai.d.ts.map +1 -0
  24. package/dist/src/ai.js +30 -0
  25. package/dist/src/ai.js.map +1 -0
  26. package/dist/src/client.d.ts +77 -0
  27. package/dist/src/client.d.ts.map +1 -0
  28. package/dist/src/client.js +135 -0
  29. package/dist/src/client.js.map +1 -0
  30. package/dist/src/constants.d.ts +2 -0
  31. package/dist/src/constants.d.ts.map +1 -0
  32. package/dist/src/constants.js +15 -0
  33. package/dist/src/constants.js.map +1 -0
  34. package/dist/src/index.d.ts +10 -0
  35. package/dist/src/index.d.ts.map +1 -0
  36. package/dist/src/index.js +25 -0
  37. package/dist/src/index.js.map +1 -0
  38. package/dist/src/proxy/client.d.ts +22 -0
  39. package/dist/src/proxy/client.d.ts.map +1 -0
  40. package/dist/src/proxy/client.js +87 -0
  41. package/dist/src/proxy/client.js.map +1 -0
  42. package/dist/src/proxy/core.d.ts +16 -0
  43. package/dist/src/proxy/core.d.ts.map +1 -0
  44. package/dist/src/proxy/core.js +68 -0
  45. package/dist/src/proxy/core.js.map +1 -0
  46. package/dist/src/proxy/handlers/callTool.d.ts +7 -0
  47. package/dist/src/proxy/handlers/callTool.d.ts.map +1 -0
  48. package/dist/src/proxy/handlers/callTool.js +40 -0
  49. package/dist/src/proxy/handlers/callTool.js.map +1 -0
  50. package/dist/src/proxy/handlers/listTools.d.ts +7 -0
  51. package/dist/src/proxy/handlers/listTools.d.ts.map +1 -0
  52. package/dist/src/proxy/handlers/listTools.js +36 -0
  53. package/dist/src/proxy/handlers/listTools.js.map +1 -0
  54. package/dist/src/proxy/index.d.ts +4 -0
  55. package/dist/src/proxy/index.d.ts.map +1 -0
  56. package/dist/src/proxy/index.js +17 -0
  57. package/dist/src/proxy/index.js.map +1 -0
  58. package/dist/src/singleton.d.ts +25 -0
  59. package/dist/src/singleton.d.ts.map +1 -0
  60. package/dist/src/singleton.js +76 -0
  61. package/dist/src/singleton.js.map +1 -0
  62. package/dist/src/spec/client.d.ts +52 -0
  63. package/dist/src/spec/client.d.ts.map +1 -0
  64. package/dist/src/spec/client.js +52 -0
  65. package/dist/src/spec/client.js.map +1 -0
  66. package/dist/src/spec/errors.d.ts +39 -0
  67. package/dist/src/spec/errors.d.ts.map +1 -0
  68. package/dist/src/spec/errors.js +56 -0
  69. package/dist/src/spec/errors.js.map +1 -0
  70. package/dist/src/spec/proxy.d.ts +22 -0
  71. package/dist/src/spec/proxy.d.ts.map +1 -0
  72. package/dist/src/spec/proxy.js +31 -0
  73. package/dist/src/spec/proxy.js.map +1 -0
  74. package/dist/src/tools-adapter.d.ts +27 -0
  75. package/dist/src/tools-adapter.d.ts.map +1 -0
  76. package/dist/src/tools-adapter.js +66 -0
  77. package/dist/src/tools-adapter.js.map +1 -0
  78. package/dist/src/types.d.ts +38 -0
  79. package/dist/src/types.d.ts.map +1 -0
  80. package/dist/src/types.js +15 -0
  81. package/dist/src/types.js.map +1 -0
  82. package/dist/src/version.d.ts +2 -0
  83. package/dist/src/version.d.ts.map +1 -0
  84. package/dist/src/version.js +3 -0
  85. package/dist/src/version.js.map +1 -0
  86. package/package.json +63 -0
@@ -0,0 +1,10 @@
1
+ export { Stitch } from "../generated/src/stitch.js";
2
+ export { Project } from "../generated/src/project.js";
3
+ export { Screen } from "../generated/src/screen.js";
4
+ export { StitchToolClient } from "./client.js";
5
+ export { StitchProxy } from "./proxy/core.js";
6
+ export { stitch } from "./singleton.js";
7
+ export { StitchError, StitchErrorCode } from "./spec/errors.js";
8
+ export type { StitchConfig, StitchConfigInput } from "./spec/client.js";
9
+ export type { ProjectData, GenerateScreenParams, DesignTheme, ScreenInstance, ThumbnailScreenshot, } from "./types.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGhE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ // Domain classes (generated)
15
+ export { Stitch } from "../generated/src/stitch.js";
16
+ export { Project } from "../generated/src/project.js";
17
+ export { Screen } from "../generated/src/screen.js";
18
+ // Infrastructure (handwritten)
19
+ export { StitchToolClient } from "./client.js";
20
+ export { StitchProxy } from "./proxy/core.js";
21
+ // Singleton
22
+ export { stitch } from "./singleton.js";
23
+ // Error handling
24
+ export { StitchError, StitchErrorCode } from "./spec/errors.js";
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6BAA6B;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,+BAA+B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,YAAY;AACZ,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,iBAAiB;AACjB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { StitchProxyConfig } from '../spec/proxy.js';
2
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
3
+ /**
4
+ * Shared state for proxy handlers.
5
+ */
6
+ export interface ProxyContext {
7
+ config: StitchProxyConfig;
8
+ remoteTools: Tool[];
9
+ }
10
+ /**
11
+ * Forward a JSON-RPC request to Stitch.
12
+ */
13
+ export declare function forwardToStitch(config: StitchProxyConfig, method: string, params?: unknown): Promise<unknown>;
14
+ /**
15
+ * Initialize connection to Stitch and fetch tools.
16
+ */
17
+ export declare function initializeStitchConnection(ctx: ProxyContext): Promise<void>;
18
+ /**
19
+ * Refresh the cached tools list from Stitch.
20
+ */
21
+ export declare function refreshTools(ctx: ProxyContext): Promise<void>;
22
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/proxy/client.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,WAAW,EAAE,IAAI,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnE"}
@@ -0,0 +1,87 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /**
15
+ * Forward a JSON-RPC request to Stitch.
16
+ */
17
+ export async function forwardToStitch(config, method, params) {
18
+ const request = {
19
+ jsonrpc: '2.0',
20
+ method,
21
+ params: params ?? {},
22
+ id: Date.now(),
23
+ };
24
+ let response;
25
+ try {
26
+ response = await fetch(config.url, {
27
+ method: 'POST',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ Accept: 'application/json',
31
+ 'X-Goog-Api-Key': config.apiKey,
32
+ },
33
+ body: JSON.stringify(request),
34
+ });
35
+ }
36
+ catch (err) {
37
+ throw new Error(`Network failure connecting to Stitch API: ${err.message}`);
38
+ }
39
+ if (!response.ok) {
40
+ const errorText = await response.text();
41
+ throw new Error(`Stitch API error (${response.status}): ${errorText}`);
42
+ }
43
+ const result = (await response.json());
44
+ if (result.error) {
45
+ throw new Error(`Stitch RPC error: ${result.error.message}`);
46
+ }
47
+ return result.result;
48
+ }
49
+ /**
50
+ * Initialize connection to Stitch and fetch tools.
51
+ */
52
+ export async function initializeStitchConnection(ctx) {
53
+ // Send initialize request
54
+ await forwardToStitch(ctx.config, 'initialize', {
55
+ protocolVersion: ctx.config.protocolVersion || '2024-11-05',
56
+ capabilities: {},
57
+ clientInfo: {
58
+ name: ctx.config.name,
59
+ version: ctx.config.version,
60
+ },
61
+ });
62
+ // Send initialized notification (fire and forget)
63
+ fetch(ctx.config.url, {
64
+ method: 'POST',
65
+ headers: {
66
+ 'Content-Type': 'application/json',
67
+ Accept: 'application/json',
68
+ 'X-Goog-Api-Key': ctx.config.apiKey,
69
+ },
70
+ body: JSON.stringify({
71
+ jsonrpc: '2.0',
72
+ method: 'notifications/initialized',
73
+ }),
74
+ }).catch((err) => {
75
+ console.error('[stitch-proxy] Failed to send initialized notification:', err);
76
+ });
77
+ await refreshTools(ctx);
78
+ console.error(`[stitch-proxy] Connected to Stitch, discovered ${ctx.remoteTools.length} tools`);
79
+ }
80
+ /**
81
+ * Refresh the cached tools list from Stitch.
82
+ */
83
+ export async function refreshTools(ctx) {
84
+ const toolsResult = (await forwardToStitch(ctx.config, 'tools/list', {}));
85
+ ctx.remoteTools = toolsResult.tools || [];
86
+ }
87
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/proxy/client.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAajC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAyB,EACzB,MAAc,EACd,MAAgB;IAEhB,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,KAAK;QACd,MAAM;QACN,MAAM,EAAE,MAAM,IAAI,EAAE;QACpB,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;KACf,CAAC;IAEF,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,kBAAkB;gBAC1B,gBAAgB,EAAE,MAAM,CAAC,MAAO;aACjC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CA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AAC,SAAS,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,2BAA2B;SACpC,CAAC;KACH,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,yDAAyD,EAAE,GAAG,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,CAAC,KAAK,CACX,kDAAkD,GAAG,CAAC,WAAW,CAAC,MAAM,QAAQ,CACjF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAiB;IAClD,MAAM,WAAW,GAAG,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,CAAC,CAEvE,CAAC;IACF,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ import { StitchProxyConfig, StitchProxySpec } from '../spec/proxy.js';
3
+ /**
4
+ * A proxy server that forwards MCP requests to Stitch.
5
+ * Bypasses SDK transport layer to handle specific auth and JSON-RPC forwarding.
6
+ */
7
+ export declare class StitchProxy implements StitchProxySpec {
8
+ private config;
9
+ private server;
10
+ private ctx;
11
+ constructor(inputConfig?: Partial<StitchProxyConfig>);
12
+ private setupHandlers;
13
+ start(transport: Transport): Promise<void>;
14
+ close(): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/proxy/core.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAA2B,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAK/F;;;GAGG;AACH,qBAAa,WAAY,YAAW,eAAe;IACjD,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,GAAG,CAAe;gBAEd,WAAW,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAoCpD,OAAO,CAAC,aAAa;IAKf,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAO1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -0,0 +1,68 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
15
+ import { StitchProxyConfigSchema } from '../spec/proxy.js';
16
+ import { initializeStitchConnection } from './client.js';
17
+ import { registerListToolsHandler } from './handlers/listTools.js';
18
+ import { registerCallToolHandler } from './handlers/callTool.js';
19
+ /**
20
+ * A proxy server that forwards MCP requests to Stitch.
21
+ * Bypasses SDK transport layer to handle specific auth and JSON-RPC forwarding.
22
+ */
23
+ export class StitchProxy {
24
+ config;
25
+ server;
26
+ ctx;
27
+ constructor(inputConfig) {
28
+ const rawConfig = {
29
+ apiKey: inputConfig?.apiKey || process.env.STITCH_API_KEY,
30
+ url: inputConfig?.url || process.env.STITCH_MCP_URL,
31
+ name: inputConfig?.name,
32
+ version: inputConfig?.version,
33
+ };
34
+ // Validate config
35
+ this.config = StitchProxyConfigSchema.parse(rawConfig);
36
+ if (!this.config.apiKey) {
37
+ throw new Error('StitchProxy requires an API key (STITCH_API_KEY)');
38
+ }
39
+ this.server = new McpServer({
40
+ name: this.config.name,
41
+ version: this.config.version,
42
+ }, {
43
+ capabilities: {
44
+ tools: {},
45
+ },
46
+ });
47
+ // Shared context for handlers
48
+ this.ctx = {
49
+ config: this.config,
50
+ remoteTools: [],
51
+ };
52
+ this.setupHandlers();
53
+ }
54
+ setupHandlers() {
55
+ registerListToolsHandler(this.server.server, this.ctx);
56
+ registerCallToolHandler(this.server.server, this.ctx);
57
+ }
58
+ async start(transport) {
59
+ console.error(`[stitch-proxy] Connecting to ${this.config.url}...`);
60
+ await initializeStitchConnection(this.ctx);
61
+ await this.server.connect(transport);
62
+ console.error('[stitch-proxy] Proxy server running');
63
+ }
64
+ async close() {
65
+ await this.server.close();
66
+ }
67
+ }
68
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/proxy/core.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,uBAAuB,EAAsC,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAgB,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAoB;IAC1B,MAAM,CAAY;IAClB,GAAG,CAAe;IAE1B,YAAY,WAAwC;QAClD,MAAM,SAAS,GAAG;YAChB,MAAM,EAAE,WAAW,EAAE,MAAM,IAAI,OAAO,CAAC,GAAG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AK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import type { ProxyContext } from '../client.js';
3
+ /**
4
+ * Register the tools/call handler.
5
+ */
6
+ export declare function registerCallToolHandler(server: Server, ctx: ProxyContext): void;
7
+ //# sourceMappingURL=callTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callTool.d.ts","sourceRoot":"","sources":["../../../../src/proxy/handlers/callTool.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,YAAY,GAChB,IAAI,CAoBN"}
@@ -0,0 +1,40 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
15
+ import { forwardToStitch } from '../client.js';
16
+ /**
17
+ * Register the tools/call handler.
18
+ */
19
+ export function registerCallToolHandler(server, ctx) {
20
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
21
+ const { name, arguments: args } = request.params;
22
+ console.error(`[stitch-proxy] Calling tool: ${name}`);
23
+ try {
24
+ const result = await forwardToStitch(ctx.config, 'tools/call', {
25
+ name,
26
+ arguments: args,
27
+ });
28
+ return result;
29
+ }
30
+ catch (err) {
31
+ const errorMessage = err instanceof Error ? err.message : String(err);
32
+ console.error(`[stitch-proxy] Tool call failed: ${errorMessage}`);
33
+ return {
34
+ content: [{ type: 'text', text: `Error calling ${name}: ${errorMessage}` }],
35
+ isError: true,
36
+ };
37
+ }
38
+ });
39
+ }
40
+ //# sourceMappingURL=callTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callTool.js","sourceRoot":"","sources":["../../../../src/proxy/handlers/callTool.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAG3E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,GAAiB;IAEjB,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;QAEtD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE;gBAC7D,IAAI;gBACJ,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,OAAO,MAA4D,CAAC;QACtE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACtE,OAAO,CAAC,KAAK,CAAC,oCAAoC,YAAY,EAAE,CAAC,CAAC;YAClE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,KAAK,YAAY,EAAE,EAAE,CAAC;gBAC3E,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import type { ProxyContext } from '../client.js';
3
+ /**
4
+ * Register the tools/list handler.
5
+ */
6
+ export declare function registerListToolsHandler(server: Server, ctx: ProxyContext): void;
7
+ //# sourceMappingURL=listTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listTools.d.ts","sourceRoot":"","sources":["../../../../src/proxy/handlers/listTools.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,YAAY,GAChB,IAAI,CAcN"}
@@ -0,0 +1,36 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
15
+ import { refreshTools } from '../client.js';
16
+ /**
17
+ * Register the tools/list handler.
18
+ */
19
+ export function registerListToolsHandler(server, ctx) {
20
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
21
+ try {
22
+ await refreshTools(ctx);
23
+ }
24
+ catch (err) {
25
+ console.error('[stitch-proxy] Failed to refresh tools:', err);
26
+ if (ctx.remoteTools.length === 0) {
27
+ throw err;
28
+ }
29
+ else {
30
+ console.warn('[stitch-proxy] Warning: Using stale tools due to refresh failure');
31
+ }
32
+ }
33
+ return { tools: ctx.remoteTools };
34
+ });
35
+ }
36
+ //# sourceMappingURL=listTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listTools.js","sourceRoot":"","sources":["../../../../src/proxy/handlers/listTools.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAc,EACd,GAAiB;IAEjB,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QAC1D,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAC;YAC9D,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjC,MAAM,GAAG,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { StitchProxy } from './core.js';
2
+ export { forwardToStitch, initializeStitchConnection, refreshTools } from './client.js';
3
+ export type { ProxyContext } from './client.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/proxy/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,17 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ // Proxy barrel exports
15
+ export { StitchProxy } from './core.js';
16
+ export { forwardToStitch, initializeStitchConnection, refreshTools } from './client.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/proxy/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,uBAAuB;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Stitch } from "../generated/src/stitch.js";
2
+ import { StitchToolClient } from "./client.js";
3
+ /** Get or create the shared StitchToolClient instance. */
4
+ export declare function getOrCreateClient(config?: {
5
+ apiKey?: string;
6
+ }): StitchToolClient;
7
+ /**
8
+ * Default Stitch instance using environment variables.
9
+ * Lazily initialized on first access.
10
+ *
11
+ * Exposes both domain methods (from Stitch class) and tool methods
12
+ * (listTools, callTool, close from StitchToolClient).
13
+ *
14
+ * @example
15
+ * import { stitch } from '@google/stitch-sdk';
16
+ *
17
+ * // Domain API
18
+ * const projects = await stitch.projects();
19
+ *
20
+ * // Tool API
21
+ * const tools = await stitch.listTools();
22
+ * await stitch.callTool("create_project", { title: "My App" });
23
+ */
24
+ export declare const stitch: Stitch & Pick<StitchToolClient, "listTools" | "callTool" | "close">;
25
+ //# sourceMappingURL=singleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/singleton.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,gBAAgB,CAQhF;AAeD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,qEAqBjB,CAAC"}
@@ -0,0 +1,76 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { Stitch } from "../generated/src/stitch.js";
15
+ import { StitchToolClient } from "./client.js";
16
+ import { DEFAULT_STITCH_API_URL } from "./constants.js";
17
+ /** Lazily-initialized default client */
18
+ let _client = null;
19
+ /** Get or create the shared StitchToolClient instance. */
20
+ export function getOrCreateClient(config) {
21
+ if (!_client) {
22
+ _client = new StitchToolClient({
23
+ apiKey: config?.apiKey || process.env.STITCH_API_KEY,
24
+ baseUrl: process.env.STITCH_HOST || DEFAULT_STITCH_API_URL,
25
+ });
26
+ }
27
+ return _client;
28
+ }
29
+ /** Lazily-initialized default Stitch instance */
30
+ let _stitch = null;
31
+ function getStitchInstance() {
32
+ if (!_stitch) {
33
+ _stitch = new Stitch(getOrCreateClient());
34
+ }
35
+ return _stitch;
36
+ }
37
+ /** Methods that delegate to StitchToolClient instead of Stitch domain class. */
38
+ const CLIENT_METHODS = new Set(['listTools', 'callTool', 'close']);
39
+ /**
40
+ * Default Stitch instance using environment variables.
41
+ * Lazily initialized on first access.
42
+ *
43
+ * Exposes both domain methods (from Stitch class) and tool methods
44
+ * (listTools, callTool, close from StitchToolClient).
45
+ *
46
+ * @example
47
+ * import { stitch } from '@google/stitch-sdk';
48
+ *
49
+ * // Domain API
50
+ * const projects = await stitch.projects();
51
+ *
52
+ * // Tool API
53
+ * const tools = await stitch.listTools();
54
+ * await stitch.callTool("create_project", { title: "My App" });
55
+ */
56
+ export const stitch = new Proxy({}, {
57
+ get(_target, prop) {
58
+ // Client methods → delegate to StitchToolClient
59
+ if (typeof prop === 'string' && CLIENT_METHODS.has(prop)) {
60
+ const client = getOrCreateClient();
61
+ const value = client[prop];
62
+ if (typeof value === 'function') {
63
+ return value.bind(client);
64
+ }
65
+ return value;
66
+ }
67
+ // Domain methods → delegate to Stitch instance
68
+ const instance = getStitchInstance();
69
+ const value = instance[prop];
70
+ if (typeof value === 'function') {
71
+ return value.bind(instance);
72
+ }
73
+ return value;
74
+ },
75
+ });
76
+ //# sourceMappingURL=singleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/singleton.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,wCAAwC;AACxC,IAAI,OAAO,GAA4B,IAAI,CAAC;AAE5C,0DAA0D;AAC1D,MAAM,UAAU,iBAAiB,CAAC,MAA4B;IAC5D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,gBAAgB,CAAC;YAC7B,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;YACpD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,sBAAsB;SAC3D,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,iDAAiD;AACjD,IAAI,OAAO,GAAkB,IAAI,CAAC;AAElC,SAAS,iBAAiB;IACxB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gFAAgF;AAChF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,KAAK,CAE7B,EAAS,EAAE;IACX,GAAG,CAAC,OAAO,EAAE,IAAqB;QAChC,gDAAgD;QAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,CAAC,IAA8B,CAAC,CAAC;YACrD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,+CAA+C;QAC/C,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAoB,CAAC,CAAC;QAC7C,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ export declare const StitchConfigSchema: z.ZodObject<{
3
+ apiKey: z.ZodOptional<z.ZodString>;
4
+ accessToken: z.ZodOptional<z.ZodString>;
5
+ projectId: z.ZodOptional<z.ZodString>;
6
+ baseUrl: z.ZodDefault<z.ZodString>;
7
+ timeout: z.ZodDefault<z.ZodNumber>;
8
+ }, z.core.$strip>;
9
+ export type StitchConfig = z.infer<typeof StitchConfigSchema>;
10
+ /** Input type for StitchConfig - fields with defaults are optional */
11
+ export type StitchConfigInput = z.input<typeof StitchConfigSchema>;
12
+ export declare const ToolResultSchema: z.ZodObject<{
13
+ success: z.ZodBoolean;
14
+ data: z.ZodOptional<z.ZodUnknown>;
15
+ error: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export type ToolResult = z.infer<typeof ToolResultSchema>;
18
+ export declare const ToolsSchema: z.ZodObject<{
19
+ tools: z.ZodArray<z.ZodObject<{
20
+ name: z.ZodString;
21
+ description: z.ZodOptional<z.ZodString>;
22
+ inputSchema: z.ZodOptional<z.ZodUnknown>;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ export type Tools = z.infer<typeof ToolsSchema>;
26
+ export interface StitchToolClientSpec {
27
+ name: 'stitch-tool-client';
28
+ description: 'Authenticated tool pipe for Stitch MCP Server';
29
+ /**
30
+ * Validate configuration and establish connection.
31
+ * MUST handle auth header injection based on config.
32
+ * - API Key: Inject `X-Goog-Api-Key` header.
33
+ * - OAuth: Inject `Authorization: Bearer` and `X-Goog-User-Project` headers.
34
+ */
35
+ connect: () => Promise<void>;
36
+ /**
37
+ * Call a tool on the MCP server.
38
+ * @param name - Tool name
39
+ * @param args - Tool arguments
40
+ * @returns Parsed tool result
41
+ */
42
+ callTool: <T>(name: string, args: Record<string, unknown>) => Promise<T>;
43
+ /**
44
+ * Get available tools from the server.
45
+ */
46
+ listTools: () => Promise<Tools>;
47
+ /**
48
+ * Close the connection.
49
+ */
50
+ close: () => Promise<void>;
51
+ }
52
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/spec/client.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,kBAAkB;;;;;;iBAqB7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,sEAAsE;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAKnE,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,WAAW;;;;;;iBAMtB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAKhD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,WAAW,EAAE,+CAA+C,CAAC;IAE7D;;;;;OAKG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAEzE;;OAEG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;IAEhC;;OAEG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B"}
@@ -0,0 +1,52 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // https://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { z } from 'zod';
15
+ import { DEFAULT_STITCH_API_URL } from '../constants.js';
16
+ // ─────────────────────────────────────────────────────────────────────────────
17
+ // 1. INPUT SCHEMA - What the client receives for configuration
18
+ // ─────────────────────────────────────────────────────────────────────────────
19
+ export const StitchConfigSchema = z.object({
20
+ /** API key for simple API access. Falls back to STITCH_API_KEY. */
21
+ apiKey: z.string().optional(),
22
+ /** OAuth access token for user-authenticated requests. Falls back to STITCH_ACCESS_TOKEN. */
23
+ accessToken: z.string().optional(),
24
+ /** Google Cloud project ID. Required for OAuth, optional for API Key. Falls back to GOOGLE_CLOUD_PROJECT. */
25
+ projectId: z.string().optional(),
26
+ /** Base URL for the Stitch MCP server. */
27
+ baseUrl: z.string().default(DEFAULT_STITCH_API_URL),
28
+ /** Request timeout in milliseconds. Default: 300000 (5 min). */
29
+ timeout: z.number().default(300_000),
30
+ }).refine(data => {
31
+ const hasApiKey = !!data.apiKey;
32
+ const hasOAuth = !!data.accessToken && !!data.projectId;
33
+ return hasApiKey || hasOAuth;
34
+ }, {
35
+ message: "Authentication failed. Provide either 'apiKey' OR ('accessToken' + 'projectId')."
36
+ });
37
+ // ─────────────────────────────────────────────────────────────────────────────
38
+ // 2. OUTPUT SCHEMAS - What the client produces
39
+ // ─────────────────────────────────────────────────────────────────────────────
40
+ export const ToolResultSchema = z.object({
41
+ success: z.boolean(),
42
+ data: z.unknown().optional(),
43
+ error: z.string().optional(),
44
+ });
45
+ export const ToolsSchema = z.object({
46
+ tools: z.array(z.object({
47
+ name: z.string(),
48
+ description: z.string().optional(),
49
+ inputSchema: z.unknown().optional(),
50
+ })),
51
+ });
52
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/spec/client.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;A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