@mcp-fe/react-tools 0.1.5 → 0.1.7
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/hooks/useMCPTool.d.ts +32 -2
- package/hooks/useMCPTool.d.ts.map +1 -1
- package/index.js +1 -1
- package/index.mjs +133 -108
- package/package.json +2 -2
package/hooks/useMCPTool.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolHandler } from '@mcp-fe/mcp-worker';
|
|
1
|
+
import { ToolHandler, Icon, ToolAnnotations, ToolExecution } from '@mcp-fe/mcp-worker';
|
|
2
2
|
export interface UseMCPToolOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Tool name (must be unique)
|
|
@@ -7,15 +7,45 @@ export interface UseMCPToolOptions {
|
|
|
7
7
|
/**
|
|
8
8
|
* Tool description for AI
|
|
9
9
|
*/
|
|
10
|
-
description
|
|
10
|
+
description?: string;
|
|
11
11
|
/**
|
|
12
12
|
* JSON Schema for tool inputs
|
|
13
13
|
*/
|
|
14
14
|
inputSchema: Record<string, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* JSON Schema for tool outputs (optional)
|
|
17
|
+
*/
|
|
18
|
+
outputSchema?: Record<string, unknown>;
|
|
15
19
|
/**
|
|
16
20
|
* Handler function (runs in main thread with full browser access)
|
|
17
21
|
*/
|
|
18
22
|
handler: ToolHandler;
|
|
23
|
+
/**
|
|
24
|
+
* Tool annotations (hints for AI about tool behavior)
|
|
25
|
+
* - title: Human-readable title for the tool
|
|
26
|
+
* - readOnlyHint: Indicates the tool only reads data
|
|
27
|
+
* - destructiveHint: Warns that the tool performs destructive actions
|
|
28
|
+
* - idempotentHint: Indicates multiple calls have the same effect
|
|
29
|
+
* - openWorldHint: Suggests the tool may access external systems
|
|
30
|
+
*/
|
|
31
|
+
annotations?: ToolAnnotations;
|
|
32
|
+
/**
|
|
33
|
+
* Tool execution metadata
|
|
34
|
+
* - taskSupport: Whether the tool supports task-based execution
|
|
35
|
+
*/
|
|
36
|
+
execution?: ToolExecution;
|
|
37
|
+
/**
|
|
38
|
+
* Optional metadata for extensibility
|
|
39
|
+
*/
|
|
40
|
+
_meta?: Record<string, unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* Optional icons for the tool
|
|
43
|
+
*/
|
|
44
|
+
icons?: Icon[];
|
|
45
|
+
/**
|
|
46
|
+
* Optional display title
|
|
47
|
+
*/
|
|
48
|
+
title?: string;
|
|
19
49
|
/**
|
|
20
50
|
* Whether to register immediately on mount (default: true)
|
|
21
51
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMCPTool.d.ts","sourceRoot":"","sources":["../../../../libs/react-tools/src/hooks/useMCPTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"useMCPTool.d.ts","sourceRoot":"","sources":["../../../../libs/react-tools/src/hooks/useMCPTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvC;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B;;OAEG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAuKvE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,GACX;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAEpD"}
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),f=require("@mcp-fe/mcp-worker"),D=require("react/jsx-runtime");function m(r){const{name:t,description:s,inputSchema:c,outputSchema:n,handler:l,annotations:u,execution:C,_meta:g,icons:d,title:P,autoRegister:T=!0,autoUnregister:S=!0}=r,[h,a]=e.useState(null),i=e.useRef(l),R=e.useRef(t),w=e.useRef(s),k=e.useRef(c),p=e.useRef(n),v=e.useRef(u),b=e.useRef(C),I=e.useRef(g),E=e.useRef(d),z=e.useRef(P),N=e.useRef(!0),y=e.useRef(!1);e.useEffect(()=>{i.current=l,R.current=t,w.current=s,k.current=c,p.current=n,v.current=u,b.current=C,I.current=g,E.current=d,z.current=P},[l,t,s,c,n,u,C,g,d,P]);const A=e.useCallback(async o=>i.current(o),[]),q=e.useCallback(async()=>{const o=R.current,M=w.current,H=k.current,O=p.current,U=v.current,F=b.current,G=I.current,J=E.current,_=z.current;try{await f.workerClient.registerTool(o,M,H,A,{outputSchema:O,annotations:U,execution:F,_meta:G,icons:J,title:_}),y.current=!0,console.log(`[useMCPTool] Registered tool '${o}'`)}catch(j){throw console.error(`[useMCPTool] Failed to register tool '${o}':`,j),j}},[A]),$=e.useCallback(async()=>{const o=R.current;try{await f.workerClient.unregisterTool(o),y.current=!1,console.log(`[useMCPTool] Unregistered tool '${o}'`)}catch(M){console.error(`[useMCPTool] Failed to unregister tool '${o}':`,M)}},[]);return e.useEffect(()=>f.workerClient.onToolChange(t,M=>{a(M)}),[t]),e.useEffect(()=>(T&&q().catch(o=>{console.error(`[useMCPTool] Auto-register failed for '${t}':`,o)}),()=>{N.current=!1,S&&y.current&&$().catch(o=>{console.error(`[useMCPTool] Auto-unregister failed for '${t}':`,o)})}),[t]),{isRegistered:h?.isRegistered??!1,refCount:h?.refCount??0,register:q,unregister:$}}function W(r){return f.workerClient.isToolRegistered(r)}function B(){return f.workerClient.getRegisteredTools()}function K(r){return f.workerClient.getToolInfo(r)}function L(r,t,s,c){const n=e.useCallback(async()=>{const l=await s();return{content:[{type:"text",text:JSON.stringify(l,null,2)}]}},[s]);return m({name:r,description:t,inputSchema:{type:"object",properties:{}},handler:n,...c})}function Q(r,t,s,c,n){const l=e.useCallback(async u=>{const C=await c(u);return{content:[{type:"text",text:JSON.stringify(C,null,2)}]}},[c]);return m({name:r,description:t,inputSchema:{type:"object",properties:s,...n?.required&&{required:n.required}},handler:l,autoRegister:n?.autoRegister,autoUnregister:n?.autoUnregister})}const x=e.createContext(null);function V({children:r,autoInit:t=!0,backendWsUrl:s="ws://localhost:3001",initOptions:c,onInitialized:n,onInitError:l}){const[u,C]=e.useState(!1),[g,d]=e.useState(!1),[P]=e.useState([]),T=e.useCallback(async a=>{if(u){console.log("[MCPToolsProvider] Already initialized");return}try{const i=a||c||{backendWsUrl:s};console.log("[MCPToolsProvider] Initializing worker client...",i),await f.workerClient.init(i),C(!0);const R=await f.workerClient.getConnectionStatus();d(R),f.workerClient.onConnectionStatus(w=>{d(w)}),console.log("[MCPToolsProvider] Worker client initialized"),n?.()}catch(i){throw console.error("[MCPToolsProvider] Initialization failed:",i),l?.(i instanceof Error?i:new Error(String(i))),i}},[u,c,s,n,l]),S=e.useCallback(async()=>{const a=await f.workerClient.getConnectionStatus();return d(a),a},[]);e.useEffect(()=>{t&&T().catch(a=>{console.error("[MCPToolsProvider] Auto-init failed:",a)})},[t,T]),e.useEffect(()=>{if(!u)return;const a=setInterval(()=>{},5e3);return()=>clearInterval(a)},[u]);const h={isInitialized:u,isConnected:g,registeredTools:P,initialize:T,getConnectionStatus:S};return D.jsx(x.Provider,{value:h,children:r})}function X(r=!1){const t=e.useContext(x);if(!t&&r)throw new Error("useMCPToolsContext must be used within MCPToolsProvider. Either wrap your component tree with <MCPToolsProvider> or set strict=false.");return t||{isInitialized:!1,isConnected:!1,registeredTools:[],initialize:async()=>{throw new Error("MCPToolsProvider not found")},getConnectionStatus:async()=>!1}}function Y(){return e.useContext(x)!==null}exports.MCPToolsProvider=V;exports.getRegisteredTools=B;exports.getToolInfo=K;exports.isToolRegistered=W;exports.useHasMCPProvider=Y;exports.useMCPAction=Q;exports.useMCPGetter=L;exports.useMCPTool=m;exports.useMCPToolsContext=X;
|
package/index.mjs
CHANGED
|
@@ -1,76 +1,101 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { workerClient as
|
|
3
|
-
import { jsx as
|
|
4
|
-
function
|
|
1
|
+
import { useState as y, useRef as n, useEffect as R, useCallback as C, createContext as Q, useContext as F } from "react";
|
|
2
|
+
import { workerClient as f } from "@mcp-fe/mcp-worker";
|
|
3
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
4
|
+
function H(t) {
|
|
5
5
|
const {
|
|
6
6
|
name: e,
|
|
7
7
|
description: s,
|
|
8
|
-
inputSchema:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
g
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
inputSchema: c,
|
|
9
|
+
outputSchema: o,
|
|
10
|
+
handler: a,
|
|
11
|
+
annotations: i,
|
|
12
|
+
execution: d,
|
|
13
|
+
_meta: P,
|
|
14
|
+
icons: g,
|
|
15
|
+
title: T,
|
|
16
|
+
autoRegister: h = !0,
|
|
17
|
+
autoUnregister: x = !0
|
|
18
|
+
} = t, [p, l] = y(null), u = n(a), m = n(e), w = n(s), I = n(c), b = n(o), z = n(i), A = n(d), E = n(P), $ = n(g), N = n(T), J = n(!0), S = n(!1);
|
|
19
|
+
R(() => {
|
|
20
|
+
u.current = a, m.current = e, w.current = s, I.current = c, b.current = o, z.current = i, A.current = d, E.current = P, $.current = g, N.current = T;
|
|
21
|
+
}, [
|
|
22
|
+
a,
|
|
23
|
+
e,
|
|
24
|
+
s,
|
|
25
|
+
c,
|
|
26
|
+
o,
|
|
27
|
+
i,
|
|
28
|
+
d,
|
|
29
|
+
P,
|
|
30
|
+
g,
|
|
31
|
+
T
|
|
32
|
+
]);
|
|
33
|
+
const j = C(async (r) => u.current(r), []), k = C(async () => {
|
|
34
|
+
const r = m.current, M = w.current, O = I.current, _ = b.current, D = z.current, G = A.current, B = E.current, K = $.current, L = N.current;
|
|
18
35
|
try {
|
|
19
|
-
await
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
await f.registerTool(
|
|
37
|
+
r,
|
|
38
|
+
M,
|
|
39
|
+
O,
|
|
40
|
+
j,
|
|
41
|
+
{
|
|
42
|
+
outputSchema: _,
|
|
43
|
+
annotations: D,
|
|
44
|
+
execution: G,
|
|
45
|
+
_meta: B,
|
|
46
|
+
icons: K,
|
|
47
|
+
title: L
|
|
48
|
+
}
|
|
49
|
+
), S.current = !0, console.log(`[useMCPTool] Registered tool '${r}'`);
|
|
50
|
+
} catch (U) {
|
|
26
51
|
throw console.error(
|
|
27
|
-
`[useMCPTool] Failed to register tool '${
|
|
28
|
-
|
|
29
|
-
),
|
|
52
|
+
`[useMCPTool] Failed to register tool '${r}':`,
|
|
53
|
+
U
|
|
54
|
+
), U;
|
|
30
55
|
}
|
|
31
|
-
}, [
|
|
32
|
-
const
|
|
56
|
+
}, [j]), q = C(async () => {
|
|
57
|
+
const r = m.current;
|
|
33
58
|
try {
|
|
34
|
-
await
|
|
35
|
-
} catch (
|
|
59
|
+
await f.unregisterTool(r), S.current = !1, console.log(`[useMCPTool] Unregistered tool '${r}'`);
|
|
60
|
+
} catch (M) {
|
|
36
61
|
console.error(
|
|
37
|
-
`[useMCPTool] Failed to unregister tool '${
|
|
38
|
-
|
|
62
|
+
`[useMCPTool] Failed to unregister tool '${r}':`,
|
|
63
|
+
M
|
|
39
64
|
);
|
|
40
65
|
}
|
|
41
66
|
}, []);
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
}), [e]),
|
|
67
|
+
return R(() => f.onToolChange(e, (M) => {
|
|
68
|
+
l(M);
|
|
69
|
+
}), [e]), R(() => (h && k().catch((r) => {
|
|
45
70
|
console.error(
|
|
46
71
|
`[useMCPTool] Auto-register failed for '${e}':`,
|
|
47
|
-
|
|
72
|
+
r
|
|
48
73
|
);
|
|
49
74
|
}), () => {
|
|
50
|
-
|
|
75
|
+
J.current = !1, x && S.current && q().catch((r) => {
|
|
51
76
|
console.error(
|
|
52
77
|
`[useMCPTool] Auto-unregister failed for '${e}':`,
|
|
53
|
-
|
|
78
|
+
r
|
|
54
79
|
);
|
|
55
80
|
});
|
|
56
81
|
}), [e]), {
|
|
57
|
-
isRegistered:
|
|
58
|
-
refCount:
|
|
59
|
-
register:
|
|
60
|
-
unregister:
|
|
82
|
+
isRegistered: p?.isRegistered ?? !1,
|
|
83
|
+
refCount: p?.refCount ?? 0,
|
|
84
|
+
register: k,
|
|
85
|
+
unregister: q
|
|
61
86
|
};
|
|
62
87
|
}
|
|
63
|
-
function
|
|
64
|
-
return
|
|
88
|
+
function Z(t) {
|
|
89
|
+
return f.isToolRegistered(t);
|
|
65
90
|
}
|
|
66
|
-
function
|
|
67
|
-
return
|
|
91
|
+
function ee() {
|
|
92
|
+
return f.getRegisteredTools();
|
|
68
93
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
94
|
+
function te(t) {
|
|
95
|
+
return f.getToolInfo(t);
|
|
71
96
|
}
|
|
72
|
-
function
|
|
73
|
-
const
|
|
97
|
+
function re(t, e, s, c) {
|
|
98
|
+
const o = C(async () => {
|
|
74
99
|
const a = await s();
|
|
75
100
|
return {
|
|
76
101
|
content: [
|
|
@@ -81,21 +106,21 @@ function F(t, e, s, i) {
|
|
|
81
106
|
]
|
|
82
107
|
};
|
|
83
108
|
}, [s]);
|
|
84
|
-
return
|
|
109
|
+
return H({
|
|
85
110
|
name: t,
|
|
86
111
|
description: e,
|
|
87
112
|
inputSchema: {
|
|
88
113
|
type: "object",
|
|
89
114
|
properties: {}
|
|
90
115
|
},
|
|
91
|
-
handler:
|
|
92
|
-
...
|
|
116
|
+
handler: o,
|
|
117
|
+
...c
|
|
93
118
|
});
|
|
94
119
|
}
|
|
95
|
-
function
|
|
96
|
-
const a =
|
|
97
|
-
async (
|
|
98
|
-
const d = await i
|
|
120
|
+
function oe(t, e, s, c, o) {
|
|
121
|
+
const a = C(
|
|
122
|
+
async (i) => {
|
|
123
|
+
const d = await c(i);
|
|
99
124
|
return {
|
|
100
125
|
content: [
|
|
101
126
|
{
|
|
@@ -105,75 +130,75 @@ function H(t, e, s, i, r) {
|
|
|
105
130
|
]
|
|
106
131
|
};
|
|
107
132
|
},
|
|
108
|
-
[
|
|
133
|
+
[c]
|
|
109
134
|
);
|
|
110
|
-
return
|
|
135
|
+
return H({
|
|
111
136
|
name: t,
|
|
112
137
|
description: e,
|
|
113
138
|
inputSchema: {
|
|
114
139
|
type: "object",
|
|
115
140
|
properties: s,
|
|
116
|
-
...
|
|
141
|
+
...o?.required && { required: o.required }
|
|
117
142
|
},
|
|
118
143
|
handler: a,
|
|
119
|
-
autoRegister:
|
|
120
|
-
autoUnregister:
|
|
144
|
+
autoRegister: o?.autoRegister,
|
|
145
|
+
autoUnregister: o?.autoUnregister
|
|
121
146
|
});
|
|
122
147
|
}
|
|
123
|
-
const
|
|
124
|
-
function
|
|
148
|
+
const v = Q(null);
|
|
149
|
+
function ne({
|
|
125
150
|
children: t,
|
|
126
151
|
autoInit: e = !0,
|
|
127
152
|
backendWsUrl: s = "ws://localhost:3001",
|
|
128
|
-
initOptions:
|
|
129
|
-
onInitialized:
|
|
153
|
+
initOptions: c,
|
|
154
|
+
onInitialized: o,
|
|
130
155
|
onInitError: a
|
|
131
156
|
}) {
|
|
132
|
-
const [
|
|
133
|
-
async (
|
|
134
|
-
if (
|
|
157
|
+
const [i, d] = y(!1), [P, g] = y(!1), [T] = y([]), h = C(
|
|
158
|
+
async (l) => {
|
|
159
|
+
if (i) {
|
|
135
160
|
console.log("[MCPToolsProvider] Already initialized");
|
|
136
161
|
return;
|
|
137
162
|
}
|
|
138
163
|
try {
|
|
139
|
-
const
|
|
140
|
-
console.log("[MCPToolsProvider] Initializing worker client...",
|
|
141
|
-
const
|
|
142
|
-
g(
|
|
143
|
-
g(
|
|
144
|
-
}), console.log("[MCPToolsProvider] Worker client initialized"),
|
|
145
|
-
} catch (
|
|
146
|
-
throw console.error("[MCPToolsProvider] Initialization failed:",
|
|
147
|
-
|
|
148
|
-
),
|
|
164
|
+
const u = l || c || { backendWsUrl: s };
|
|
165
|
+
console.log("[MCPToolsProvider] Initializing worker client...", u), await f.init(u), d(!0);
|
|
166
|
+
const m = await f.getConnectionStatus();
|
|
167
|
+
g(m), f.onConnectionStatus((w) => {
|
|
168
|
+
g(w);
|
|
169
|
+
}), console.log("[MCPToolsProvider] Worker client initialized"), o?.();
|
|
170
|
+
} catch (u) {
|
|
171
|
+
throw console.error("[MCPToolsProvider] Initialization failed:", u), a?.(
|
|
172
|
+
u instanceof Error ? u : new Error(String(u))
|
|
173
|
+
), u;
|
|
149
174
|
}
|
|
150
175
|
},
|
|
151
|
-
[
|
|
152
|
-
),
|
|
153
|
-
const
|
|
154
|
-
return g(
|
|
176
|
+
[i, c, s, o, a]
|
|
177
|
+
), x = C(async () => {
|
|
178
|
+
const l = await f.getConnectionStatus();
|
|
179
|
+
return g(l), l;
|
|
155
180
|
}, []);
|
|
156
|
-
|
|
157
|
-
e &&
|
|
158
|
-
console.error("[MCPToolsProvider] Auto-init failed:",
|
|
181
|
+
R(() => {
|
|
182
|
+
e && h().catch((l) => {
|
|
183
|
+
console.error("[MCPToolsProvider] Auto-init failed:", l);
|
|
159
184
|
});
|
|
160
|
-
}, [e,
|
|
161
|
-
if (!
|
|
162
|
-
const
|
|
185
|
+
}, [e, h]), R(() => {
|
|
186
|
+
if (!i) return;
|
|
187
|
+
const l = setInterval(() => {
|
|
163
188
|
}, 5e3);
|
|
164
|
-
return () => clearInterval(
|
|
165
|
-
}, [
|
|
166
|
-
const
|
|
167
|
-
isInitialized:
|
|
168
|
-
isConnected:
|
|
189
|
+
return () => clearInterval(l);
|
|
190
|
+
}, [i]);
|
|
191
|
+
const p = {
|
|
192
|
+
isInitialized: i,
|
|
193
|
+
isConnected: P,
|
|
169
194
|
registeredTools: T,
|
|
170
|
-
initialize:
|
|
171
|
-
getConnectionStatus:
|
|
195
|
+
initialize: h,
|
|
196
|
+
getConnectionStatus: x
|
|
172
197
|
};
|
|
173
|
-
return /* @__PURE__ */
|
|
198
|
+
return /* @__PURE__ */ V(v.Provider, { value: p, children: t });
|
|
174
199
|
}
|
|
175
|
-
function
|
|
176
|
-
const e =
|
|
200
|
+
function se(t = !1) {
|
|
201
|
+
const e = F(v);
|
|
177
202
|
if (!e && t)
|
|
178
203
|
throw new Error(
|
|
179
204
|
"useMCPToolsContext must be used within MCPToolsProvider. Either wrap your component tree with <MCPToolsProvider> or set strict=false."
|
|
@@ -188,17 +213,17 @@ function D(t = !1) {
|
|
|
188
213
|
getConnectionStatus: async () => !1
|
|
189
214
|
};
|
|
190
215
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
216
|
+
function ce() {
|
|
217
|
+
return F(v) !== null;
|
|
193
218
|
}
|
|
194
219
|
export {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
220
|
+
ne as MCPToolsProvider,
|
|
221
|
+
ee as getRegisteredTools,
|
|
222
|
+
te as getToolInfo,
|
|
223
|
+
Z as isToolRegistered,
|
|
224
|
+
ce as useHasMCPProvider,
|
|
225
|
+
oe as useMCPAction,
|
|
226
|
+
re as useMCPGetter,
|
|
227
|
+
H as useMCPTool,
|
|
228
|
+
se as useMCPToolsContext
|
|
204
229
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-fe/react-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://mcp-fe.ai",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@mcp-fe/mcp-worker": "^0.1.
|
|
22
|
+
"@mcp-fe/mcp-worker": "^0.1.7",
|
|
23
23
|
"react": "^19.0.0",
|
|
24
24
|
"react-dom": "^19.0.0"
|
|
25
25
|
},
|