Tencent/WeKnora · error
tool_name is required
Error message
tool_name is required
What it means
Argument validation at the top of SetRequireApproval: the toolName parameter is empty, so there is no tool whose approval requirement could be toggled. It fires before any service or approval lookup, indicating the caller omitted the tool_name from the request.
Source
Thrown at internal/application/service/mcp_tool_approval_service.go:39
return &mcpToolApprovalService{repo: repo, mcpRepo: mcpRepo}
}
func (s *mcpToolApprovalService) ListByService(ctx context.Context, tenantID uint64, serviceID string) ([]*types.MCPToolApproval, error) {
svc, err := s.mcpRepo.GetByID(ctx, tenantID, serviceID)
if err != nil {
return nil, err
}
if svc == nil {
return nil, fmt.Errorf("mcp service not found")
}
return s.repo.ListByService(ctx, tenantID, serviceID)
}
func (s *mcpToolApprovalService) SetRequireApproval(
ctx context.Context, tenantID uint64, serviceID, toolName string, require bool,
) error {
if toolName == "" {
return fmt.Errorf("tool_name is required")
}
svc, err := s.mcpRepo.GetByID(ctx, tenantID, serviceID)
if err != nil {
return err
}
if svc == nil {
return fmt.Errorf("mcp service not found")
}
row := &types.MCPToolApproval{
TenantID: tenantID,
ServiceID: serviceID,
ToolName: toolName,
RequireApproval: require,
}
return s.repo.Upsert(ctx, row)
}
func (s *mcpToolApprovalService) IsRequired(ctx context.Context, tenantID uint64, serviceID, toolName string) (bool, error) {View on GitHub (pinned to 988cbb0330)
Solutions
- Supply the exact tool name from the MCP service's tool list
- Validate tool_name is non-empty in the HTTP handler before calling the service
- Check that the request struct field maps the correct JSON key (tool_name)
- Default the UI/API to send the wildcard or per-tool name the approval system expects
Example fix
// before
err := approvalSvc.SetRequireApproval(ctx, tenantID, serviceID, toolName, true)
// after
if toolName == "" {
return errors.New("tool_name is required")
}
err := approvalSvc.SetRequireApproval(ctx, tenantID, serviceID, toolName, true) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(req.ToolName) == "" {
return http.StatusBadRequest // or a typed validation error
}
err := approvalSvc.SetRequireApproval(ctx, tenantID, serviceID, req.ToolName, req.Require) Try / catch
err := approvalSvc.SetRequireApproval(ctx, tenantID, serviceID, toolName, require)
if err != nil && strings.Contains(err.Error(), "tool_name is required") {
return ErrMissingToolName // 400 Bad Request
} Prevention
- Make tool_name required in request schemas/DTOs with explicit validation tags
- Derive tool names from the MCP service's tool metadata, not free-form input
- Trim whitespace before sending
- Cover the empty-toolName case in handler tests
When it happens
Trigger: Calling SetRequireApproval with toolName="" (empty string literal, unset struct field, or request body missing tool_name).
Common situations: Client deserialization omits tool_name when the JSON field is absent; binding an empty form field; passing a variable that was never populated from tool metadata.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- knowledge_id is required
- mcp service not found
- MCP client config and service are required
- URL is required for SSE transport
- URL is required for HTTP Streamable transport
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/ff00eea37dbb4c74.
Report an issue: GitHub.