File size: 701 Bytes
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"use client";

import {useState} from "react";
import mcp from "../services/mcp/client";

export default function useMCP(){

const [loading,setLoading]=useState(false);

async function exec(fn,...args){

setLoading(true);

try{

const {data}=await fn(...args);
return data;

}finally{

setLoading(false);

}

}

return{

loading,

servers:(...a)=>exec(mcp.servers,...a),

tools:(...a)=>exec(mcp.tools,...a),

resources:(...a)=>exec(mcp.resources,...a),

prompts:(...a)=>exec(mcp.prompts,...a),

connect:(...a)=>exec(mcp.connect,...a),

disconnect:(...a)=>exec(mcp.disconnect,...a),

invoke:(...a)=>exec(mcp.invoke,...a),

status:(...a)=>exec(mcp.status,...a),

logs:(...a)=>exec(mcp.logs,...a)

};

}