{"record":{"id":"bfe1d7a6ffde6848","repo":"jaegertracing/jaeger","slug":"service-name-is-required","errorCode":null,"errorMessage":"service_name is required","messagePattern":"service_name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_span_names.go","lineNumber":53,"sourceCode":"// NewGetSpanNamesHandler creates a new get_span_names handler and returns the handler function.\nfunc NewGetSpanNamesHandler(\n\tqueryService *querysvc.QueryService,\n) mcp.ToolHandlerFor[types.GetSpanNamesInput, types.GetSpanNamesOutput] {\n\th := &getSpanNamesHandler{\n\t\tqueryService: queryService,\n\t}\n\treturn h.handle\n}\n\n// handle processes the get_span_names request.\nfunc (h *getSpanNamesHandler) handle(\n\tctx context.Context,\n\t_ *mcp.CallToolRequest,\n\tinput types.GetSpanNamesInput,\n) (*mcp.CallToolResult, types.GetSpanNamesOutput, error) {\n\t// Validate service name\n\tif input.ServiceName == \"\" {\n\t\treturn nil, types.GetSpanNamesOutput{}, errors.New(\"service_name is required\")\n\t}\n\n\t// Set default limit\n\tlimit := input.Limit\n\tif limit <= 0 {\n\t\tlimit = defaultSpanNameLimit\n\t}\n\n\t// Build query parameters\n\t// Normalize span kind to lowercase because storage backends store span kinds\n\t// in lowercase (e.g., \"server\") but the MCP schema documents uppercase examples\n\t// (e.g., \"SERVER\"). Without normalization, uppercase input silently returns\n\t// empty results instead of matching stored operations.\n\tquery := tracestore.OperationQueryParams{\n\t\tServiceName: input.ServiceName,\n\t\tSpanKind:    strings.ToLower(strings.TrimSpace(input.SpanKind)),\n\t}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_span_names.go#L35-L71","documentation":"The get_span_names MCP handler requires a service name because span names are queried per service. When input.ServiceName is empty it cannot scope the query, so handle returns this sentinel error before calling the query service.","triggerScenarios":"Calling the get_span_names MCP tool with ServiceName omitted or \"\"; often the caller skipped a prior get_services call and guessed no service.","commonSituations":"MCP client not enforcing required tool arguments; an LLM assuming span names are global rather than per-service; a UI dropdown left unselected.","solutions":["Fetch the available services via get_services and pass one as service_name","Validate service_name is non-empty in the caller before invoking the tool","Enforce the required field in the MCP tool input schema"],"exampleFix":"// before\nout, err := spanNames.Handle(ctx, req, types.GetSpanNamesInput{})\n// after\nservices, _ := getServices.Handle(ctx, req, types.GetServicesInput{})\nout, err := spanNames.Handle(ctx, req, types.GetSpanNamesInput{ServiceName: services[0]})","handlingStrategy":"validation","validationCode":"if input.ServiceName == \"\" {\n    return errors.New(\"service_name is required before calling get_span_names\")\n}","typeGuard":null,"tryCatchPattern":"out, err := handler.Handle(ctx, req, input)\nif err != nil && strings.Contains(err.Error(), \"service_name is required\") {\n    return fmt.Errorf(\"call get_services first, then pass one service to get_span_names\")\n}","preventionTips":["Resolve service names via get_services before querying span names","Make service_name required in the tool input schema","Validate dropdown/form selections are non-empty before dispatching tool calls"],"tags":["jaeger","mcp","validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}