Tencent/WeKnora · error
mcp service not found
Error message
mcp service not found
What it means
ListByService looks up the parent MCP service by tenantID+serviceID before listing approvals; a nil row (not an error) from mcpRepo.GetByID yields this plain error. It signals the referenced MCP service record does not exist for the tenant.
Source
Thrown at internal/application/service/mcp_tool_approval_service.go:30
repo interfaces.MCPToolApprovalRepository
mcpRepo interfaces.MCPServiceRepository
}
// NewMCPToolApprovalService constructs the MCP tool approval service.
func NewMCPToolApprovalService(
repo interfaces.MCPToolApprovalRepository,
mcpRepo interfaces.MCPServiceRepository,
) interfaces.MCPToolApprovalService {
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{View on GitHub (pinned to 988cbb0330)
Solutions
- Verify the serviceID exists via the MCP service list/get API for the tenant
- Confirm the request targets the correct tenant
- Create the MCP service first if it was never provisioned
- Return a typed not-found error at the HTTP layer (404) rather than surfacing this raw
Example fix
// before
approvals, err := approvalSvc.ListByService(ctx, tenantID, serviceID)
// after
if _, err := mcpSvc.Get(ctx, tenantID, serviceID); err != nil {
return nil, err // surface not-found before listing approvals
}
approvals, err := approvalSvc.ListByService(ctx, tenantID, serviceID) Defensive patterns
Strategy: validation
Validate before calling
svc, err := mcpRepo.GetByID(ctx, tenantID, serviceID)
if err != nil { return err }
if svc == nil {
return fmt.Errorf("mcp service %q not found for tenant %d", serviceID, tenantID)
}
// now safe
approvals, err := approvalSvc.ListByService(ctx, tenantID, serviceID) Try / catch
approvals, err := approvalSvc.ListByService(ctx, tenantID, serviceID)
if err != nil {
if strings.Contains(err.Error(), "mcp service not found") {
return ErrServiceNotFound // map to 404 at the transport layer
}
return err
} Prevention
- Resolve serviceIDs from the tenant's own MCP service list, never from user input verbatim
- Include tenant filters in every lookup to avoid cross-tenant ID reuse
- Clean up approval references when deleting an MCP service
- Return typed not-found sentinel errors for easy errors.Is matching
When it happens
Trigger: Calling ListByService with a serviceID that does not exist in the tenant's MCP services, or one belonging to another tenant.
Common situations: Stale client cache holding a deleted service ID; wrong tenant header in a multi-tenant deployment; UUID/ID typo in the request; service was soft-deleted but references remain.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- tool_name is required
- MCP client config and service are required
- URL is required for SSE transport
- URL is required for HTTP Streamable transport
- MCP service is required
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/17d7038e08cc76a5.
Report an issue: GitHub.