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

Function buildExecuteSqlTool

src/utils/tool-metadata.ts:217–233  ·  view source on GitHub ↗

* Build execute_sql tool metadata for API response

(sourceId: string, toolConfig?: ToolConfig)

Source from the content-addressed store, hash-verified

215 * Build execute_sql tool metadata for API response
216 */
217function buildExecuteSqlTool(sourceId: string, toolConfig?: ToolConfig): Tool {
218 const executeSqlMetadata = getExecuteSqlMetadata(sourceId);
219 const executeSqlParameters = zodToParameters(executeSqlMetadata.schema);
220
221 // Extract readonly and max_rows from toolConfig
222 // ToolConfig is a union type, but ExecuteSqlToolConfig and CustomToolConfig both have these fields
223 const readonly = toolConfig && 'readonly' in toolConfig ? toolConfig.readonly : undefined;
224 const max_rows = toolConfig && 'max_rows' in toolConfig ? toolConfig.max_rows : undefined;
225
226 return {
227 name: executeSqlMetadata.name,
228 description: executeSqlMetadata.description,
229 parameters: executeSqlParameters,
230 readonly,
231 max_rows,
232 };
233}
234
235/**
236 * Build search_objects tool metadata for API response

Callers 1

getToolsForSourceFunction · 0.85

Calls 2

getExecuteSqlMetadataFunction · 0.85
zodToParametersFunction · 0.85

Tested by

no test coverage detected