@ubuligan/react 0.1.0
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/LICENSE +21 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +124 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jsznpm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
|
+
import * as _modelcontextprotocol_sdk_client from '@modelcontextprotocol/sdk/client';
|
|
5
|
+
import { CallToolResult, ListPromptsResult, ListResourcesResult, ListToolsResult } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
|
|
7
|
+
interface MCPContextValue {
|
|
8
|
+
/** The connected SDK client, or null until the connection is established. */
|
|
9
|
+
client: Client | null;
|
|
10
|
+
connected: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
}
|
|
13
|
+
interface MCPProviderProps {
|
|
14
|
+
/** Streamable HTTP endpoint of the MCP server. */
|
|
15
|
+
url: string;
|
|
16
|
+
/** Optional request headers (e.g. auth). */
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
/** Client identity advertised to the server. */
|
|
19
|
+
name?: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Connects to an MCP server over Streamable HTTP and exposes the client via
|
|
25
|
+
* context. Browser-only transport — stdio is not available in the browser.
|
|
26
|
+
*/
|
|
27
|
+
declare function MCPProvider({ url, headers, name, version, children }: MCPProviderProps): react.JSX.Element;
|
|
28
|
+
/** Access the raw MCP context (client + connection state). */
|
|
29
|
+
declare function useMCPContext(): MCPContextValue;
|
|
30
|
+
|
|
31
|
+
/** The connected client plus connection state. */
|
|
32
|
+
declare function useMCPClient(): {
|
|
33
|
+
client: _modelcontextprotocol_sdk_client.Client<{
|
|
34
|
+
method: string;
|
|
35
|
+
params?: {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
_meta?: {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
progressToken?: string | number | undefined;
|
|
40
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
41
|
+
taskId: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
method: string;
|
|
47
|
+
params?: {
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
_meta?: {
|
|
50
|
+
[x: string]: unknown;
|
|
51
|
+
progressToken?: string | number | undefined;
|
|
52
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
53
|
+
taskId: string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
} | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
[x: string]: unknown;
|
|
59
|
+
_meta?: {
|
|
60
|
+
[x: string]: unknown;
|
|
61
|
+
progressToken?: string | number | undefined;
|
|
62
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
63
|
+
taskId: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
} | undefined;
|
|
66
|
+
}> | null;
|
|
67
|
+
connected: boolean;
|
|
68
|
+
error: Error | null;
|
|
69
|
+
};
|
|
70
|
+
interface AsyncState<T> {
|
|
71
|
+
data: T | null;
|
|
72
|
+
loading: boolean;
|
|
73
|
+
error: Error | null;
|
|
74
|
+
refresh: () => void;
|
|
75
|
+
}
|
|
76
|
+
/** List the server's tools. Re-runs when the connection changes. */
|
|
77
|
+
declare function useTools(): AsyncState<ListToolsResult>;
|
|
78
|
+
/** List the server's resources. */
|
|
79
|
+
declare function useResources(): AsyncState<ListResourcesResult>;
|
|
80
|
+
/** List the server's prompts. */
|
|
81
|
+
declare function usePrompts(): AsyncState<ListPromptsResult>;
|
|
82
|
+
interface UseToolResult {
|
|
83
|
+
call: (args?: Record<string, unknown>) => Promise<CallToolResult | undefined>;
|
|
84
|
+
data: CallToolResult | null;
|
|
85
|
+
loading: boolean;
|
|
86
|
+
error: Error | null;
|
|
87
|
+
}
|
|
88
|
+
/** Get a typed `call` function plus state for a single tool. */
|
|
89
|
+
declare function useTool(name: string): UseToolResult;
|
|
90
|
+
|
|
91
|
+
export { type MCPContextValue, MCPProvider, type MCPProviderProps, type UseToolResult, useMCPClient, useMCPContext, usePrompts, useResources, useTool, useTools };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// src/context.tsx
|
|
2
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var MCPContext = createContext(null);
|
|
7
|
+
function MCPProvider({ url, headers, name, version, children }) {
|
|
8
|
+
const [client, setClient] = useState(null);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const activeRef = useRef(0);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const token = ++activeRef.current;
|
|
13
|
+
const c = new Client({ name: name ?? "mcp-toolkit-react", version: version ?? "0.1.0" });
|
|
14
|
+
const transport = new StreamableHTTPClientTransport(new URL(url), {
|
|
15
|
+
requestInit: headers ? { headers } : void 0
|
|
16
|
+
});
|
|
17
|
+
setClient(null);
|
|
18
|
+
setError(null);
|
|
19
|
+
c.connect(transport).then(() => {
|
|
20
|
+
if (token === activeRef.current) setClient(c);
|
|
21
|
+
else void c.close();
|
|
22
|
+
}).catch((e) => {
|
|
23
|
+
if (token === activeRef.current) setError(e instanceof Error ? e : new Error(String(e)));
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
activeRef.current++;
|
|
27
|
+
void c.close().catch(() => {
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}, [url, headers, name, version]);
|
|
31
|
+
return /* @__PURE__ */ jsx(MCPContext.Provider, { value: { client, connected: client !== null, error }, children });
|
|
32
|
+
}
|
|
33
|
+
function useMCPContext() {
|
|
34
|
+
const ctx = useContext(MCPContext);
|
|
35
|
+
if (!ctx) throw new Error("useMCPContext must be used within <MCPProvider>");
|
|
36
|
+
return ctx;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/hooks.ts
|
|
40
|
+
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
41
|
+
function useMCPClient() {
|
|
42
|
+
const { client, connected, error } = useMCPContext();
|
|
43
|
+
return { client, connected, error };
|
|
44
|
+
}
|
|
45
|
+
function useListQuery(fetcher) {
|
|
46
|
+
const [data, setData] = useState2(null);
|
|
47
|
+
const [loading, setLoading] = useState2(false);
|
|
48
|
+
const [error, setError] = useState2(null);
|
|
49
|
+
const [nonce, setNonce] = useState2(0);
|
|
50
|
+
useEffect2(() => {
|
|
51
|
+
const signal = { cancelled: false };
|
|
52
|
+
const promise = fetcher(signal);
|
|
53
|
+
if (!promise) return;
|
|
54
|
+
setLoading(true);
|
|
55
|
+
setError(null);
|
|
56
|
+
promise.then((result) => {
|
|
57
|
+
if (!signal.cancelled) setData(result);
|
|
58
|
+
}).catch((e) => {
|
|
59
|
+
if (!signal.cancelled) setError(e instanceof Error ? e : new Error(String(e)));
|
|
60
|
+
}).finally(() => {
|
|
61
|
+
if (!signal.cancelled) setLoading(false);
|
|
62
|
+
});
|
|
63
|
+
return () => {
|
|
64
|
+
signal.cancelled = true;
|
|
65
|
+
};
|
|
66
|
+
}, [nonce, fetcher]);
|
|
67
|
+
const refresh = useCallback(() => setNonce((n) => n + 1), []);
|
|
68
|
+
return { data, loading, error, refresh };
|
|
69
|
+
}
|
|
70
|
+
function useTools() {
|
|
71
|
+
const { client } = useMCPContext();
|
|
72
|
+
const fetcher = useCallback(() => client ? client.listTools() : null, [client]);
|
|
73
|
+
return useListQuery(fetcher);
|
|
74
|
+
}
|
|
75
|
+
function useResources() {
|
|
76
|
+
const { client } = useMCPContext();
|
|
77
|
+
const fetcher = useCallback(() => client ? client.listResources() : null, [client]);
|
|
78
|
+
return useListQuery(fetcher);
|
|
79
|
+
}
|
|
80
|
+
function usePrompts() {
|
|
81
|
+
const { client } = useMCPContext();
|
|
82
|
+
const fetcher = useCallback(() => client ? client.listPrompts() : null, [client]);
|
|
83
|
+
return useListQuery(fetcher);
|
|
84
|
+
}
|
|
85
|
+
function useTool(name) {
|
|
86
|
+
const { client } = useMCPContext();
|
|
87
|
+
const [data, setData] = useState2(null);
|
|
88
|
+
const [loading, setLoading] = useState2(false);
|
|
89
|
+
const [error, setError] = useState2(null);
|
|
90
|
+
const call = useCallback(
|
|
91
|
+
async (args) => {
|
|
92
|
+
if (!client) {
|
|
93
|
+
const err = new Error("MCP client is not connected");
|
|
94
|
+
setError(err);
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
setLoading(true);
|
|
98
|
+
setError(null);
|
|
99
|
+
try {
|
|
100
|
+
const result = await client.callTool({ name, arguments: args ?? {} });
|
|
101
|
+
setData(result);
|
|
102
|
+
return result;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
105
|
+
setError(err);
|
|
106
|
+
throw err;
|
|
107
|
+
} finally {
|
|
108
|
+
setLoading(false);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
[client, name]
|
|
112
|
+
);
|
|
113
|
+
return { call, data, loading, error };
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
MCPProvider,
|
|
117
|
+
useMCPClient,
|
|
118
|
+
useMCPContext,
|
|
119
|
+
usePrompts,
|
|
120
|
+
useResources,
|
|
121
|
+
useTool,
|
|
122
|
+
useTools
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.tsx","../src/hooks.ts"],"sourcesContent":["import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\nexport interface MCPContextValue {\n /** The connected SDK client, or null until the connection is established. */\n client: Client | null;\n connected: boolean;\n error: Error | null;\n}\n\nconst MCPContext = createContext<MCPContextValue | null>(null);\n\nexport interface MCPProviderProps {\n /** Streamable HTTP endpoint of the MCP server. */\n url: string;\n /** Optional request headers (e.g. auth). */\n headers?: Record<string, string>;\n /** Client identity advertised to the server. */\n name?: string;\n version?: string;\n children: ReactNode;\n}\n\n/**\n * Connects to an MCP server over Streamable HTTP and exposes the client via\n * context. Browser-only transport — stdio is not available in the browser.\n */\nexport function MCPProvider({ url, headers, name, version, children }: MCPProviderProps) {\n const [client, setClient] = useState<Client | null>(null);\n const [error, setError] = useState<Error | null>(null);\n // Avoid double-connect under React 18 StrictMode dev double-invoke.\n const activeRef = useRef(0);\n\n useEffect(() => {\n const token = ++activeRef.current;\n const c = new Client({ name: name ?? \"mcp-toolkit-react\", version: version ?? \"0.1.0\" });\n const transport = new StreamableHTTPClientTransport(new URL(url), {\n requestInit: headers ? { headers } : undefined,\n });\n\n setClient(null);\n setError(null);\n\n c.connect(transport)\n .then(() => {\n if (token === activeRef.current) setClient(c);\n else void c.close();\n })\n .catch((e) => {\n if (token === activeRef.current) setError(e instanceof Error ? e : new Error(String(e)));\n });\n\n return () => {\n activeRef.current++;\n void c.close().catch(() => {});\n };\n }, [url, headers, name, version]);\n\n return (\n <MCPContext.Provider value={{ client, connected: client !== null, error }}>\n {children}\n </MCPContext.Provider>\n );\n}\n\n/** Access the raw MCP context (client + connection state). */\nexport function useMCPContext(): MCPContextValue {\n const ctx = useContext(MCPContext);\n if (!ctx) throw new Error(\"useMCPContext must be used within <MCPProvider>\");\n return ctx;\n}\n","import { useCallback, useEffect, useState } from \"react\";\nimport type {\n CallToolResult,\n ListPromptsResult,\n ListResourcesResult,\n ListToolsResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { useMCPContext } from \"./context.js\";\n\n/** The connected client plus connection state. */\nexport function useMCPClient() {\n const { client, connected, error } = useMCPContext();\n return { client, connected, error };\n}\n\ninterface AsyncState<T> {\n data: T | null;\n loading: boolean;\n error: Error | null;\n refresh: () => void;\n}\n\nfunction useListQuery<T>(fetcher: (signal: { cancelled: boolean }) => Promise<T> | null): AsyncState<T> {\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [nonce, setNonce] = useState(0);\n\n useEffect(() => {\n const signal = { cancelled: false };\n const promise = fetcher(signal);\n if (!promise) return;\n setLoading(true);\n setError(null);\n promise\n .then((result) => {\n if (!signal.cancelled) setData(result);\n })\n .catch((e) => {\n if (!signal.cancelled) setError(e instanceof Error ? e : new Error(String(e)));\n })\n .finally(() => {\n if (!signal.cancelled) setLoading(false);\n });\n return () => {\n signal.cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [nonce, fetcher]);\n\n const refresh = useCallback(() => setNonce((n) => n + 1), []);\n return { data, loading, error, refresh };\n}\n\n/** List the server's tools. Re-runs when the connection changes. */\nexport function useTools(): AsyncState<ListToolsResult> {\n const { client } = useMCPContext();\n const fetcher = useCallback(() => (client ? client.listTools() : null), [client]);\n return useListQuery(fetcher);\n}\n\n/** List the server's resources. */\nexport function useResources(): AsyncState<ListResourcesResult> {\n const { client } = useMCPContext();\n const fetcher = useCallback(() => (client ? client.listResources() : null), [client]);\n return useListQuery(fetcher);\n}\n\n/** List the server's prompts. */\nexport function usePrompts(): AsyncState<ListPromptsResult> {\n const { client } = useMCPContext();\n const fetcher = useCallback(() => (client ? client.listPrompts() : null), [client]);\n return useListQuery(fetcher);\n}\n\nexport interface UseToolResult {\n call: (args?: Record<string, unknown>) => Promise<CallToolResult | undefined>;\n data: CallToolResult | null;\n loading: boolean;\n error: Error | null;\n}\n\n/** Get a typed `call` function plus state for a single tool. */\nexport function useTool(name: string): UseToolResult {\n const { client } = useMCPContext();\n const [data, setData] = useState<CallToolResult | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const call = useCallback(\n async (args?: Record<string, unknown>) => {\n if (!client) {\n const err = new Error(\"MCP client is not connected\");\n setError(err);\n throw err;\n }\n setLoading(true);\n setError(null);\n try {\n const result = (await client.callTool({ name, arguments: args ?? {} })) as CallToolResult;\n setData(result);\n return result;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n throw err;\n } finally {\n setLoading(false);\n }\n },\n [client, name],\n );\n\n return { call, data, loading, error };\n}\n"],"mappings":";AAAA,SAAS,eAAe,YAAY,WAAW,QAAQ,gBAAgC;AACvF,SAAS,cAAc;AACvB,SAAS,qCAAqC;AA0D1C;AAjDJ,IAAM,aAAa,cAAsC,IAAI;AAiBtD,SAAS,YAAY,EAAE,KAAK,SAAS,MAAM,SAAS,SAAS,GAAqB;AACvF,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAwB,IAAI;AACxD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AAErD,QAAM,YAAY,OAAO,CAAC;AAE1B,YAAU,MAAM;AACd,UAAM,QAAQ,EAAE,UAAU;AAC1B,UAAM,IAAI,IAAI,OAAO,EAAE,MAAM,QAAQ,qBAAqB,SAAS,WAAW,QAAQ,CAAC;AACvF,UAAM,YAAY,IAAI,8BAA8B,IAAI,IAAI,GAAG,GAAG;AAAA,MAChE,aAAa,UAAU,EAAE,QAAQ,IAAI;AAAA,IACvC,CAAC;AAED,cAAU,IAAI;AACd,aAAS,IAAI;AAEb,MAAE,QAAQ,SAAS,EAChB,KAAK,MAAM;AACV,UAAI,UAAU,UAAU,QAAS,WAAU,CAAC;AAAA,UACvC,MAAK,EAAE,MAAM;AAAA,IACpB,CAAC,EACA,MAAM,CAAC,MAAM;AACZ,UAAI,UAAU,UAAU,QAAS,UAAS,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC;AAAA,IACzF,CAAC;AAEH,WAAO,MAAM;AACX,gBAAU;AACV,WAAK,EAAE,MAAM,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,KAAK,SAAS,MAAM,OAAO,CAAC;AAEhC,SACE,oBAAC,WAAW,UAAX,EAAoB,OAAO,EAAE,QAAQ,WAAW,WAAW,MAAM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,MAAM,SAAS,MAAM;AACtC;","names":["useEffect","useState","useState","useEffect"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ubuligan/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React hooks for MCP servers over Streamable HTTP (useMCPClient, useTools, useTool)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
21
|
+
"@ubuligan/shared": "^0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "^18.3.18",
|
|
28
|
+
"react": "^18.3.1",
|
|
29
|
+
"tsup": "^8.3.5",
|
|
30
|
+
"typescript": "^5.7.2"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"author": "jsznpm",
|
|
36
|
+
"homepage": "https://github.com/jsznpm/create-mcp-toolkit#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/jsznpm/create-mcp-toolkit/issues"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/jsznpm/create-mcp-toolkit.git",
|
|
43
|
+
"directory": "packages/react"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"mcp",
|
|
47
|
+
"model-context-protocol",
|
|
48
|
+
"ai",
|
|
49
|
+
"llm",
|
|
50
|
+
"react",
|
|
51
|
+
"hooks",
|
|
52
|
+
"nextjs"
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"typecheck": "tsc --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|