MCPcopy Create free account
hub / github.com/bytebase/dbhub / getSearchObjectsMetadata

Function getSearchObjectsMetadata

src/utils/tool-metadata.ts:172–194  ·  view source on GitHub ↗
(sourceId: string)

Source from the content-addressed store, hash-verified

170 * @returns Tool name, description, and annotations
171 */
172export function getSearchObjectsMetadata(sourceId: string): { name: string; description: string; title: string } {
173 const sourceIds = ConnectorManager.getAvailableSourceIds();
174 const sourceConfig = ConnectorManager.getSourceConfig(sourceId)!;
175 const dbType = sourceConfig.type;
176 const isSingleSource = sourceIds.length === 1;
177
178 const toolName = isSingleSource ? "search_objects" : `search_objects_${normalizeSourceId(sourceId)}`;
179 const title = isSingleSource
180 ? `Search Database Objects (${dbType})`
181 : `Search Database Objects on ${sourceId} (${dbType})`;
182 // Prepend the user-provided `description` from the source config (if set)
183 // so AI clients reading the MCP tool list see the source's purpose first.
184 const userDescPrefix = buildSourceDescriptionPrefix(sourceConfig.description);
185 const description = isSingleSource
186 ? `${userDescPrefix}Search and list database objects on the ${dbType} database`
187 : `${userDescPrefix}Search and list database objects on the '${sourceId}' ${dbType} database`;
188
189 return {
190 name: toolName,
191 description,
192 title,
193 };
194}
195
196/**
197 * Convert custom tool parameter configs to Tool parameter format

Calls 4

normalizeSourceIdFunction · 0.85
getAvailableSourceIdsMethod · 0.80
getSourceConfigMethod · 0.80

Tested by

no test coverage detected