MCPcopy Create free account
hub / github.com/bytebase/bytebase / resolveSchemaTarget

Method resolveSchemaTarget

backend/api/mcp/tool_schema.go:296–312  ·  view source on GitHub ↗

resolveSchemaTarget runs the shared database resolver and handles the ambiguous case with elicitation fallback. Returns either a resolved database (on success) or a non-nil CallToolResult describing the error for the caller to return.

(ctx context.Context, req *mcp.CallToolRequest, input SchemaInput)

Source from the content-addressed store, hash-verified

294// case with elicitation fallback. Returns either a resolved database (on success)
295// or a non-nil CallToolResult describing the error for the caller to return.
296func (s *Server) resolveSchemaTarget(ctx context.Context, req *mcp.CallToolRequest, input SchemaInput) (*resolvedDatabase, *mcp.CallToolResult) {
297 resolveCtx, resolveCancel := context.WithTimeout(ctx, resolveTimeout)
298 defer resolveCancel()
299
300 resolved, err := s.resolveDatabase(resolveCtx, input.Database, input.Instance, input.Project)
301 if err != nil {
302 return nil, formatToolError(err)
303 }
304 if !resolved.ambiguous {
305 return resolved, nil
306 }
307 picked, elicitErr := s.elicitDatabaseChoice(ctx, req, resolved)
308 if elicitErr != nil {
309 return nil, formatAmbiguousResult(input.Database, resolved.candidates)
310 }
311 return picked, nil
312}
313
314// renderTableResult dispatches the `table=` drill-down path: it picks the unique
315// match (or returns an appropriate error result) and renders it as TableDetail.

Callers 1

handleGetSchemaMethod · 0.95

Calls 4

resolveDatabaseMethod · 0.95
elicitDatabaseChoiceMethod · 0.95
formatToolErrorFunction · 0.85
formatAmbiguousResultFunction · 0.85

Tested by

no test coverage detected