@apollo/client-ai-apps 0.5.4 → 0.6.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.
- package/CHANGELOG.md +180 -0
- package/dist/config/defineConfig.d.ts +1 -0
- package/dist/config/defineConfig.d.ts.map +1 -1
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/core/typeRegistration.d.ts +33 -0
- package/dist/core/typeRegistration.d.ts.map +1 -0
- package/dist/core/typeRegistration.js +2 -0
- package/dist/core/typeRegistration.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/core/McpAppManager.d.ts +2 -1
- package/dist/mcp/core/McpAppManager.d.ts.map +1 -1
- package/dist/mcp/core/McpAppManager.js +11 -1
- package/dist/mcp/core/McpAppManager.js.map +1 -1
- package/dist/mcp/react/hooks/useHostContext.d.ts +2 -0
- package/dist/mcp/react/hooks/useHostContext.d.ts.map +1 -0
- package/dist/mcp/react/hooks/useHostContext.js +7 -0
- package/dist/mcp/react/hooks/useHostContext.js.map +1 -0
- package/dist/mcp/react/hooks/useToolInfo.d.ts +3 -0
- package/dist/mcp/react/hooks/useToolInfo.d.ts.map +1 -0
- package/dist/mcp/react/hooks/useToolInfo.js +10 -0
- package/dist/mcp/react/hooks/useToolInfo.js.map +1 -0
- package/dist/mcp/react/hooks/useToolInput.d.ts +6 -1
- package/dist/mcp/react/hooks/useToolInput.d.ts.map +1 -1
- package/dist/mcp/react/hooks/useToolInput.js +4 -0
- package/dist/mcp/react/hooks/useToolInput.js.map +1 -1
- package/dist/mcp/react/hooks/useToolName.d.ts +6 -1
- package/dist/mcp/react/hooks/useToolName.d.ts.map +1 -1
- package/dist/mcp/react/hooks/useToolName.js +4 -0
- package/dist/mcp/react/hooks/useToolName.js.map +1 -1
- package/dist/mcp/react/index.d.ts +2 -0
- package/dist/mcp/react/index.d.ts.map +1 -1
- package/dist/mcp/react/index.js +2 -0
- package/dist/mcp/react/index.js.map +1 -1
- package/dist/openai/core/McpAppManager.d.ts +2 -1
- package/dist/openai/core/McpAppManager.d.ts.map +1 -1
- package/dist/openai/core/McpAppManager.js +11 -1
- package/dist/openai/core/McpAppManager.js.map +1 -1
- package/dist/openai/react/hooks/useHostContext.d.ts +2 -0
- package/dist/openai/react/hooks/useHostContext.d.ts.map +1 -0
- package/dist/openai/react/hooks/useHostContext.js +7 -0
- package/dist/openai/react/hooks/useHostContext.js.map +1 -0
- package/dist/openai/react/hooks/useToolInfo.d.ts +3 -0
- package/dist/openai/react/hooks/useToolInfo.d.ts.map +1 -0
- package/dist/openai/react/hooks/useToolInfo.js +10 -0
- package/dist/openai/react/hooks/useToolInfo.js.map +1 -0
- package/dist/openai/react/hooks/useToolInput.d.ts +6 -1
- package/dist/openai/react/hooks/useToolInput.d.ts.map +1 -1
- package/dist/openai/react/hooks/useToolInput.js +4 -0
- package/dist/openai/react/hooks/useToolInput.js.map +1 -1
- package/dist/openai/react/hooks/useToolName.d.ts +6 -1
- package/dist/openai/react/hooks/useToolName.d.ts.map +1 -1
- package/dist/openai/react/hooks/useToolName.js +4 -0
- package/dist/openai/react/hooks/useToolName.js.map +1 -1
- package/dist/openai/react/index.d.ts +2 -0
- package/dist/openai/react/index.d.ts.map +1 -1
- package/dist/openai/react/index.js +2 -0
- package/dist/openai/react/index.js.map +1 -1
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +10 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mcp.d.ts +1 -1
- package/dist/react/index.mcp.d.ts.map +1 -1
- package/dist/react/index.mcp.js +1 -1
- package/dist/react/index.mcp.js.map +1 -1
- package/dist/react/index.openai.d.ts +1 -1
- package/dist/react/index.openai.d.ts.map +1 -1
- package/dist/react/index.openai.js +1 -1
- package/dist/react/index.openai.js.map +1 -1
- package/dist/tsconfig/core/tsconfig.json +2 -0
- package/dist/tsconfig/mcp/tsconfig.json +2 -0
- package/dist/tsconfig/openai/tsconfig.json +2 -0
- package/dist/types/application-manifest.d.ts +1 -0
- package/dist/types/application-manifest.d.ts.map +1 -1
- package/dist/types/application-manifest.js.map +1 -1
- package/dist/vite/__tests__/utilities/build.d.ts.map +1 -1
- package/dist/vite/__tests__/utilities/build.js +0 -1
- package/dist/vite/__tests__/utilities/build.js.map +1 -1
- package/dist/vite/apolloClientAiApps.d.ts +2 -0
- package/dist/vite/apolloClientAiApps.d.ts.map +1 -1
- package/dist/vite/apolloClientAiApps.js +362 -53
- package/dist/vite/apolloClientAiApps.js.map +1 -1
- package/dist/vite/utilities/recast.d.ts +54 -0
- package/dist/vite/utilities/recast.d.ts.map +1 -0
- package/dist/vite/utilities/recast.js +71 -0
- package/dist/vite/utilities/recast.js.map +1 -0
- package/package.json +7 -6
- package/src/config/schema.ts +1 -0
- package/src/core/typeRegistration.ts +32 -0
- package/src/index.ts +7 -0
- package/src/mcp/core/McpAppManager.ts +23 -1
- package/src/mcp/react/hooks/__tests__/useHostContext.test.tsx +95 -0
- package/src/mcp/react/hooks/__tests__/useToolInfo.test.tsx +53 -0
- package/src/mcp/react/hooks/useHostContext.ts +14 -0
- package/src/mcp/react/hooks/useToolInfo.ts +13 -0
- package/src/mcp/react/hooks/useToolInput.ts +6 -1
- package/src/mcp/react/hooks/useToolName.ts +6 -1
- package/src/mcp/react/index.ts +2 -0
- package/src/openai/core/McpAppManager.ts +22 -1
- package/src/openai/react/hooks/__tests__/useToolInfo.test.tsx +92 -0
- package/src/openai/react/hooks/useHostContext.ts +14 -0
- package/src/openai/react/hooks/useToolInfo.ts +13 -0
- package/src/openai/react/hooks/useToolInput.ts +6 -1
- package/src/openai/react/hooks/useToolName.ts +6 -1
- package/src/openai/react/index.ts +2 -0
- package/src/react/index.mcp.ts +2 -0
- package/src/react/index.openai.ts +2 -0
- package/src/react/index.ts +14 -0
- package/src/testing/internal/mcp/mockMcpHost.ts +12 -0
- package/src/testing/internal/utilities/mockApplicationManifest.ts +1 -0
- package/src/tsconfig/core/tsconfig.json +2 -0
- package/src/tsconfig/mcp/tsconfig.json +2 -0
- package/src/tsconfig/openai/tsconfig.json +2 -0
- package/src/types/application-manifest.ts +1 -0
- package/src/vite/__tests__/apolloClientAiApps.test.ts +1022 -66
- package/src/vite/__tests__/utilities/build.ts +0 -1
- package/src/vite/apolloClientAiApps.ts +604 -81
- package/src/vite/utilities/recast.ts +100 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,183 @@
|
|
|
1
|
+
## 0.6.1 (2026-03-11)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
#### Add `useToolInfo` hook
|
|
6
|
+
|
|
7
|
+
A new `useToolInfo()` hook is now available that combines `useToolName()` and `useToolInput()` into a single hook. `useToolInfo` is more type-safe and automatically narrows the `toolInput` type based on the `toolName`.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// With toolInputs registered for "CreateTodo" and "DeleteTodo":
|
|
11
|
+
const info = useToolInfo();
|
|
12
|
+
// info: { toolName: "CreateTodo"; toolInput: CreateTodoInput }
|
|
13
|
+
// | { toolName: "DeleteTodo"; toolInput: DeleteTodoInput }
|
|
14
|
+
// | undefined
|
|
15
|
+
|
|
16
|
+
if (info?.toolName === "CreateTodo") {
|
|
17
|
+
// info.toolInput is narrowed to `CreateTodoInput`
|
|
18
|
+
doSomething(info.toolInput.title);
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
As a result, `useToolName()` and `useToolInput()` are now deprecated in favor of `useToolInfo()`. These hooks will be removed with the next major version.
|
|
23
|
+
|
|
24
|
+
#### Generate a TypeScript definition file for `.application-manifest.json`
|
|
25
|
+
|
|
26
|
+
The Vite plugin now generates a `.application-manifest.json.d.ts` TypeScript declaration file next to `.application-manifest.json`. This file declares the manifest as `ApplicationManifest`, so TypeScript infers the correct type automatically when you import it.
|
|
27
|
+
|
|
28
|
+
This removes the need to type cast the `manifest` when initializing `ApolloClient`:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// before
|
|
32
|
+
import manifest from "./.application-manifest.json";
|
|
33
|
+
|
|
34
|
+
const client = new ApolloClient({
|
|
35
|
+
manifest: manifest as ApplicationManifest, // cast required
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// after
|
|
39
|
+
import manifest from "./.application-manifest.json";
|
|
40
|
+
|
|
41
|
+
const client = new ApolloClient({
|
|
42
|
+
manifest, // type is inferred as ApplicationManifest
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> [!NOTE]
|
|
47
|
+
> This requires the TypeScript `allowArbitraryExtensions` option. Please ensure your `tsconfig.json` extends one of the provided `tsconfig`, or add these compiler options manually:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"compilerOptions": {
|
|
52
|
+
"allowArbitraryExtensions": true,
|
|
53
|
+
"resolveJsonModule": true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Add type-safe tool names
|
|
59
|
+
|
|
60
|
+
The Vite plugin now generates a `.apollo-client-ai-apps/types/register.d.ts` TypeScript declaration file. This file contains a union of all tool names found in your app's `@tool` directives.
|
|
61
|
+
|
|
62
|
+
This means the `useToolName()` hook now provides the precise union of tool names instead of `string | undefined`:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// before
|
|
66
|
+
const toolName = useToolName(); // string | undefined
|
|
67
|
+
|
|
68
|
+
// after (with @tool directives on "CreateTodo", "DeleteTodo", "UpdateTodo")
|
|
69
|
+
const toolName = useToolName(); // "CreateTodo" | "DeleteTodo" | "UpdateTodo" | undefined
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The generated file is written to `.apollo-client-ai-apps/types/register.d.ts` and is kept up to date as you edit your operations. Add this path to your `tsconfig.json` `include` to ensure these types are included:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"include": ["src", ".apollo-client-ai-apps/types"]
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You might also consider adding `.apollo-client-ai-apps/` to your `.gitignore` since it is fully generated.
|
|
81
|
+
|
|
82
|
+
The `ToolName` type is exported from `@apollo/client-ai-apps` if you need access to the available tool names for your own utilities.
|
|
83
|
+
|
|
84
|
+
#### `@tool` `name` and `description` arguments are now optional
|
|
85
|
+
|
|
86
|
+
The `name` and `description` arguments on the `@tool` directive are now optional. When omitted, they fall back to the operation name and description respectively.
|
|
87
|
+
|
|
88
|
+
```graphql
|
|
89
|
+
## name defaults to "HelloWorldQuery", description defaults to the operation description
|
|
90
|
+
"""
|
|
91
|
+
Say hello to the world.
|
|
92
|
+
"""
|
|
93
|
+
query HelloWorldQuery @tool {
|
|
94
|
+
helloWorld
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Tool `name` and `description` are still enforced and must be set either by the operation or the `@tool` arguments. An anonymous operation or an operation that omits the description while using a bare `@tool` directive fails validation.
|
|
99
|
+
|
|
100
|
+
When an operation has multiple `@tool` directives, `name` and `description` must still be provided explicitly on each directive to avoid ambiguity.
|
|
101
|
+
|
|
102
|
+
```graphql
|
|
103
|
+
## ✅ Valid — each @tool has an explicit name and description
|
|
104
|
+
query ProductsQuery
|
|
105
|
+
@tool(name: "list-products", description: "List all products")
|
|
106
|
+
@tool(name: "search-products", description: "Search products by keyword") {
|
|
107
|
+
products {
|
|
108
|
+
id
|
|
109
|
+
title
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
## ❌ Error — missing name on second @tool when multiple are present
|
|
114
|
+
query ProductsQuery
|
|
115
|
+
@tool(name: "list-products", description: "List all products")
|
|
116
|
+
@tool(description: "Search products") {
|
|
117
|
+
products {
|
|
118
|
+
id
|
|
119
|
+
title
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 0.6.0 (2026-03-06)
|
|
125
|
+
|
|
126
|
+
### Breaking Changes
|
|
127
|
+
|
|
128
|
+
#### Added a new required `appsOutDir` option to the `apolloClientAiApps` Vite plugin
|
|
129
|
+
|
|
130
|
+
The `apolloClientAiApps` Vite plugin now requires an `appsOutDir` option that controls where build output is written. The value must end with `apps` as the final path segment (e.g. `"dist/apps"`).
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
apolloClientAiApps({ targets: ["mcp"], appsOutDir: "dist/apps" });
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The plugin will now write the application manifest to `<appsOutDir>/<appName>/.application-manifest.json`, where `appName` is taken from the `name` field in your `apollo-client-ai-apps` config or `package.json`. Previously, the output location was derived from `build.outDir` in your Vite config. Setting `build.outDir` alongside this plugin will now emit a warning that it is ignored.
|
|
137
|
+
|
|
138
|
+
This option replaces `build.outDir`. Setting `build.outDir` now emits a warning and the value is ignored. To migrate, please move the path from `build.outDir` to the `appsOutDir` option in the `apolloClientAiApps` plugin.
|
|
139
|
+
|
|
140
|
+
```diff
|
|
141
|
+
// vite.config.ts
|
|
142
|
+
export default defineConfig({
|
|
143
|
+
- build: {
|
|
144
|
+
- outDir: "../../apps",
|
|
145
|
+
- },
|
|
146
|
+
plugins: [
|
|
147
|
+
apolloClientAiApps({
|
|
148
|
+
targets: ["mcp"],
|
|
149
|
+
+ appsOutDir: "../../apps" ,
|
|
150
|
+
}),
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Features
|
|
156
|
+
|
|
157
|
+
#### Add `baseUriDomains` to CSP config
|
|
158
|
+
|
|
159
|
+
Adds support for configuring `baseUriDomains` in CSP settings. Only available for MCP apps.
|
|
160
|
+
|
|
161
|
+
#### Add a `useHostContext` hook
|
|
162
|
+
|
|
163
|
+
Adds a new `useHostContext` hook that returns the current host context from the MCP host.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { useHostContext } from "@apollo/client-ai-apps/react";
|
|
167
|
+
|
|
168
|
+
function MyComponent() {
|
|
169
|
+
const hostContext = useHostContext();
|
|
170
|
+
|
|
171
|
+
// ...
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Fixes
|
|
176
|
+
|
|
177
|
+
#### `@modelcontextprotocol/ext-apps` is now a required peer dependency
|
|
178
|
+
|
|
179
|
+
`@modelcontextprotocol/ext-apps` is now a required peer dependency and must be installed along with this library.
|
|
180
|
+
|
|
1
181
|
## 0.5.4 (2026-02-27)
|
|
2
182
|
|
|
3
183
|
### Fixes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/config/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM
|
|
1
|
+
{"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/config/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;EAEnE"}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const ApolloClientAiAppsConfigSchema: z.ZodObject<{
|
|
|
10
10
|
frameDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
11
11
|
redirectDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
12
12
|
resourceDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
baseUriDomains: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
13
14
|
}, z.core.$strict>>;
|
|
14
15
|
widgetSettings: z.ZodExactOptional<z.ZodObject<{
|
|
15
16
|
prefersBorder: z.ZodExactOptional<z.ZodBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS,gCAA+B,CAAC;AAwBtD,eAAO,MAAM,8BAA8B
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS,gCAA+B,CAAC;AAwBtD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+CzC,CAAC"}
|
package/dist/config/schema.js
CHANGED
|
@@ -23,6 +23,7 @@ export const ApolloClientAiAppsConfigSchema = z.strictObject({
|
|
|
23
23
|
frameDomains: z.array(z.string()).exactOptional(),
|
|
24
24
|
redirectDomains: z.array(z.string()).exactOptional(),
|
|
25
25
|
resourceDomains: z.array(z.string()).exactOptional(),
|
|
26
|
+
baseUriDomains: z.array(z.string()).exactOptional(),
|
|
26
27
|
})),
|
|
27
28
|
widgetSettings: z.exactOptional(z.strictObject({
|
|
28
29
|
prefersBorder: z.boolean().exactOptional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEtD,MAAM,IAAI,GAAG,CAAC;KACX,OAAO,CAAC,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AE;QACvC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE;KACnC,CAAC,CACH;IACD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,EAAE;QACzC,MAAM,EAAE,GAAG,EAAE;YACX,qEAAqE;YACrE,wEAAwE;YACxE,qEAAqE;YACrE,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;YAC7B,MAAM,MAAM,GAAiC,EAAE,CAAC;YAEhD,IAAI,cAAc,EAAE,QAAQ,EAAE,CAAC;gBAC7B,MAAM,CAAC,yBAAyB,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC;YAC9D,CAAC;YAED,IAAI,cAAc,EAAE,OAAO,EAAE,CAAC;gBAC5B,MAAM,CAAC,wBAAwB,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC;YAC5D,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nexport const AppTarget = z.literal([\"mcp\", \"openai\"]);\n\nconst Mode = z\n .literal([\"development\", \"production\"])\n .or(z.custom<string & {}>((value) => typeof value === \"string\"));\n\nconst labelsInput = z.exactOptional(\n z.strictObject({\n toolInvocation: z.exactOptional(\n z.strictObject({\n invoking: z.string().exactOptional(),\n invoked: z.string().exactOptional(),\n })\n ),\n })\n);\n\nconst labelsOutput = z.exactOptional(\n z.strictObject({\n \"toolInvocation/invoking\": z.string().exactOptional(),\n \"toolInvocation/invoked\": z.string().exactOptional(),\n })\n);\n\nexport const ApolloClientAiAppsConfigSchema = z.strictObject({\n name: z.string().exactOptional(),\n description: z.string().exactOptional(),\n version: z.string().exactOptional(),\n entry: z.exactOptional(\n z.partialRecord(\n Mode,\n z.union([z.string(), z.partialRecord(AppTarget, z.string())])\n )\n ),\n csp: z.exactOptional(\n z.strictObject({\n connectDomains: z.array(z.string()).exactOptional(),\n frameDomains: z.array(z.string()).exactOptional(),\n redirectDomains: z.array(z.string()).exactOptional(),\n resourceDomains: z.array(z.string()).exactOptional(),\n baseUriDomains: z.array(z.string()).exactOptional(),\n })\n ),\n widgetSettings: z.exactOptional(\n z.strictObject({\n prefersBorder: z.boolean().exactOptional(),\n description: z.string().exactOptional(),\n domain: z.string().exactOptional(),\n })\n ),\n labels: z.codec(labelsInput, labelsOutput, {\n encode: () => {\n // encode is currently not used so we can skip the business logic and\n // return an empty object which satisfies the type. If we need to encode\n // labels back to the original form, this will need to be implemented\n return {};\n },\n decode: ({ toolInvocation }) => {\n const config: z.infer<typeof labelsOutput> = {};\n\n if (toolInvocation?.invoking) {\n config[\"toolInvocation/invoking\"] = toolInvocation.invoking;\n }\n\n if (toolInvocation?.invoked) {\n config[\"toolInvocation/invoked\"] = toolInvocation.invoked;\n }\n\n return config;\n },\n }),\n});\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Register {
|
|
2
|
+
}
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Please use the `ToolInfo` type instead. `ToolName` will be
|
|
5
|
+
* removed in the next major version.
|
|
6
|
+
*/
|
|
7
|
+
export type ToolName = Register extends {
|
|
8
|
+
toolName: infer T extends string;
|
|
9
|
+
} ? T : string;
|
|
10
|
+
type RegisteredToolInputs = Register extends {
|
|
11
|
+
toolInputs: infer T extends Record<string, unknown>;
|
|
12
|
+
} ? T : never;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Please use the `ToolInfo` type instead. `ToolInput` will be
|
|
15
|
+
* removed in the next major version.
|
|
16
|
+
*/
|
|
17
|
+
export type ToolInput = [
|
|
18
|
+
RegisteredToolInputs
|
|
19
|
+
] extends [never] ? Record<string, unknown> : RegisteredToolInputs[keyof RegisteredToolInputs];
|
|
20
|
+
type ToolInfoFromInputs<T extends Record<string, unknown>> = {
|
|
21
|
+
[K in keyof T]: {
|
|
22
|
+
toolName: K;
|
|
23
|
+
toolInput: T[K] extends Record<string, never> ? T[K] | undefined : T[K];
|
|
24
|
+
};
|
|
25
|
+
}[keyof T];
|
|
26
|
+
export type ToolInfo = [
|
|
27
|
+
RegisteredToolInputs
|
|
28
|
+
] extends [never] ? {
|
|
29
|
+
toolName: string;
|
|
30
|
+
toolInput: Record<string, unknown> | undefined;
|
|
31
|
+
} : ToolInfoFromInputs<RegisteredToolInputs>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=typeRegistration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeRegistration.d.ts","sourceRoot":"","sources":["../../src/core/typeRegistration.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;CAAG;AAE5B;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAClB,QAAQ,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAErE,KAAK,oBAAoB,GACvB,QAAQ,SAAS;IAAE,UAAU,EAAE,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,CAAC,GAC1E,KAAK,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,SAAS,GACnB;IAAC,oBAAoB;CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9D,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC;AAErD,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KAC1D,CAAC,IAAI,MAAM,CAAC,GAAG;QACd,QAAQ,EAAE,CAAC,CAAC;QACZ,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACzE;CACF,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,MAAM,MAAM,QAAQ,GAClB;IAAC,oBAAoB;CAAC,SAAS,CAAC,KAAK,CAAC,GACpC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAAE,GACpE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeRegistration.js","sourceRoot":"","sources":["../../src/core/typeRegistration.ts"],"names":[],"mappings":"","sourcesContent":["export interface Register {}\n\n/**\n * @deprecated Please use the `ToolInfo` type instead. `ToolName` will be\n * removed in the next major version.\n */\nexport type ToolName =\n Register extends { toolName: infer T extends string } ? T : string;\n\ntype RegisteredToolInputs =\n Register extends { toolInputs: infer T extends Record<string, unknown> } ? T\n : never;\n\n/**\n * @deprecated Please use the `ToolInfo` type instead. `ToolInput` will be\n * removed in the next major version.\n */\nexport type ToolInput =\n [RegisteredToolInputs] extends [never] ? Record<string, unknown>\n : RegisteredToolInputs[keyof RegisteredToolInputs];\n\ntype ToolInfoFromInputs<T extends Record<string, unknown>> = {\n [K in keyof T]: {\n toolName: K;\n toolInput: T[K] extends Record<string, never> ? T[K] | undefined : T[K];\n };\n}[keyof T];\n\nexport type ToolInfo =\n [RegisteredToolInputs] extends [never] ?\n { toolName: string; toolInput: Record<string, unknown> | undefined }\n : ToolInfoFromInputs<RegisteredToolInputs>;\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { ApplicationManifest, ManifestOperation, ManifestTool, ManifestExtraInput, ManifestCsp, ManifestLabels, ManifestWidgetSettings, } from "./types/application-manifest.js";
|
|
2
|
+
export type { Register, ToolInfo, ToolInput, ToolName, } from "./core/typeRegistration.js";
|
|
2
3
|
export { ApolloClient } from "./core/ApolloClient.js";
|
|
3
4
|
export { ToolCallLink } from "./link/ToolCallLink.js";
|
|
4
5
|
export { Platform } from "./core/Platform.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type {\n ApplicationManifest,\n ManifestOperation,\n ManifestTool,\n ManifestExtraInput,\n ManifestCsp,\n ManifestLabels,\n ManifestWidgetSettings,\n} from \"./types/application-manifest.js\";\n\nexport type {\n Register,\n ToolInfo,\n ToolInput,\n ToolName,\n} from \"./core/typeRegistration.js\";\n\nexport { ApolloClient } from \"./core/ApolloClient.js\";\nexport { ToolCallLink } from \"./link/ToolCallLink.js\";\n\nexport { Platform } from \"./core/Platform.js\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App } from "@modelcontextprotocol/ext-apps";
|
|
1
|
+
import { App, type McpUiHostContextChangedNotification } from "@modelcontextprotocol/ext-apps";
|
|
2
2
|
import type { ApplicationManifest } from "../../types/application-manifest";
|
|
3
3
|
import type { FormattedExecutionResult } from "graphql";
|
|
4
4
|
import type { DocumentNode, OperationVariables } from "@apollo/client";
|
|
@@ -11,6 +11,7 @@ export declare class McpAppManager {
|
|
|
11
11
|
get toolName(): string | undefined;
|
|
12
12
|
get toolMetadata(): ApolloMcpServerApps.Meta | undefined;
|
|
13
13
|
get toolInput(): Record<string, unknown> | undefined;
|
|
14
|
+
onHostContextChanged(cb: (params: McpUiHostContextChangedNotification["params"]) => void): () => void;
|
|
14
15
|
connect: (() => Promise<{
|
|
15
16
|
toolName: string | undefined;
|
|
16
17
|
args: Record<string, unknown> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAEH,KAAK,mCAAmC,EACzC,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D,gBAAgB;AAChB,qBAAa,aAAa;;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;gBAUN,QAAQ,EAAE,mBAAmB;IAIzC,IAAI,QAAQ,uBAEX;IAED,IAAI,YAAY,yCAEf;IAED,IAAI,SAAS,wCAEZ;IAED,oBAAoB,CAClB,EAAE,EAAE,CAAC,MAAM,EAAE,mCAAmC,CAAC,QAAQ,CAAC,KAAK,IAAI;IASrE,OAAO;;;;;;;MAyCJ;IAEH,KAAK;IAIC,YAAY,CAAC,EACjB,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;KAC3C;YASa,aAAa;CAW5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App, PostMessageTransport } from "@modelcontextprotocol/ext-apps";
|
|
1
|
+
import { App, PostMessageTransport, } from "@modelcontextprotocol/ext-apps";
|
|
2
2
|
import { print } from "@apollo/client/utilities";
|
|
3
3
|
import { cacheAsync, promiseWithResolvers } from "../../utilities";
|
|
4
4
|
/** @internal */
|
|
@@ -7,6 +7,7 @@ export class McpAppManager {
|
|
|
7
7
|
#toolName;
|
|
8
8
|
#toolMetadata;
|
|
9
9
|
#toolInput;
|
|
10
|
+
#hostContextCallbacks = new Set();
|
|
10
11
|
constructor(manifest) {
|
|
11
12
|
this.app = new App({ name: manifest.name, version: manifest.appVersion });
|
|
12
13
|
}
|
|
@@ -19,6 +20,12 @@ export class McpAppManager {
|
|
|
19
20
|
get toolInput() {
|
|
20
21
|
return this.#toolInput;
|
|
21
22
|
}
|
|
23
|
+
onHostContextChanged(cb) {
|
|
24
|
+
this.#hostContextCallbacks.add(cb);
|
|
25
|
+
return () => {
|
|
26
|
+
this.#hostContextCallbacks.delete(cb);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
22
29
|
connect = cacheAsync(async () => {
|
|
23
30
|
let toolResult = promiseWithResolvers();
|
|
24
31
|
let toolInput = promiseWithResolvers();
|
|
@@ -28,6 +35,9 @@ export class McpAppManager {
|
|
|
28
35
|
this.app.ontoolinput = (params) => {
|
|
29
36
|
toolInput.resolve(params);
|
|
30
37
|
};
|
|
38
|
+
this.app.onhostcontextchanged = (params) => {
|
|
39
|
+
this.#hostContextCallbacks.forEach((cb) => cb(params));
|
|
40
|
+
};
|
|
31
41
|
await this.connectToHost();
|
|
32
42
|
const { structuredContent, _meta } = await toolResult.promise;
|
|
33
43
|
const { arguments: args } = await toolInput.promise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpAppManager.js","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"McpAppManager.js","sourceRoot":"","sources":["../../../src/mcp/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAOnE,gBAAgB;AAChB,MAAM,OAAO,aAAa;IACf,GAAG,CAAM;IAElB,SAAS,CAAqB;IAC9B,aAAa,CAA0D;IACvE,UAAU,CAAsC;IAEhD,qBAAqB,GAAG,IAAI,GAAG,EAE5B,CAAC;IAEJ,YAAY,QAA6B;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5E,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ent":["import {\n App,\n PostMessageTransport,\n type McpUiHostContextChangedNotification,\n} from \"@modelcontextprotocol/ext-apps\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ApplicationManifest } from \"../../types/application-manifest\";\nimport type { FormattedExecutionResult } from \"graphql\";\nimport type { DocumentNode, OperationVariables } from \"@apollo/client\";\nimport { print } from \"@apollo/client/utilities\";\nimport { cacheAsync, promiseWithResolvers } from \"../../utilities\";\nimport type { ApolloMcpServerApps } from \"../../core/types\";\n\ntype ExecuteQueryCallToolResult = Omit<CallToolResult, \"structuredContent\"> & {\n structuredContent: FormattedExecutionResult;\n};\n\n/** @internal */\nexport class McpAppManager {\n readonly app: App;\n\n #toolName: string | undefined;\n #toolMetadata: ApolloMcpServerApps.CallToolResult[\"_meta\"] | undefined;\n #toolInput: Record<string, unknown> | undefined;\n\n #hostContextCallbacks = new Set<\n (params: McpUiHostContextChangedNotification[\"params\"]) => void\n >();\n\n constructor(manifest: ApplicationManifest) {\n this.app = new App({ name: manifest.name, version: manifest.appVersion });\n }\n\n get toolName() {\n return this.#toolName;\n }\n\n get toolMetadata() {\n return this.#toolMetadata;\n }\n\n get toolInput() {\n return this.#toolInput;\n }\n\n onHostContextChanged(\n cb: (params: McpUiHostContextChangedNotification[\"params\"]) => void\n ) {\n this.#hostContextCallbacks.add(cb);\n\n return () => {\n this.#hostContextCallbacks.delete(cb);\n };\n }\n\n connect = cacheAsync(async () => {\n let toolResult = promiseWithResolvers<ApolloMcpServerApps.CallToolResult>();\n let toolInput = promiseWithResolvers<Parameters<App[\"ontoolinput\"]>[0]>();\n\n this.app.ontoolresult = (params) => {\n toolResult.resolve(\n params as unknown as ApolloMcpServerApps.CallToolResult\n );\n };\n\n this.app.ontoolinput = (params) => {\n toolInput.resolve(params);\n };\n\n this.app.onhostcontextchanged = (params) => {\n this.#hostContextCallbacks.forEach((cb) => cb(params));\n };\n\n await this.connectToHost();\n\n const { structuredContent, _meta } = await toolResult.promise;\n const { arguments: args } = await toolInput.promise;\n\n // Some hosts do not provide toolInfo in the ui/initialize response, so we\n // fallback to `_meta.toolName` provided by Apollo MCP server if the value\n // is not available.\n this.#toolName =\n this.app.getHostContext()?.toolInfo?.tool.name ??\n _meta?.toolName ??\n // Some hosts do not forward `_meta` nor do they provide `toolInfo`. Our\n // MCP server provides `toolName` in `structuredContent` as a workaround\n // that we can use if all else fails\n structuredContent.toolName;\n this.#toolMetadata = _meta;\n this.#toolInput = args;\n\n return {\n ...structuredContent,\n toolName: this.toolName,\n args,\n };\n });\n\n close() {\n return this.app.close();\n }\n\n async executeQuery({\n query,\n variables,\n }: {\n query: DocumentNode;\n variables: OperationVariables | undefined;\n }) {\n const result = (await this.app.callServerTool({\n name: \"execute\",\n arguments: { query: print(query), variables },\n })) as ExecuteQueryCallToolResult;\n\n return result.structuredContent;\n }\n\n private async connectToHost() {\n try {\n return await this.app.connect(\n new PostMessageTransport(window.parent, window.parent)\n );\n } catch (e) {\n const error = e instanceof Error ? e : new Error(\"Failed to connect\");\n\n throw error;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostContext.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useHostContext.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,0EAU7B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
2
|
+
import { useApolloClient } from "./useApolloClient";
|
|
3
|
+
export function useHostContext() {
|
|
4
|
+
const appManager = useApolloClient()["appManager"];
|
|
5
|
+
return useSyncExternalStore(useCallback((update) => appManager.onHostContextChanged(update), [appManager]), () => appManager.app.getHostContext());
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=useHostContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostContext.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useHostContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,cAAc;IAC5B,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC;IAEnD,OAAO,oBAAoB,CACzB,WAAW,CACT,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,EACnD,CAAC,UAAU,CAAC,CACb,EACD,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,CACtC,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport { useApolloClient } from \"./useApolloClient\";\n\nexport function useHostContext() {\n const appManager = useApolloClient()[\"appManager\"];\n\n return useSyncExternalStore(\n useCallback(\n (update) => appManager.onHostContextChanged(update),\n [appManager]\n ),\n () => appManager.app.getHostContext()\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToolInfo.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAGlE,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CASlD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useApolloClient } from "./useApolloClient.js";
|
|
2
|
+
export function useToolInfo() {
|
|
3
|
+
const appManager = useApolloClient()["appManager"];
|
|
4
|
+
const toolName = appManager.toolName;
|
|
5
|
+
if (!toolName) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return { toolName, toolInput: appManager.toolInput };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=useToolInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToolInfo.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,UAAU,WAAW;IACzB,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IAErC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import type { ToolInfo } from \"../../../core/typeRegistration.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport function useToolInfo(): ToolInfo | undefined {\n const appManager = useApolloClient()[\"appManager\"];\n const toolName = appManager.toolName;\n\n if (!toolName) {\n return;\n }\n\n return { toolName, toolInput: appManager.toolInput };\n}\n"]}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ToolInput } from "../../../core/typeRegistration.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Please use the `useToolInfo` hook. `useToolInput` will be removed
|
|
4
|
+
* in the next major version.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useToolInput(): ToolInput | undefined;
|
|
2
7
|
//# sourceMappingURL=useToolInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolInput.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useToolInput.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAGnE;;;GAGG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,SAAS,CAEpD"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { useApolloClient } from "./useApolloClient.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Please use the `useToolInfo` hook. `useToolInput` will be removed
|
|
4
|
+
* in the next major version.
|
|
5
|
+
*/
|
|
2
6
|
export function useToolInput() {
|
|
3
7
|
return useApolloClient()["appManager"].toolInput;
|
|
4
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolInput.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useToolInput.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC","sourcesContent":["import type { ToolInput } from \"../../../core/typeRegistration.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\n/**\n * @deprecated Please use the `useToolInfo` hook. `useToolInput` will be removed\n * in the next major version.\n */\nexport function useToolInput(): ToolInput | undefined {\n return useApolloClient()[\"appManager\"].toolInput;\n}\n"]}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ToolName } from "../../../core/typeRegistration.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Please use the `useToolInfo` hook. `useToolName` will be removed
|
|
4
|
+
* in the next major version.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useToolName(): ToolName | undefined;
|
|
2
7
|
//# sourceMappingURL=useToolName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolName.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolName.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useToolName.d.ts","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAGlE;;;GAGG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAElD"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { useApolloClient } from "./useApolloClient.js";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Please use the `useToolInfo` hook. `useToolName` will be removed
|
|
4
|
+
* in the next major version.
|
|
5
|
+
*/
|
|
2
6
|
export function useToolName() {
|
|
3
7
|
return useApolloClient()["appManager"].toolName;
|
|
4
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolName.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolName.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useToolName.js","sourceRoot":"","sources":["../../../../src/mcp/react/hooks/useToolName.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,eAAe,EAAE,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC;AAClD,CAAC","sourcesContent":["import type { ToolName } from \"../../../core/typeRegistration.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\n/**\n * @deprecated Please use the `useToolInfo` hook. `useToolName` will be removed\n * in the next major version.\n */\nexport function useToolName(): ToolName | undefined {\n return useApolloClient()[\"appManager\"].toolName;\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { useApp } from "./hooks/useApp.js";
|
|
2
|
+
export { useHostContext } from "./hooks/useHostContext.js";
|
|
2
3
|
export { useToolName } from "./hooks/useToolName.js";
|
|
3
4
|
export { useToolMetadata } from "./hooks/useToolMetadata.js";
|
|
4
5
|
export { useToolInput } from "./hooks/useToolInput.js";
|
|
6
|
+
export { useToolInfo } from "./hooks/useToolInfo.js";
|
|
5
7
|
export { createHydrationUtils } from "./hooks/createHydrationUtils.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/mcp/react/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { useApp } from "./hooks/useApp.js";
|
|
2
|
+
export { useHostContext } from "./hooks/useHostContext.js";
|
|
2
3
|
export { useToolName } from "./hooks/useToolName.js";
|
|
3
4
|
export { useToolMetadata } from "./hooks/useToolMetadata.js";
|
|
4
5
|
export { useToolInput } from "./hooks/useToolInput.js";
|
|
6
|
+
export { useToolInfo } from "./hooks/useToolInfo.js";
|
|
5
7
|
export { createHydrationUtils } from "./hooks/createHydrationUtils.js";
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export { useApp } from \"./hooks/useApp.js\";\nexport { useToolName } from \"./hooks/useToolName.js\";\nexport { useToolMetadata } from \"./hooks/useToolMetadata.js\";\nexport { useToolInput } from \"./hooks/useToolInput.js\";\nexport { createHydrationUtils } from \"./hooks/createHydrationUtils.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export { useApp } from \"./hooks/useApp.js\";\nexport { useHostContext } from \"./hooks/useHostContext.js\";\nexport { useToolName } from \"./hooks/useToolName.js\";\nexport { useToolMetadata } from \"./hooks/useToolMetadata.js\";\nexport { useToolInput } from \"./hooks/useToolInput.js\";\nexport { useToolInfo } from \"./hooks/useToolInfo.js\";\nexport { createHydrationUtils } from \"./hooks/createHydrationUtils.js\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App } from "@modelcontextprotocol/ext-apps";
|
|
1
|
+
import { App, type McpUiHostContextChangedNotification } from "@modelcontextprotocol/ext-apps";
|
|
2
2
|
import type { ApplicationManifest } from "../../types/application-manifest";
|
|
3
3
|
import type { FormattedExecutionResult } from "graphql";
|
|
4
4
|
import type { DocumentNode, OperationVariables } from "@apollo/client";
|
|
@@ -10,6 +10,7 @@ export declare class McpAppManager {
|
|
|
10
10
|
get toolName(): string | undefined;
|
|
11
11
|
get toolMetadata(): Record<string, unknown> | null;
|
|
12
12
|
get toolInput(): Record<string, unknown> | undefined;
|
|
13
|
+
onHostContextChanged(cb: (params: McpUiHostContextChangedNotification["params"]) => void): () => void;
|
|
13
14
|
connect: (() => Promise<{
|
|
14
15
|
toolName: string | undefined;
|
|
15
16
|
args: Record<string, unknown> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/openai/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"McpAppManager.d.ts","sourceRoot":"","sources":["../../../src/openai/core/McpAppManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAEH,KAAK,mCAAmC,EACzC,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AASvE,gBAAgB;AAChB,qBAAa,aAAa;;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;gBAUN,QAAQ,EAAE,mBAAmB;IAIzC,IAAI,QAAQ,uBAEX;IAED,IAAI,YAAY,mCAEf;IAED,IAAI,SAAS,wCAEZ;IAED,oBAAoB,CAClB,EAAE,EAAE,CAAC,MAAM,EAAE,mCAAmC,CAAC,QAAQ,CAAC,KAAK,IAAI;IAQrE,OAAO;;;;;;;MAyCJ;IAEH,KAAK;IAIC,YAAY,CAAC,EACjB,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,YAAY,CAAC;QACpB,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;KAC3C;YASa,aAAa;CAW5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { App, PostMessageTransport } from "@modelcontextprotocol/ext-apps";
|
|
1
|
+
import { App, PostMessageTransport, } from "@modelcontextprotocol/ext-apps";
|
|
2
2
|
import { print } from "@apollo/client/utilities";
|
|
3
3
|
import { cacheAsync, promiseWithResolvers } from "../../utilities";
|
|
4
4
|
/** @internal */
|
|
@@ -7,6 +7,7 @@ export class McpAppManager {
|
|
|
7
7
|
#toolName;
|
|
8
8
|
#toolMetadata = null;
|
|
9
9
|
#toolInput;
|
|
10
|
+
#hostContextCallbacks = new Set();
|
|
10
11
|
constructor(manifest) {
|
|
11
12
|
this.app = new App({ name: manifest.name, version: manifest.appVersion });
|
|
12
13
|
}
|
|
@@ -19,11 +20,20 @@ export class McpAppManager {
|
|
|
19
20
|
get toolInput() {
|
|
20
21
|
return this.#toolInput;
|
|
21
22
|
}
|
|
23
|
+
onHostContextChanged(cb) {
|
|
24
|
+
this.#hostContextCallbacks.add(cb);
|
|
25
|
+
return () => {
|
|
26
|
+
this.#hostContextCallbacks.delete(cb);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
22
29
|
connect = cacheAsync(async () => {
|
|
23
30
|
let toolResult = promiseWithResolvers();
|
|
24
31
|
this.app.ontoolresult = (params) => {
|
|
25
32
|
toolResult.resolve(params);
|
|
26
33
|
};
|
|
34
|
+
this.app.onhostcontextchanged = (params) => {
|
|
35
|
+
this.#hostContextCallbacks.forEach((cb) => cb(params));
|
|
36
|
+
};
|
|
27
37
|
await this.connectToHost();
|
|
28
38
|
const { structuredContent } = await toolResult.promise;
|
|
29
39
|
this.#toolName = this.app.getHostContext()?.toolInfo?.tool.name;
|