@frontmcp/react 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 (140) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +263 -0
  3. package/ai/createToolHandler.d.ts +10 -0
  4. package/ai/createToolHandler.d.ts.map +1 -0
  5. package/ai/index.d.ts +7 -0
  6. package/ai/index.d.ts.map +1 -0
  7. package/ai/index.js +416 -0
  8. package/ai/types.d.ts +52 -0
  9. package/ai/types.d.ts.map +1 -0
  10. package/ai/useAITools.d.ts +17 -0
  11. package/ai/useAITools.d.ts.map +1 -0
  12. package/ai/useTools.d.ts +19 -0
  13. package/ai/useTools.d.ts.map +1 -0
  14. package/api/api.types.d.ts +61 -0
  15. package/api/api.types.d.ts.map +1 -0
  16. package/api/createFetchClient.d.ts +9 -0
  17. package/api/createFetchClient.d.ts.map +1 -0
  18. package/api/index.d.ts +12 -0
  19. package/api/index.d.ts.map +1 -0
  20. package/api/index.js +402 -0
  21. package/api/parseOpenApiSpec.d.ts +9 -0
  22. package/api/parseOpenApiSpec.d.ts.map +1 -0
  23. package/api/useApiClient.d.ts +9 -0
  24. package/api/useApiClient.d.ts.map +1 -0
  25. package/components/AgentContent.d.ts +30 -0
  26. package/components/AgentContent.d.ts.map +1 -0
  27. package/components/AgentSearch.d.ts +35 -0
  28. package/components/AgentSearch.d.ts.map +1 -0
  29. package/components/ComponentRegistry.d.ts +36 -0
  30. package/components/ComponentRegistry.d.ts.map +1 -0
  31. package/components/DomResources.d.ts +16 -0
  32. package/components/DomResources.d.ts.map +1 -0
  33. package/components/DynamicRenderer.d.ts +19 -0
  34. package/components/DynamicRenderer.d.ts.map +1 -0
  35. package/components/OutputDisplay.d.ts +11 -0
  36. package/components/OutputDisplay.d.ts.map +1 -0
  37. package/components/PromptForm.d.ts +13 -0
  38. package/components/PromptForm.d.ts.map +1 -0
  39. package/components/ResourceViewer.d.ts +18 -0
  40. package/components/ResourceViewer.d.ts.map +1 -0
  41. package/components/ToolForm.d.ts +16 -0
  42. package/components/ToolForm.d.ts.map +1 -0
  43. package/components/index.d.ts +21 -0
  44. package/components/index.d.ts.map +1 -0
  45. package/components/mcpComponent.d.ts +48 -0
  46. package/components/mcpComponent.d.ts.map +1 -0
  47. package/esm/ai/index.mjs +393 -0
  48. package/esm/api/index.mjs +379 -0
  49. package/esm/index.mjs +1814 -0
  50. package/esm/package.json +111 -0
  51. package/esm/router/index.mjs +157 -0
  52. package/esm/state/index.mjs +450 -0
  53. package/hooks/index.d.ts +21 -0
  54. package/hooks/index.d.ts.map +1 -0
  55. package/hooks/useCallTool.d.ts +9 -0
  56. package/hooks/useCallTool.d.ts.map +1 -0
  57. package/hooks/useComponentTree.d.ts +21 -0
  58. package/hooks/useComponentTree.d.ts.map +1 -0
  59. package/hooks/useDynamicResource.d.ts +20 -0
  60. package/hooks/useDynamicResource.d.ts.map +1 -0
  61. package/hooks/useDynamicTool.d.ts +39 -0
  62. package/hooks/useDynamicTool.d.ts.map +1 -0
  63. package/hooks/useFrontMcp.d.ts +8 -0
  64. package/hooks/useFrontMcp.d.ts.map +1 -0
  65. package/hooks/useGetPrompt.d.ts +13 -0
  66. package/hooks/useGetPrompt.d.ts.map +1 -0
  67. package/hooks/useListPrompts.d.ts +10 -0
  68. package/hooks/useListPrompts.d.ts.map +1 -0
  69. package/hooks/useListResources.d.ts +14 -0
  70. package/hooks/useListResources.d.ts.map +1 -0
  71. package/hooks/useListTools.d.ts +10 -0
  72. package/hooks/useListTools.d.ts.map +1 -0
  73. package/hooks/useReadResource.d.ts +23 -0
  74. package/hooks/useReadResource.d.ts.map +1 -0
  75. package/hooks/useResolvedServer.d.ts +16 -0
  76. package/hooks/useResolvedServer.d.ts.map +1 -0
  77. package/hooks/useServer.d.ts +17 -0
  78. package/hooks/useServer.d.ts.map +1 -0
  79. package/hooks/useStoreResource.d.ts +22 -0
  80. package/hooks/useStoreResource.d.ts.map +1 -0
  81. package/index.d.ts +33 -0
  82. package/index.d.ts.map +1 -0
  83. package/index.js +1821 -0
  84. package/package.json +111 -0
  85. package/provider/FrontMcpContext.d.ts +6 -0
  86. package/provider/FrontMcpContext.d.ts.map +1 -0
  87. package/provider/FrontMcpProvider.d.ts +34 -0
  88. package/provider/FrontMcpProvider.d.ts.map +1 -0
  89. package/provider/index.d.ts +4 -0
  90. package/provider/index.d.ts.map +1 -0
  91. package/registry/DynamicRegistry.d.ts +55 -0
  92. package/registry/DynamicRegistry.d.ts.map +1 -0
  93. package/registry/ServerRegistry.d.ts +43 -0
  94. package/registry/ServerRegistry.d.ts.map +1 -0
  95. package/registry/createWrappedServer.d.ts +14 -0
  96. package/registry/createWrappedServer.d.ts.map +1 -0
  97. package/registry/index.d.ts +5 -0
  98. package/registry/index.d.ts.map +1 -0
  99. package/router/current-route.resource.d.ts +11 -0
  100. package/router/current-route.resource.d.ts.map +1 -0
  101. package/router/go-back.tool.d.ts +18 -0
  102. package/router/go-back.tool.d.ts.map +1 -0
  103. package/router/index.d.ts +9 -0
  104. package/router/index.d.ts.map +1 -0
  105. package/router/index.js +180 -0
  106. package/router/navigate.tool.d.ts +35 -0
  107. package/router/navigate.tool.d.ts.map +1 -0
  108. package/router/router-bridge.d.ts +20 -0
  109. package/router/router-bridge.d.ts.map +1 -0
  110. package/router/router.entries.d.ts +23 -0
  111. package/router/router.entries.d.ts.map +1 -0
  112. package/router/useRouterBridge.d.ts +7 -0
  113. package/router/useRouterBridge.d.ts.map +1 -0
  114. package/state/adapters/createStore.d.ts +15 -0
  115. package/state/adapters/createStore.d.ts.map +1 -0
  116. package/state/adapters/index.d.ts +7 -0
  117. package/state/adapters/index.d.ts.map +1 -0
  118. package/state/adapters/reduxAdapter.d.ts +21 -0
  119. package/state/adapters/reduxAdapter.d.ts.map +1 -0
  120. package/state/adapters/valtioAdapter.d.ts +19 -0
  121. package/state/adapters/valtioAdapter.d.ts.map +1 -0
  122. package/state/index.d.ts +15 -0
  123. package/state/index.d.ts.map +1 -0
  124. package/state/index.js +473 -0
  125. package/state/state.types.d.ts +48 -0
  126. package/state/state.types.d.ts.map +1 -0
  127. package/state/useReduxResource.d.ts +8 -0
  128. package/state/useReduxResource.d.ts.map +1 -0
  129. package/state/useStoreRegistration.d.ts +14 -0
  130. package/state/useStoreRegistration.d.ts.map +1 -0
  131. package/state/useStoreResource.d.ts +10 -0
  132. package/state/useStoreResource.d.ts.map +1 -0
  133. package/state/useValtioResource.d.ts +9 -0
  134. package/state/useValtioResource.d.ts.map +1 -0
  135. package/types.d.ts +127 -0
  136. package/types.d.ts.map +1 -0
  137. package/utils/index.d.ts +2 -0
  138. package/utils/index.d.ts.map +1 -0
  139. package/utils/zodToJsonSchema.d.ts +9 -0
  140. package/utils/zodToJsonSchema.d.ts.map +1 -0
package/package.json ADDED
@@ -0,0 +1,111 @@
1
+ {
2
+ "name": "@frontmcp/react",
3
+ "version": "0.0.1",
4
+ "description": "React hooks, components, and AI SDK integration for FrontMCP",
5
+ "author": "AgentFront <info@agentfront.dev>",
6
+ "homepage": "https://docs.agentfront.dev",
7
+ "license": "Apache-2.0",
8
+ "keywords": [
9
+ "mcp",
10
+ "react",
11
+ "hooks",
12
+ "ai",
13
+ "tools",
14
+ "openai",
15
+ "claude",
16
+ "vercel-ai",
17
+ "agentfront",
18
+ "frontmcp"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/agentfront/frontmcp.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/agentfront/frontmcp/issues"
26
+ },
27
+ "type": "commonjs",
28
+ "main": "./index.js",
29
+ "module": "./esm/index.mjs",
30
+ "types": "./index.d.ts",
31
+ "sideEffects": false,
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": {
35
+ "require": {
36
+ "types": "./index.d.ts",
37
+ "default": "./index.js"
38
+ },
39
+ "import": {
40
+ "types": "./index.d.ts",
41
+ "default": "./esm/index.mjs"
42
+ }
43
+ },
44
+ "./ai": {
45
+ "require": {
46
+ "types": "./ai/index.d.ts",
47
+ "default": "./ai/index.js"
48
+ },
49
+ "import": {
50
+ "types": "./ai/index.d.ts",
51
+ "default": "./esm/ai/index.mjs"
52
+ }
53
+ },
54
+ "./router": {
55
+ "require": {
56
+ "types": "./router/index.d.ts",
57
+ "default": "./router/index.js"
58
+ },
59
+ "import": {
60
+ "types": "./router/index.d.ts",
61
+ "default": "./esm/router/index.mjs"
62
+ }
63
+ },
64
+ "./state": {
65
+ "require": {
66
+ "types": "./state/index.d.ts",
67
+ "default": "./state/index.js"
68
+ },
69
+ "import": {
70
+ "types": "./state/index.d.ts",
71
+ "default": "./esm/state/index.mjs"
72
+ }
73
+ },
74
+ "./api": {
75
+ "require": {
76
+ "types": "./api/index.d.ts",
77
+ "default": "./api/index.js"
78
+ },
79
+ "import": {
80
+ "types": "./api/index.d.ts",
81
+ "default": "./esm/api/index.mjs"
82
+ }
83
+ }
84
+ },
85
+ "engines": {
86
+ "node": ">=22.0.0"
87
+ },
88
+ "peerDependencies": {
89
+ "react": "^18.0.0 || ^19.0.0",
90
+ "react-dom": "^18.0.0 || ^19.0.0",
91
+ "@frontmcp/sdk": "1.0.0",
92
+ "@frontmcp/utils": "1.0.0",
93
+ "react-router-dom": "^7.0.0",
94
+ "zod": "^4.0.0"
95
+ },
96
+ "peerDependenciesMeta": {
97
+ "react-router-dom": {
98
+ "optional": true
99
+ },
100
+ "zod": {
101
+ "optional": true
102
+ }
103
+ },
104
+ "dependencies": {
105
+ "@frontmcp/sdk": "1.0.0",
106
+ "@frontmcp/utils": "1.0.0"
107
+ },
108
+ "devDependencies": {
109
+ "typescript": "^5.9.3"
110
+ }
111
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * React context for FrontMCP.
3
+ */
4
+ import type { FrontMcpContextValue } from '../types';
5
+ export declare const FrontMcpContext: import("react").Context<FrontMcpContextValue>;
6
+ //# sourceMappingURL=FrontMcpContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrontMcpContext.d.ts","sourceRoot":"","sources":["../../src/provider/FrontMcpContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAMrD,eAAO,MAAM,eAAe,+CAM1B,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * FrontMcpProvider — manages MCP client lifecycle for a pre-created server.
3
+ *
4
+ * 1. Receives an already-created `DirectMcpServer` via the `server` prop
5
+ * 2. Optionally receives additional named servers via `servers` prop
6
+ * 3. Merges developer-registered components into the ComponentRegistry
7
+ * 4. Optionally auto-connects a client on mount (default: true)
8
+ * 5. Registers all servers into the shared ServerRegistry singleton
9
+ * 6. Creates a DynamicRegistry for dynamic tool/resource registration
10
+ * 7. Wraps the server to overlay dynamic entries on list/call operations
11
+ * 8. All state (status, tools, etc.) lives in the ServerRegistry — context
12
+ * carries only `name`, `registry`, `dynamicRegistry`, and `connect`.
13
+ */
14
+ import React from 'react';
15
+ import type { ComponentType } from 'react';
16
+ import type { DirectMcpServer, DirectClient } from '@frontmcp/sdk';
17
+ import type { StoreAdapter } from '../types';
18
+ export interface FrontMcpProviderProps {
19
+ /** Logical name for the primary server (defaults to 'default') */
20
+ name?: string;
21
+ /** Primary MCP server — registered under `name` in ServerRegistry */
22
+ server: DirectMcpServer;
23
+ /** Additional named servers — each registered by key in ServerRegistry */
24
+ servers?: Record<string, DirectMcpServer>;
25
+ components?: Record<string, ComponentType<Record<string, unknown>>>;
26
+ /** Store adapters to register at the provider level (reduxStore, valtioStore, createStore). */
27
+ stores?: StoreAdapter[];
28
+ autoConnect?: boolean;
29
+ children: React.ReactNode;
30
+ onConnected?: (client: DirectClient) => void;
31
+ onError?: (error: Error) => void;
32
+ }
33
+ export declare function FrontMcpProvider({ name: nameProp, server, servers, components, stores, autoConnect, children, onConnected, onError, }: FrontMcpProviderProps): React.ReactElement;
34
+ //# sourceMappingURL=FrontMcpProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrontMcpProvider.d.ts","sourceRoot":"","sources":["../../src/provider/FrontMcpProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAKnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK7C,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,MAAM,EAAE,eAAe,CAAC;IACxB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE,+FAA+F;IAC/F,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,OAAO,EACP,UAAU,EACV,MAAM,EACN,WAAkB,EAClB,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CAsN5C"}
@@ -0,0 +1,4 @@
1
+ export { FrontMcpContext } from './FrontMcpContext';
2
+ export { FrontMcpProvider } from './FrontMcpProvider';
3
+ export type { FrontMcpProviderProps } from './FrontMcpProvider';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * DynamicRegistry — React-side registry for tools and resources that
3
+ * components register on mount and unregister on unmount.
4
+ *
5
+ * Operates as an overlay on the base DirectMcpServer: dynamic entries
6
+ * are merged into listTools/listResources and checked first on
7
+ * callTool/readResource.
8
+ *
9
+ * Uses the same listener/version pattern as ServerRegistry for
10
+ * useSyncExternalStore compatibility.
11
+ */
12
+ import type { DynamicToolDef, DynamicResourceDef } from '../types';
13
+ type Listener = () => void;
14
+ export declare class DynamicRegistry {
15
+ private tools;
16
+ private resources;
17
+ private toolRefCounts;
18
+ private resourceRefCounts;
19
+ private listeners;
20
+ private version;
21
+ /**
22
+ * Register a dynamic tool. Returns an unregister function
23
+ * suitable for useEffect cleanup.
24
+ *
25
+ * Multiple registrations of the same name are ref-counted:
26
+ * subsequent registrations update the definition but the tool
27
+ * is only removed when every registrant has unregistered.
28
+ */
29
+ registerTool(def: DynamicToolDef): () => void;
30
+ unregisterTool(name: string): void;
31
+ /**
32
+ * Register a dynamic resource. Returns an unregister function
33
+ * suitable for useEffect cleanup.
34
+ *
35
+ * Multiple registrations of the same URI are ref-counted.
36
+ */
37
+ registerResource(def: DynamicResourceDef): () => void;
38
+ unregisterResource(uri: string): void;
39
+ /** Update the execute function for an existing tool (for stale closure prevention). */
40
+ updateToolExecute(name: string, execute: DynamicToolDef['execute']): void;
41
+ /** Update the read function for an existing resource and notify subscribers. */
42
+ updateResourceRead(uri: string, read: DynamicResourceDef['read']): void;
43
+ getTools(): DynamicToolDef[];
44
+ getResources(): DynamicResourceDef[];
45
+ findTool(name: string): DynamicToolDef | undefined;
46
+ findResource(uri: string): DynamicResourceDef | undefined;
47
+ hasTool(name: string): boolean;
48
+ hasResource(uri: string): boolean;
49
+ subscribe(listener: Listener): () => void;
50
+ getVersion(): number;
51
+ clear(): void;
52
+ private notify;
53
+ }
54
+ export {};
55
+ //# sourceMappingURL=DynamicRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/DynamicRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnE,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAE3B,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAK;IAEpB;;;;;;;OAOG;IACH,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,IAAI;IAe7C,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAYlC;;;;;OAKG;IACH,gBAAgB,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAerD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAYrC,uFAAuF;IACvF,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,IAAI;IAOzE,gFAAgF;IAChF,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,IAAI;IAQvE,QAAQ,IAAI,cAAc,EAAE;IAI5B,YAAY,IAAI,kBAAkB,EAAE;IAIpC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIlD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIzD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIjC,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAOzC,UAAU,IAAI,MAAM;IAIpB,KAAK,IAAI,IAAI;IASb,OAAO,CAAC,MAAM;CAMf"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ServerRegistry — shared singleton that maps server names to DirectMcpServer instances.
3
+ *
4
+ * Enables multiple MCP servers to coexist in a single React app without
5
+ * requiring multiple providers or React Router trees. Hooks can target
6
+ * a specific server by name via `{ server: 'name' }` option.
7
+ *
8
+ * Integrates with React via useSyncExternalStore for tear-free reads.
9
+ */
10
+ import type { DirectMcpServer, DirectClient } from '@frontmcp/sdk';
11
+ import type { FrontMcpStatus, ToolInfo, ResourceInfo, ResourceTemplateInfo, PromptInfo } from '../types';
12
+ type Listener = () => void;
13
+ export interface ServerEntry {
14
+ server: DirectMcpServer;
15
+ client: DirectClient | null;
16
+ status: FrontMcpStatus;
17
+ error: Error | null;
18
+ tools: ToolInfo[];
19
+ resources: ResourceInfo[];
20
+ resourceTemplates: ResourceTemplateInfo[];
21
+ prompts: PromptInfo[];
22
+ }
23
+ export declare class ServerRegistry {
24
+ private entries;
25
+ private listeners;
26
+ private version;
27
+ register(name: string, server: DirectMcpServer): void;
28
+ unregister(name: string): void;
29
+ get(name: string): ServerEntry | undefined;
30
+ has(name: string): boolean;
31
+ list(): string[];
32
+ connect(name: string): Promise<DirectClient>;
33
+ connectAll(): Promise<void>;
34
+ update(name: string, partial: Partial<ServerEntry>): void;
35
+ clear(): void;
36
+ subscribe(listener: Listener): () => void;
37
+ getVersion(): number;
38
+ private notify;
39
+ }
40
+ /** Module-scoped singleton — shared across all components. */
41
+ export declare const serverRegistry: ServerRegistry;
42
+ export {};
43
+ //# sourceMappingURL=ServerRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerRegistry.d.ts","sourceRoot":"","sources":["../../src/registry/ServerRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEzG,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAE3B,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;IAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAK;IAEpB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI;IAcrD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI1C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,IAAI,IAAI,MAAM,EAAE;IAIV,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAuC5C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAQzD,KAAK,IAAI,IAAI;IAKb,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAOzC,UAAU,IAAI,MAAM;IAIpB,OAAO,CAAC,MAAM;CAIf;AAED,8DAA8D;AAC9D,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * createWrappedServer — wraps a DirectMcpServer with a DynamicRegistry overlay.
3
+ *
4
+ * Intercepts listTools/callTool/listResources/readResource to merge
5
+ * dynamically registered entries. All other methods delegate directly.
6
+ */
7
+ import type { DirectMcpServer } from '@frontmcp/sdk';
8
+ import type { DynamicRegistry } from './DynamicRegistry';
9
+ /**
10
+ * Create a wrapped DirectMcpServer that overlays dynamic tools and resources.
11
+ * Dynamic entries take precedence over base server entries with the same name/uri.
12
+ */
13
+ export declare function createWrappedServer(base: DirectMcpServer, dynamicRegistry: DynamicRegistry): DirectMcpServer;
14
+ //# sourceMappingURL=createWrappedServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createWrappedServer.d.ts","sourceRoot":"","sources":["../../src/registry/createWrappedServer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAiCzD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,GAAG,eAAe,CA4H5G"}
@@ -0,0 +1,5 @@
1
+ export { ServerRegistry, serverRegistry } from './ServerRegistry';
2
+ export type { ServerEntry } from './ServerRegistry';
3
+ export { DynamicRegistry } from './DynamicRegistry';
4
+ export { createWrappedServer } from './createWrappedServer';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * CurrentRouteResource — MCP resource that reads the current URL/path/params.
3
+ */
4
+ import type { ReadResourceResult } from '@frontmcp/sdk';
5
+ export declare class CurrentRouteResource {
6
+ static readonly uri = "route://current";
7
+ static readonly resourceName = "Current Route";
8
+ static readonly description = "Read the current URL path, search params, and hash";
9
+ static read(): ReadResourceResult;
10
+ }
11
+ //# sourceMappingURL=current-route.resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-route.resource.d.ts","sourceRoot":"","sources":["../../src/router/current-route.resource.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,qBAAa,oBAAoB;IAC/B,MAAM,CAAC,QAAQ,CAAC,GAAG,qBAAqB;IACxC,MAAM,CAAC,QAAQ,CAAC,YAAY,mBAAmB;IAC/C,MAAM,CAAC,QAAQ,CAAC,WAAW,wDAAwD;IAEnF,MAAM,CAAC,IAAI,IAAI,kBAAkB;CA+BlC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * GoBackTool — MCP tool that goes back to the previous page in history.
3
+ */
4
+ export declare class GoBackTool {
5
+ static readonly toolName = "go_back";
6
+ static readonly description = "Go back to the previous page in browser history";
7
+ static readonly inputSchema: {
8
+ type: "object";
9
+ properties: {};
10
+ };
11
+ static execute(): Promise<{
12
+ content: Array<{
13
+ type: string;
14
+ text: string;
15
+ }>;
16
+ }>;
17
+ }
18
+ //# sourceMappingURL=go-back.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go-back.tool.d.ts","sourceRoot":"","sources":["../../src/router/go-back.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qBAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CAAC,QAAQ,aAAa;IACrC,MAAM,CAAC,QAAQ,CAAC,WAAW,qDAAqD;IAChF,MAAM,CAAC,QAAQ,CAAC,WAAW;;;MAGzB;WAEW,OAAO,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAkBpF"}
@@ -0,0 +1,9 @@
1
+ export { useRouterBridge } from './useRouterBridge';
2
+ export { NavigateTool } from './navigate.tool';
3
+ export { GoBackTool } from './go-back.tool';
4
+ export { CurrentRouteResource } from './current-route.resource';
5
+ export { createRouterEntries } from './router.entries';
6
+ export type { RouterEntries } from './router.entries';
7
+ export type { BridgeLocation, NavigateFn } from './router-bridge';
8
+ export { setNavigate, setLocation, getNavigate, getLocation, clearBridge } from './router-bridge';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // libs/react/src/router/index.ts
21
+ var router_exports = {};
22
+ __export(router_exports, {
23
+ CurrentRouteResource: () => CurrentRouteResource,
24
+ GoBackTool: () => GoBackTool,
25
+ NavigateTool: () => NavigateTool,
26
+ clearBridge: () => clearBridge,
27
+ createRouterEntries: () => createRouterEntries,
28
+ getLocation: () => getLocation,
29
+ getNavigate: () => getNavigate,
30
+ setLocation: () => setLocation,
31
+ setNavigate: () => setNavigate,
32
+ useRouterBridge: () => useRouterBridge
33
+ });
34
+ module.exports = __toCommonJS(router_exports);
35
+
36
+ // libs/react/src/router/useRouterBridge.ts
37
+ var import_react = require("react");
38
+ var import_react_router_dom = require("react-router-dom");
39
+
40
+ // libs/react/src/router/router-bridge.ts
41
+ var currentNavigate = null;
42
+ var currentLocation = null;
43
+ function setNavigate(fn) {
44
+ currentNavigate = fn;
45
+ }
46
+ function setLocation(loc) {
47
+ currentLocation = loc;
48
+ }
49
+ function getNavigate() {
50
+ return currentNavigate;
51
+ }
52
+ function getLocation() {
53
+ return currentLocation;
54
+ }
55
+ function clearBridge() {
56
+ currentNavigate = null;
57
+ currentLocation = null;
58
+ }
59
+
60
+ // libs/react/src/router/useRouterBridge.ts
61
+ function useRouterBridge() {
62
+ const navigate = (0, import_react_router_dom.useNavigate)();
63
+ const location = (0, import_react_router_dom.useLocation)();
64
+ (0, import_react.useEffect)(() => {
65
+ setNavigate(navigate);
66
+ return () => {
67
+ clearBridge();
68
+ };
69
+ }, [navigate]);
70
+ (0, import_react.useEffect)(() => {
71
+ setLocation({
72
+ pathname: location.pathname,
73
+ search: location.search,
74
+ hash: location.hash
75
+ });
76
+ }, [location.pathname, location.search, location.hash]);
77
+ }
78
+
79
+ // libs/react/src/router/navigate.tool.ts
80
+ var NavigateTool = class {
81
+ static toolName = "navigate";
82
+ static description = "Navigate to a URL path in the application";
83
+ static inputSchema = {
84
+ type: "object",
85
+ properties: {
86
+ path: { type: "string", description: "The URL path to navigate to" },
87
+ replace: { type: "boolean", description: "Replace current history entry instead of pushing" }
88
+ },
89
+ required: ["path"]
90
+ };
91
+ static async execute(args) {
92
+ const navigate = getNavigate();
93
+ if (!navigate) {
94
+ return {
95
+ content: [
96
+ {
97
+ type: "text",
98
+ text: "Router bridge not connected. Ensure useRouterBridge() is called inside a React Router tree."
99
+ }
100
+ ]
101
+ };
102
+ }
103
+ navigate(args.path, { replace: args.replace });
104
+ return {
105
+ content: [{ type: "text", text: `Navigated to ${args.path}` }]
106
+ };
107
+ }
108
+ };
109
+
110
+ // libs/react/src/router/go-back.tool.ts
111
+ var GoBackTool = class {
112
+ static toolName = "go_back";
113
+ static description = "Go back to the previous page in browser history";
114
+ static inputSchema = {
115
+ type: "object",
116
+ properties: {}
117
+ };
118
+ static async execute() {
119
+ const navigate = getNavigate();
120
+ if (!navigate) {
121
+ return {
122
+ content: [
123
+ {
124
+ type: "text",
125
+ text: "Router bridge not connected. Ensure useRouterBridge() is called inside a React Router tree."
126
+ }
127
+ ]
128
+ };
129
+ }
130
+ navigate(-1);
131
+ return {
132
+ content: [{ type: "text", text: "Navigated back" }]
133
+ };
134
+ }
135
+ };
136
+
137
+ // libs/react/src/router/current-route.resource.ts
138
+ var CurrentRouteResource = class _CurrentRouteResource {
139
+ static uri = "route://current";
140
+ static resourceName = "Current Route";
141
+ static description = "Read the current URL path, search params, and hash";
142
+ static read() {
143
+ const location = getLocation();
144
+ if (!location) {
145
+ return {
146
+ contents: [
147
+ {
148
+ uri: _CurrentRouteResource.uri,
149
+ mimeType: "application/json",
150
+ text: JSON.stringify({
151
+ error: "Router bridge not connected. Ensure useRouterBridge() is called inside a React Router tree."
152
+ })
153
+ }
154
+ ]
155
+ };
156
+ }
157
+ return {
158
+ contents: [
159
+ {
160
+ uri: _CurrentRouteResource.uri,
161
+ mimeType: "application/json",
162
+ text: JSON.stringify({
163
+ pathname: location.pathname,
164
+ search: location.search,
165
+ hash: location.hash,
166
+ href: `${location.pathname}${location.search}${location.hash}`
167
+ })
168
+ }
169
+ ]
170
+ };
171
+ }
172
+ };
173
+
174
+ // libs/react/src/router/router.entries.ts
175
+ function createRouterEntries() {
176
+ return {
177
+ tools: [NavigateTool, GoBackTool],
178
+ resources: [CurrentRouteResource]
179
+ };
180
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * NavigateTool — MCP tool that navigates to a URL path in the application.
3
+ *
4
+ * This is a plain class (not using SDK decorators) to avoid requiring
5
+ * reflect-metadata in browser bundles. It exposes the same shape that
6
+ * `create()` accepts in its `tools` array.
7
+ */
8
+ export declare class NavigateTool {
9
+ static readonly toolName = "navigate";
10
+ static readonly description = "Navigate to a URL path in the application";
11
+ static readonly inputSchema: {
12
+ type: "object";
13
+ properties: {
14
+ path: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ replace: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ };
23
+ required: readonly ["path"];
24
+ };
25
+ static execute(args: {
26
+ path: string;
27
+ replace?: boolean;
28
+ }): Promise<{
29
+ content: Array<{
30
+ type: string;
31
+ text: string;
32
+ }>;
33
+ }>;
34
+ }
35
+ //# sourceMappingURL=navigate.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigate.tool.d.ts","sourceRoot":"","sources":["../../src/router/navigate.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,qBAAa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc;IACtC,MAAM,CAAC,QAAQ,CAAC,WAAW,+CAA+C;IAC1E,MAAM,CAAC,QAAQ,CAAC,WAAW;;;;;;;;;;;;;MAOzB;WAEW,OAAO,CAAC,IAAI,EAAE;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAkBhE"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Router bridge — module-scoped singleton holding navigate/location.
3
+ *
4
+ * Single-threaded browser context means no async context needed.
5
+ * `useRouterBridge()` populates this on every render/route change.
6
+ */
7
+ export interface BridgeLocation {
8
+ pathname: string;
9
+ search: string;
10
+ hash: string;
11
+ }
12
+ export type NavigateFn = (to: string | number, options?: {
13
+ replace?: boolean;
14
+ }) => void;
15
+ export declare function setNavigate(fn: NavigateFn): void;
16
+ export declare function setLocation(loc: BridgeLocation): void;
17
+ export declare function getNavigate(): NavigateFn | null;
18
+ export declare function getLocation(): BridgeLocation | null;
19
+ export declare function clearBridge(): void;
20
+ //# sourceMappingURL=router-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-bridge.d.ts","sourceRoot":"","sources":["../../src/router/router-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,CAAC;AAKxF,wBAAgB,WAAW,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAEhD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAErD;AAED,wBAAgB,WAAW,IAAI,UAAU,GAAG,IAAI,CAE/C;AAED,wBAAgB,WAAW,IAAI,cAAc,GAAG,IAAI,CAEnD;AAED,wBAAgB,WAAW,IAAI,IAAI,CAGlC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * createRouterEntries — factory that returns tool/resource entries for easy
3
+ * spreading into `create()` config.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const { tools, resources } = createRouterEntries();
8
+ * const server = await create({
9
+ * info: { name: 'app', version: '1.0.0' },
10
+ * tools: [...tools, ...myTools],
11
+ * resources: [...resources, ...myResources],
12
+ * });
13
+ * ```
14
+ */
15
+ import { NavigateTool } from './navigate.tool';
16
+ import { GoBackTool } from './go-back.tool';
17
+ import { CurrentRouteResource } from './current-route.resource';
18
+ export interface RouterEntries {
19
+ tools: [typeof NavigateTool, typeof GoBackTool];
20
+ resources: [typeof CurrentRouteResource];
21
+ }
22
+ export declare function createRouterEntries(): RouterEntries;
23
+ //# sourceMappingURL=router.entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.entries.d.ts","sourceRoot":"","sources":["../../src/router/router.entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,CAAC,OAAO,YAAY,EAAE,OAAO,UAAU,CAAC,CAAC;IAChD,SAAS,EAAE,CAAC,OAAO,oBAAoB,CAAC,CAAC;CAC1C;AAED,wBAAgB,mBAAmB,IAAI,aAAa,CAKnD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * useRouterBridge — wires React Router's navigate/location into the bridge singleton.
3
+ *
4
+ * Must be called inside a React Router tree (e.g., <BrowserRouter>).
5
+ */
6
+ export declare function useRouterBridge(): void;
7
+ //# sourceMappingURL=useRouterBridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRouterBridge.d.ts","sourceRoot":"","sources":["../../src/router/useRouterBridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,wBAAgB,eAAe,IAAI,IAAI,CAkBtC"}