@decocms/mesh-sdk 1.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/README.md +368 -0
- package/package.json +51 -0
- package/src/context/index.ts +9 -0
- package/src/context/project-context.tsx +89 -0
- package/src/hooks/index.ts +73 -0
- package/src/hooks/use-collections.ts +357 -0
- package/src/hooks/use-connection.ts +82 -0
- package/src/hooks/use-mcp-client.ts +127 -0
- package/src/hooks/use-mcp-prompts.ts +126 -0
- package/src/hooks/use-mcp-resources.ts +128 -0
- package/src/hooks/use-mcp-tools.ts +184 -0
- package/src/hooks/use-virtual-mcp.ts +91 -0
- package/src/index.ts +128 -0
- package/src/lib/constants.ts +204 -0
- package/src/lib/mcp-oauth.ts +742 -0
- package/src/lib/query-keys.ts +178 -0
- package/src/lib/streamable-http-client-transport.ts +79 -0
- package/src/types/connection.ts +204 -0
- package/src/types/index.ts +27 -0
- package/src/types/virtual-mcp.ts +218 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known MCP Constants
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for well-known MCP IDs and connection definitions.
|
|
5
|
+
* This module provides constants and factory functions for creating standard MCP connections.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ConnectionCreateData } from "../types/connection";
|
|
9
|
+
import type { VirtualMCPEntity } from "../types/virtual-mcp";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Well-known MCP connection ID generators (org-scoped)
|
|
13
|
+
*
|
|
14
|
+
* These generate org-prefixed connection IDs for well-known MCPs.
|
|
15
|
+
* Example: WellKnownOrgMCPId.SELF("my-org") => "my-org_self"
|
|
16
|
+
*/
|
|
17
|
+
export const WellKnownOrgMCPId = {
|
|
18
|
+
/** Self/management MCP - used for management tools (monitoring, organization, user, collections) */
|
|
19
|
+
SELF: (org: string) => `${org}_self`,
|
|
20
|
+
/** Deco Store registry */
|
|
21
|
+
REGISTRY: (org: string) => `${org}_registry`,
|
|
22
|
+
/** Community MCP registry */
|
|
23
|
+
COMMUNITY_REGISTRY: (org: string) => `${org}_community-registry`,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Frontend connection ID for the self/management MCP endpoint.
|
|
28
|
+
* Use this constant when calling management tools (ALL_TOOLS) from the frontend.
|
|
29
|
+
* The endpoint is exposed at /mcp/self.
|
|
30
|
+
*/
|
|
31
|
+
export const SELF_MCP_ALIAS_ID = "self";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get well-known connection definition for the Deco Store registry.
|
|
35
|
+
* This can be used by both frontend and backend to create registry connections.
|
|
36
|
+
*
|
|
37
|
+
* @returns ConnectionCreateData for the Deco Store registry
|
|
38
|
+
*/
|
|
39
|
+
export function getWellKnownRegistryConnection(
|
|
40
|
+
orgId: string,
|
|
41
|
+
): ConnectionCreateData {
|
|
42
|
+
return {
|
|
43
|
+
id: WellKnownOrgMCPId.REGISTRY(orgId),
|
|
44
|
+
title: "Deco Store",
|
|
45
|
+
description: "Official deco MCP registry with curated integrations",
|
|
46
|
+
connection_type: "HTTP",
|
|
47
|
+
connection_url: "https://api.decocms.com/mcp/registry",
|
|
48
|
+
icon: "https://assets.decocache.com/decocms/00ccf6c3-9e13-4517-83b0-75ab84554bb9/596364c63320075ca58483660156b6d9de9b526e.png",
|
|
49
|
+
app_name: "deco-registry",
|
|
50
|
+
app_id: null,
|
|
51
|
+
connection_token: null,
|
|
52
|
+
connection_headers: null,
|
|
53
|
+
oauth_config: null,
|
|
54
|
+
configuration_state: null,
|
|
55
|
+
configuration_scopes: null,
|
|
56
|
+
metadata: {
|
|
57
|
+
isDefault: true,
|
|
58
|
+
type: "registry",
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get well-known connection definition for the Community Registry.
|
|
65
|
+
* Community MCP registry with thousands of handy MCPs.
|
|
66
|
+
*
|
|
67
|
+
* @returns ConnectionCreateData for the Community Registry
|
|
68
|
+
*/
|
|
69
|
+
export function getWellKnownCommunityRegistryConnection(): ConnectionCreateData {
|
|
70
|
+
return {
|
|
71
|
+
id: "community-registry",
|
|
72
|
+
title: "MCP Registry",
|
|
73
|
+
description: "Community MCP registry with thousands of handy MCPs",
|
|
74
|
+
connection_type: "HTTP",
|
|
75
|
+
connection_url: "https://sites-registry.decocache.com/mcp",
|
|
76
|
+
icon: "https://assets.decocache.com/decocms/cd7ca472-0f72-463a-b0de-6e44bdd0f9b4/mcp.png",
|
|
77
|
+
app_name: "mcp-registry",
|
|
78
|
+
app_id: null,
|
|
79
|
+
connection_token: null,
|
|
80
|
+
connection_headers: null,
|
|
81
|
+
oauth_config: null,
|
|
82
|
+
configuration_state: null,
|
|
83
|
+
configuration_scopes: null,
|
|
84
|
+
metadata: {
|
|
85
|
+
isDefault: true,
|
|
86
|
+
type: "registry",
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get well-known connection definition for the Management MCP (SELF).
|
|
93
|
+
* The connection URL is dynamic based on the base URL, so this is a function.
|
|
94
|
+
*
|
|
95
|
+
* @param baseUrl - The base URL for the MCP server (e.g., "http://localhost:3000" or "https://mesh.example.com")
|
|
96
|
+
* @returns ConnectionCreateData for the Management MCP
|
|
97
|
+
*/
|
|
98
|
+
export function getWellKnownSelfConnection(
|
|
99
|
+
baseUrl: string,
|
|
100
|
+
orgId: string,
|
|
101
|
+
): ConnectionCreateData {
|
|
102
|
+
return {
|
|
103
|
+
id: WellKnownOrgMCPId.SELF(orgId),
|
|
104
|
+
title: "Mesh MCP",
|
|
105
|
+
description: "The MCP for the mesh API",
|
|
106
|
+
connection_type: "HTTP",
|
|
107
|
+
// Custom url for targeting this mcp. It's a standalone endpoint that exposes all management tools.
|
|
108
|
+
connection_url: `${baseUrl}/mcp/${SELF_MCP_ALIAS_ID}`,
|
|
109
|
+
icon: "https://assets.decocache.com/mcp/09e44283-f47d-4046-955f-816d227c626f/app.png",
|
|
110
|
+
app_name: "@deco/management-mcp",
|
|
111
|
+
connection_token: null,
|
|
112
|
+
connection_headers: null,
|
|
113
|
+
oauth_config: null,
|
|
114
|
+
configuration_state: null,
|
|
115
|
+
configuration_scopes: null,
|
|
116
|
+
metadata: {
|
|
117
|
+
isDefault: true,
|
|
118
|
+
type: "self",
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get well-known connection definition for OpenRouter.
|
|
125
|
+
* Used by the chat UI to offer a one-click install when no model provider is connected.
|
|
126
|
+
*/
|
|
127
|
+
export function getWellKnownOpenRouterConnection(
|
|
128
|
+
opts: { id?: string } = {},
|
|
129
|
+
): ConnectionCreateData {
|
|
130
|
+
return {
|
|
131
|
+
id: opts.id,
|
|
132
|
+
title: "OpenRouter",
|
|
133
|
+
description: "Access hundreds of LLM models from a single API",
|
|
134
|
+
icon: "https://openrouter.ai/favicon.ico",
|
|
135
|
+
app_name: "openrouter",
|
|
136
|
+
app_id: "openrouter",
|
|
137
|
+
connection_type: "HTTP",
|
|
138
|
+
connection_url: "https://sites-openrouter.decocache.com/mcp",
|
|
139
|
+
connection_token: null,
|
|
140
|
+
connection_headers: null,
|
|
141
|
+
oauth_config: null,
|
|
142
|
+
configuration_state: null,
|
|
143
|
+
configuration_scopes: null,
|
|
144
|
+
metadata: {
|
|
145
|
+
source: "chat",
|
|
146
|
+
verified: false,
|
|
147
|
+
scopeName: "deco",
|
|
148
|
+
toolsCount: 0,
|
|
149
|
+
publishedAt: null,
|
|
150
|
+
repository: null,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get well-known connection definition for MCP Studio.
|
|
157
|
+
* Used by agents and workflows pages to offer installation when no provider is connected.
|
|
158
|
+
*/
|
|
159
|
+
export function getWellKnownMcpStudioConnection(): ConnectionCreateData {
|
|
160
|
+
return {
|
|
161
|
+
title: "MCP Studio",
|
|
162
|
+
description: "An app that allows you to create and manage MCPs",
|
|
163
|
+
icon: "https://assets.decocache.com/mcp/09e44283-f47d-4046-955f-816d227c626f/app.png",
|
|
164
|
+
app_name: "mcp-studio",
|
|
165
|
+
app_id: "65a1b407-b6af-41e2-a89f-ce9450c05bbc",
|
|
166
|
+
connection_type: "HTTP",
|
|
167
|
+
connection_url: "https://sites-vibemcp.decocache.com/mcp",
|
|
168
|
+
connection_token: null,
|
|
169
|
+
connection_headers: null,
|
|
170
|
+
oauth_config: null,
|
|
171
|
+
configuration_state: null,
|
|
172
|
+
configuration_scopes: null,
|
|
173
|
+
metadata: {
|
|
174
|
+
isDefault: false,
|
|
175
|
+
type: "mcp-studio",
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Get well-known Decopilot Agent virtual MCP entity.
|
|
182
|
+
* This is the default agent that aggregates ALL org connections.
|
|
183
|
+
*
|
|
184
|
+
* @param organizationId - Organization ID
|
|
185
|
+
* @returns VirtualMCPEntity representing the Decopilot agent
|
|
186
|
+
*/
|
|
187
|
+
export function getWellKnownDecopilotAgent(
|
|
188
|
+
organizationId: string,
|
|
189
|
+
): VirtualMCPEntity {
|
|
190
|
+
return {
|
|
191
|
+
id: `decopilot-${organizationId}`,
|
|
192
|
+
organization_id: organizationId,
|
|
193
|
+
title: "Decopilot",
|
|
194
|
+
description: "Default agent that aggregates all organization connections",
|
|
195
|
+
icon: "https://assets.decocache.com/decocms/fd07a578-6b1c-40f1-bc05-88a3b981695d/f7fc4ffa81aec04e37ae670c3cd4936643a7b269.png",
|
|
196
|
+
tool_selection_mode: "exclusion",
|
|
197
|
+
status: "active",
|
|
198
|
+
created_at: new Date().toISOString(),
|
|
199
|
+
updated_at: new Date().toISOString(),
|
|
200
|
+
created_by: "system",
|
|
201
|
+
updated_by: undefined,
|
|
202
|
+
connections: [], // Empty = no exclusions, include all connections
|
|
203
|
+
};
|
|
204
|
+
}
|