MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchTagDefinitions

Function fetchTagDefinitions

apps/sim/tools/schema-enrichers.ts:98–121  ·  view source on GitHub ↗

* Fetches tag definitions from knowledge base

(knowledgeBaseId: string)

Source from the content-addressed store, hash-verified

96 * Fetches tag definitions from knowledge base
97 */
98async function fetchTagDefinitions(knowledgeBaseId: string): Promise<TagDefinition[]> {
99 try {
100 const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http')
101
102 const headers = await buildAuthHeaders()
103 const url = buildAPIUrl(`/api/knowledge/${knowledgeBaseId}/tag-definitions`)
104
105 logger.info(`Fetching tag definitions for KB ${knowledgeBaseId} from ${url.toString()}`)
106
107 const response = await fetch(url.toString(), { headers })
108 if (!response.ok) {
109 logger.warn(`Failed to fetch tag definitions for KB ${knowledgeBaseId}: ${response.status}`)
110 return []
111 }
112
113 const result = await response.json()
114 const tagDefinitions = result.data || []
115 logger.info(`Found ${tagDefinitions.length} tag definitions for KB ${knowledgeBaseId}`)
116 return tagDefinitions
117 } catch (error) {
118 logger.error('Failed to fetch tag definitions:', error)
119 return []
120 }
121}
122
123/**
124 * Fetches KB tag definitions and builds a schema for LLM consumption.

Callers 3

enrichKBTagsSchemaFunction · 0.70
enrichKBTagFiltersSchemaFunction · 0.70
DocumentTagsModalFunction · 0.50

Calls 6

buildAPIUrlFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80
warnMethod · 0.65
buildAuthHeadersFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected