MCPcopy
hub / github.com/simstudioai/sim / buildIntegrationToolSchemas

Function buildIntegrationToolSchemas

apps/sim/lib/copilot/chat/payload.ts:106–134  ·  view source on GitHub ↗
(
  userId: string,
  messageId?: string,
  options: BuildIntegrationToolSchemasOptions = { schemaSurface: 'copilot' },
  workspaceId?: string
)

Source from the content-addressed store, hash-verified

104 * workspace's `allowedIntegrations` allowlist.
105 */
106export async function buildIntegrationToolSchemas(
107 userId: string,
108 messageId?: string,
109 options: BuildIntegrationToolSchemasOptions = { schemaSurface: 'copilot' },
110 workspaceId?: string
111): Promise<ToolSchema[]> {
112 const schemaSurface = options.schemaSurface ?? 'copilot'
113 const cacheKey = getIntegrationToolSchemaCacheKey(userId, workspaceId, schemaSurface)
114 const cached = integrationToolSchemaCache.get(cacheKey)
115 if (cached) {
116 return cloneToolSchemas(await cached.promise)
117 }
118
119 const promise = buildIntegrationToolSchemasUncached(
120 userId,
121 messageId,
122 { schemaSurface },
123 workspaceId
124 ).catch((error) => {
125 integrationToolSchemaCache.delete(cacheKey)
126 throw error
127 })
128
129 integrationToolSchemaCache.set(cacheKey, {
130 promise,
131 })
132
133 return cloneToolSchemas(await promise)
134}
135
136async function buildIntegrationToolSchemasUncached(
137 userId: string,

Callers 4

executeInboxTaskFunction · 0.90
payload.test.tsFile · 0.90
route.tsFile · 0.90

Calls 6

cloneToolSchemasFunction · 0.85
getMethod · 0.65
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected